Analytical Solution of Double Integral in Symbolic Math

The following integral is known to have an analytical solution
int(sin(x)*(a^2*cos(x)^2 + sin(x)^2/a)^(1/2), x)
but Symbolic Math only returns the same command when I try to calculate it between the limits: 0 to pi.
Is there a way to calculate this integral analytically?

4 Commenti

Hi Saeid, is this homework, and do you know if a>1 or a<1?
Hi,
I'm actually a bit too old to try to figure out my homework solutions from a forum, but to answer your question: no this is not homework.
I am just wondering why Symbolic Math fails to yield an analytical solution that I assumed is relatively simple for it to produce.
"a" can have any value that is larger than 0.
For a>1 the result is a function containing arctan(sqrt(x^3-1))
For a<1 the result is a function containing arctanh(sqrt(1-x^3))
Hi Saeid,
I don't much like to say it, but Matlab symbolics is not real capable compared to some other stuff out there. Mathworks does not appear to be too concerned about it. I believe this is because they are after all a commercial entity, and the real money lies elsewhere. Not a great look, but it's hard to blame them.
For this problem you can substitute u = cos(x), du = -sin(x) dx, (1-u^2) = sin(x)^2. Since there are only even powers of sin and cos, integral{0,p1} dx = 2*integral{0,1} du. Saving the minus sign until some later time, you get
% int(sin(x)*(a^2*cos(x)^2 + sin(x)^2/a)^(1/2), x)
syms u a
I1 = int((a^2*u^2 + (1-u^2)/a)^(1/2), u) % doesn't work
but with a little more help
I2 = int(((a^2-1/a)*u^2 + (1/a))^(1/2), u)
Assumptions help a bit.
assume(a<1)
I1 = int((a^2*u^2 + (1-u^2)/a)^(1/2), u) % still doesn't work
I2 = int(((a^2-1/a)*u^2 + (1/a))^(1/2), u)
assume(a>1)
I1 = int((a^2*u^2 + (1-u^2)/a)^(1/2), u) % both work and give the same result
I2 = int(((a^2-1/a)*u^2 + (1/a))^(1/2), u)
Integral I1 only works for a>1 in which case it gives the same result as I2. So consider just I2. For the definite integral
J2 = 2*int(((a^2-1/a)*u^2 + (1/a))^(1/2), u,0,1)
there are three cases above and of these only only the a>1 case works.
J2 = a + log((a^3 - 1)^(1/2) + a^(3/2))/(a*(a^2 - 1/a)^(1/2))
That's it. This does evaluate to 2 as a-->1, as it should.
By all rights the a<1 case should have worked, but given the form it is in, it's a complex function that happens to come out real. So it's hard to see the inverse trig function in there.
In a fairly simple case like this, and given all the messing around one has to do getting syms to cooperate, for me personally it would be faster to rearrange it a bit and go to a table of integrals.
p.s. my fond school days are long gone.
Thanks for the comprehensive response, David.
This definitely will help, and as you mentioned, I guess MATLAB has its focus on other areas where it does have a clear advantage, and almost no day goes by without me being surprised by a really useful feature I find in it!

Accedi per commentare.

 Risposta accettata

syms x
a = 2;
sol = int(sin(x).*(a.^2*cos(x).^2 + sin(x).^2/a).^(1/2),x,[0,pi])
sol = 
vpa(sol) % use vpa
ans = 
2.4543553915615044795171783624435

2 Commenti

When int is not able to calculate the definite integral for expression, you can use vpa to approximate the value. Otherwise try with integral for numerical integration
As the given expression seems to be nonlinear, a closed form symbolic solution cannot exist for it between 0 and pi, You can instead use integrateByParts option to evaluate and simplify it.
syms x t
a = 2;
sol = int(sin(x).*(a.^2*cos(x).^2 + sin(x).^2/a).^(1/2),x,[0 pi/2])
sol = 
F = integrateByParts(sol,sin(x)) %
F = 
simplify(F)
ans = 

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2022b

Richiesto:

il 23 Nov 2022

Commentato:

il 29 Nov 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by