问题描述
请告诉我如何在python中实现如图1(或代码中的第18-19行)所示的积分?
尝试通过 sympy.integrate 但失败 - ValueError: Invalid limits specified: (20.665,)
import numpy as np
import sympy
from scipy import interpolate
b_2 = 6.67
l_k = 24.0
U_1 = [0.0,4.3,8.1,11.4,14.1,16.3,18.0,19.3,20.2,20.7]
V_1 = [0.0,0.6,1.8,3.5,5.7,8.3,11.3,14.8,18.6,22.8]
"The first derivative of the centroid equation"
def Cn_1(x):
x_points = U_1
y_points = V_1
tck = interpolate.splrep(x_points,y_points)
return interpolate.splev(x,tck,der = 1)
"Calculating the length of the centroid depending on the X coordinate "
def l_cn(x):
return sympy.integrate((1 + Cn_1(x)**2)**0.5,x)
"Full centroid length"
L_max = l_cn(l_k - 0.5 * b_2)
print("L_max = ",L_max)
Image of a piece of code written in MathCad 2000 that I am trying to port to Python
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)