Analytical Solution of Double Integral in Symbolic Math

16 views (last 30 days)
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 Comments
David Goodmanson
David Goodmanson on 24 Nov 2022
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.
Saeid
Saeid on 29 Nov 2022
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!

Sign in to comment.

Accepted Answer

VBBV
VBBV on 23 Nov 2022
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 Comments
VBBV
VBBV on 23 Nov 2022
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
VBBV
VBBV on 23 Nov 2022
Edited: VBBV on 23 Nov 2022
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 = 

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!