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

  • Context: MATLAB 
  • Thread starter Thread starter aperception
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 5K views
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!