如何反转 scipy quad 函数以传入弧长并接收 (t) 的值?

How do you invert scipy quad function to pass in an arc length and receive a value for (t)?

如果我要 运行 类似于下面的代码,我将椭圆的次弧和长弧作为 3.05 和 2.23 传递,弧形成 50 度角,我将如何能够将 2.531432761012828 的输出作为弧长传回求解 t?谢谢!

import math
from scipy.integrate import quad
import numpy as np
t = math.atan(3.05*math.tan(5*math.pi/18)/2.23)
Dx = lambda t: -3.05 * np.sin(t)   
Dy = lambda t: 2.23 * np.cos(t)
quad(lambda t: np.sqrt(Dx(t)**2 + Dy(t)**2), 0, t)

最后一个的输出是:(2.531432761012828, 2.810454936566873e-14)

要找到积分的上限,给定积分值,可以将 fsolve 应用于计算可变上限积分的函数。示例(不重复您已有的行):

from scipy.optimize import fsolve
target = 2.531432761012828
fun = lambda s: quad(lambda t: np.sqrt(Dx(t)**2 + Dy(t)**2), 0, s)[0] - target
s0 = fsolve(fun, 0)[0]
print(s0) 

这会打印 1.02051

我不喜欢用同一个字母表示积分变量和上限,所以在我的代码中上限称为s