我计划计算b(也是Xo轴上的x),从0到x的曲线(函数)长度等于1
通过了解:https://www.mathsisfun.com/calculus/arc-length.html
(从0到b的积分)∫ (1+((f'(x))^2)^(1/2)dx=1
而且:
(从a到b的积分)∫ f(x)dx=f(b)-f(a)
我们可以通过
1-F(0)+F(b)=0,这里这是一个关于x的方程,因为我说的b是x轴上的x
所以现在我尝试了f(x)=x**3(下面是完整的代码)
我从SymPy得到的只是条件集,而不是数字。当然,条件集不能由evalf()求值
我的问题是:
代码:
from __future__ import division
import matplotlib.pyplot as plt
from sympy import *
x, y, z = symbols('x y z', real=True)
function1 = x**3
Antiderivative1 = integrate((1+(diff(function1))**2)**(1/2), x)
b = solveset(Eq(1 + Antiderivative1.subs(x, 0).evalf() - Antiderivative1, 0), x)
print(b)
这就是输出:
ConditionSet(x, Eq(x*hyper((-0.5, 1/4), (5/4,), 9*x**4*exp_polar(I*pi)) - 4.0*gamma(5/4)/gamma(1/4), 0), Complexes)
提前谢谢,抱歉语法错误
请注意,您应该使用
S(1)/2
或Rational(1, 2)
(或sqrt
),而不是1/2
,这将在Python中为您提供float
。有了这个我们就有了虽然这与Wolfram Alpha的结果形式不同,但很容易是相同的函数(直到一个加法常数)。从这个结果或者Wolfram Alpha的结果来看,我非常怀疑你是否能找到解析解(使用SymPy或其他方法)
但是你可以找到一个数值解。不幸的是,symphy的
lambdify
函数中有一个bug,这意味着nsolve
不能使用此函数:我们可以自己用牛顿步来做:
相关问题 更多 >
编程相关推荐