MATLAB Why Does MATLAB's Symbolic Math Toolbox Struggle with Some Definite Integrals?

  • Thread starter Thread starter aperception
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion revolves around the challenges of computing definite integrals in MATLAB, specifically using the symbolic toolbox. A user encounters an issue where the integral of x/sqrt(x^2+a^2) does not yield a result when evaluated from 0 to 10, despite a successful indefinite integral calculation. The warning indicates that an explicit integral could not be found, which confuses the user as they expect a specific answer. The conversation highlights the importance of declaring variables as real using the 'assume' function to facilitate correct evaluations. The user finds clarity in understanding how to declare variables and appreciates the MATLAB documentation on symbolic variables for further guidance.
aperception
Messages
12
Reaction score
0
Does anybody know much about how this works?

I can't understand why it doesn't give me an answer for definite integrals sometimes... e.g. in Matlab R2011a:

syms x a;
int(x/sqrt(x^2+a^2))

gives the answer (a^2 + x^2)^(1/2) as expected.

But int(x/sqrt(x^2+a^2),0,10) gives - Warning: Explicit integral could not be found.

This doesn't really make any sense as the answer should be (a^2 + 10^2)^(1/2) - a. Is there some way to understand this strange behavior?
 
Physics news on Phys.org
In this case you have to assume that a is real. Even then the solution will be plus/minus a given that we don't know the sign of a.

evalin(symengine,'assume(a in R_)')
syms x a
int(x/sqrt(x^2+a^2),0,10);

ans =

(a^2 + 100)^(1/2) - abs(a)
 
Ah, thank you! I understand!
 
Another way to declare a real (the code below will actually declare both x and a real, but the example stands) is:
Code:
syms x a real

I find it easier to remember that way.
 
that's perfect, thank you!
 
Back
Top