Ask Your Question
1

Integrate() does not integrate

asked 2012-05-01 08:42:17 -0500

Daniel gravatar image

updated 2012-05-02 09:30:09 -0500

Good Evening

When I ask sage:

var('phi r')
phi1 = 0
phi2 = 2*pi
r1 = 3
r2 = 5
fpolar = - sqrt(-2*r^2*cos(phi)^2+25)
BI = fpolar
BI= integral(BI, (phi,phi1,phi2))
BI= integral(BI, (r,r1,r2))
BI

the result is:

-integrate(integrate(sqrt(-2*r^2*cos(phi)^2 + 25), phi, 0, 2*pi), r, 3,
5)

I've found no way to make sage integrate the expresion. It repeats my input and iam not given any new information.

When i try

BI.n()

i get

ValueError: Integrand has wrong number of parameters

Same Problem with indefinite Integrals

in:

BI = fpolar
BI= integral(BI, phi)
BI

out:

-integrate(sqrt(-2*r^2*cos(phi)^2 + 25), phi)

Why? what do I need to do to get the desired output?

edit retag flag offensive close merge delete

Comments

I want to do things symbolic. When i did it in maple yesterday, it gave me nonsense. If even $$$ got Problems with such an equation, maybe it should be an feature request. Unfortuantly iam just a student of mechanical engineering, so i cant jugdge this situation. (Is it my fault or the CAS's, i suspect mine) I,however, can do it with my own sweat and tears. Thank you so far. UPDATE: Wolfram Mathematica semms to be unable to do it (at least when you go the simple way and just tell it to Integrate)

Daniel gravatar imageDaniel ( 2012-05-01 21:00:00 -0500 )edit

3 answers

Sort by » oldest newest most voted
2

answered 2012-05-01 15:59:06 -0500

niles gravatar image

Maxima is the symbolic calculation software that Sage uses for integrals. It seems to be unable to evaluate this integral:

sage: maxima('integrate(sqrt(cos(x)^2+25), x)') 'integrate(sqrt(cos(x)^2+25),x)

On the other hand, now that we're talking about interfacing with Maxima directly, you could use Maxima's dblint function for this integral:

sage: maxima('r(x):= 0')
r(x):=0
sage: maxima('s(x):= 2*pi')
s(x):=2*pi
sage: maxima('g(x,y):= sqrt(x^2*cos(y)^2 + 25)')
g(x,y):=sqrt(25+x^2*cos(y)^2)
sage: BI = maxima('dblint(g, r, s, 3,5)')
sage: BI.n()
72.0389037585788

Unfortunately, I don't know how to access this directly from Sage.

edit flag offensive delete link more

Comments

`sage: maxima_calculus.d[tab]` doesn't even give this `dblint` command, for some reason. Could be useful to make it do that. Though as I point out, we shouldn't expect that this integral has a nice formula.

kcrisman gravatar imagekcrisman ( 2012-05-01 17:01:11 -0500 )edit

numerical calculation over simsons rule may be usefull in some cases, thanks. If you want to do this in SAGE you jus need to (i think) taylor-approximate the function and have an easy life with Integration. I will remeber that when i dont need symbolics.

Daniel gravatar imageDaniel ( 2012-05-01 22:04:56 -0500 )edit
1

answered 2012-05-01 15:45:41 -0500

kcrisman gravatar image
sage: var('r phi')
(r, phi)
sage: integral(-sqrt(-2*r^2*cos(phi)^2+25), (phi,0,2*pi))
-integrate(sqrt(-2*r^2*cos(phi)^2 + 25), phi, 0, 2*pi)
sage: integral(-sqrt(-2*r^2*cos(phi)^2+25), phi)
-integrate(sqrt(-2*r^2*cos(phi)^2 + 25), phi)

So Sage/Maxima knows that the minus sign comes out. Given that Wolfram Alpha indicates that the answer is an elliptic integral of the second kind, it's not totally surprising that we don't get a symbolic answer here. Certain Maxima things will output elliptic integrals/functions, but not too many.

So what is your desired output? Keep in mind that many (most?) functions do not have antiderivatives expressible in terms of elementary functions.

edit flag offensive delete link more
0

answered 2012-05-02 09:29:53 -0500

Daniel gravatar image

I have the Solution (partly) The function was wrong, it came up because i wrecked it with a faulty transformation.

However I was able to do the first Step of integration with the "faulty" function.

IN:

var('a b')
ftrick = -sqrt(r^2*a + b)
BItrick = integral(ftrick, (r,r1,r2))

OUT:

Is  a  positive or negative?

IN:

view('AHA!')
assume(a<0)
assume(b>0)
BItrick = integral(ftrick, (r,r1,r2))
view(BItrick)
forget()
BItrick2 = BItrick.substitute(a == -2*cos(phi)^2)
BItrick2 = BItrick2.substitute(b == 25 )
view(BItrick2)

BItrick2 =

1/4*(6*sqrt(-18*cos(phi)^2 + 25)*cos(phi)^2 +
25*sqrt(2)*sqrt(cos(phi)^2)*arcsin(3/5*sqrt(2)*sqrt(cos(phi)^2)))/cos(ph\
i)^2 - 5/4*(2*sqrt(-50*cos(phi)^2 + 25)*cos(phi)^2 +
5*sqrt(2)*sqrt(cos(phi)^2)*arcsin(sqrt(2)*sqrt(cos(phi)^2)))/cos(phi)^2

When I try to go on sage says it doent know wheather cos(phi) ist positive or negative. So i divided the integral.

forget()
assume(cos(phi) >0)
erg1 = integral(BItrick2, (phi,phi1,0.5*pi))
forget()
assume(cos(phi) <0)
erg2 = integral(BItrick2, (phi,0.5*pi,1.5*pi))
forget()
assume(cos(phi) >0)
erg3 = integral(BItrick2, (phi,1.5*pi,2*pi))
erg = erg1+erg2+erg3

Sage does calculate for 2 minutes and then it gives me the input. The system is unable to integrate.

If you have problems with Integrations try using assume() and forget()

Thank you for your Help.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-05-01 08:42:17 -0500

Seen: 675 times

Last updated: May 02 '12