Why does MATLAB (Symbolic Math Toolbox) not integrate this simple function.

조회 수: 2 (최근 30일)
Sebastian Götz
Sebastian Götz 2022년 6월 3일
편집: John D'Errico 2022년 6월 4일
I am trying to integrate the following function symbolically, but MATLAB won't resolve this.
syms x a
int((1-x^2/a^2)^(3/2),x,-a,a)
ans = 
It should be and Wolfram Alpha calculates it without problem. Is there a way to get this result in MATLAB too?

답변 (3개)

John D'Errico
John D'Errico 2022년 6월 3일
편집: John D'Errico 2022년 6월 4일
Your problem is, you need to define a properly. So, if you do only this:
syms x a
I = int((1-x^2/a^2)^(3/2),x)
I = 
Now you see that MATLAB finds a solution, but it does not know anything about a. We can try this, but MATLAB is still confused.
simplify(subs(I,a) - subs(I,-a))
ans = 
The problem there is, if a takes on some general complex value, that result may not be a simple thing. The point being:
syms a
simplify(a*sqrt(-1/a^2))
ans = 
syms a real
simplify(a*sqrt(-1/a^2))
ans = 
For real a, that last one reduces to +/-i, depending on the sign of a.
syms a real positive
simplify(a*sqrt(-1/a^2))
ans = 
i
Only in the third case does a drop out completely.
So if we specify a more clearly.
syms x
syms a real positive
I = int((1-x^2/a^2)^(3/2),x)
I = 
simplify(subs(I,a) - subs(I,-a))
ans = 

Walter Roberson
Walter Roberson 2022년 6월 3일
integrate 0 to a and multiply the result by 2
  댓글 수: 1
Sebastian Götz
Sebastian Götz 2022년 6월 3일
Thanks, for the workaround. However, shouldn't it work as well if I integrate directly from -a to a? Why can't MATLAB do it?

댓글을 달려면 로그인하십시오.


Paul
Paul 2022년 6월 3일
syms x a real
I = int(simplify((1-x^2/a^2)^(3/2)),x,-a,a)
I = 
  댓글 수: 2
Sebastian Götz
Sebastian Götz 2022년 6월 3일
This works as I hoped. Thanks. It is still strange that it works with the exponent 1/2
syms x a
int((1-x^2/a^2)^(1/2),x,-a,a)
ans = 
and with the exponent 2
int((1-x^2/a^2)^(2),x,-a,a)
ans = 
without the simplify but not with 3/2.
int((1-x^2/a^2)^(3/2),x,-a,a)
ans = 
Paul
Paul 2022년 6월 3일
Sometimes int() works in mysterious ways, I suppose. I believe I've seen other case where int() does not return a solution w/o manipulating the integrand into a different form.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by