# crash on integral attempt

Sage version 6.5 app on Mac OS 10.95. Following code tries to evaluate the total curvature of a certain space curve. The answer should be given as a complete elliptic integral of the second kind (which I then hoped to numerically evaluate for a range of values of r). But I get "Error executing code in Maxima".

r,t = var('r,t')
assume(r > 0)
X = vector((r * cos(t) - (1/3)* r^3 * cos(3*t),
- r * sin(t) - (1/3) *r^3 * sin(3*t),
r^2 *cos(2*t)))
Xtheta = X.diff(t)
AbsXtheta = abs(Xtheta)
T = (1/AbsXtheta) * Xtheta    ## unit tangent
kappa = abs(T.diff(t))
print(kappa)
Curvature = integral(kappa,t,0,2*pi)

edit retag close merge delete

Sort by » oldest newest most voted

If you final aim is to numerically evaluate for a range of values of r, you can do the following:

sage: Curvature = lambda r : numerical_integral(kappa(r=r),0,2*pi)


This defines Curvature as a function of r that computes the integral numerically. Then you can do:

sage: Curvature(2)
(16.716333138156095, 4.079736172387635e-10)
sage: Curvature(10)
(18.745787025936806, 2.081200437091458e-13)


The second value is an estimation of the error, if you just want the approximated value of the integral, you can do:

sage: Curvature = lambda r : numerical_integral(kappa(r=r),0,2*pi)
sage: Curvature(2)
16.716333138156095

more

It doesn't help resolving the question immediately, but it seems the problem here is maxima's "abs_integrate" package. In maxima:

(%i1) display2d:false;
(%o1) false
(%i2) integrate(sqrt(16*r^2*sin(t)^4 + 9*r^4 - 16*r^2*sin(t)^2 + 10*r^2 + 1)/(r^2 + 1),t,0,2*%pi);
(%o2) ('integrate(sqrt(16*r^2*sin(t)^4-16*r^2*sin(t)^2+9*r^4+10*r^2+1),t,0,2*%pi)) /(r^2+1)
(%o3) "/usr/local/sage/sage-git/local/share/maxima/5.34.1/share/contrib/integration/abs_integrate.mac"
(%i4) integrate(sqrt(16*r^2*sin(t)^4 + 9*r^4 - 16*r^2*sin(t)^2 + 10*r^2 + 1)/(r^2 + 1),t,0,2*%pi);
sign: argument cannot be imaginary; found %i
#0: intfudu(exp=sqrt(9*r^4*%e^-(4*%i*t)+8*r^2*%e^-(4*%i*t)+%e^-(4*%i*t)+r^2*%e^-(8*%i*t)+r^2)*%e^(2*%i*t),%voi=t (partition.mac line 95)
#1: extra_integrate(q=sqrt(9*r^4*%e^-(4*%i*t)+8*r^2*%e^-(4*%i*t)+%e^-(4*%i*t)+r^2*%e^(8*%i*t)+r^2)*%e^(2*%i*t),x=t)
-- an error. To debug this try: debugmode(true);


so, it doesn't seem within maxima's current capabilities to express this integral into functions that allow for more efficient approximation methods.

more