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
Click For Summary

Discussion Overview

The discussion revolves around the behavior of MATLAB's Symbolic Math Toolbox when computing definite integrals, specifically why certain integrals do not yield explicit answers. Participants explore the implications of variable assumptions and the syntax used in MATLAB.

Discussion Character

  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant questions why the definite integral int(x/sqrt(x^2+a^2),0,10) does not return a result, despite the indefinite integral providing an expected answer.
  • Another participant suggests that the issue may stem from the need to assume that the variable 'a' is real, indicating that the sign of 'a' affects the solution.
  • A later reply proposes using the command evalin(symengine,'assume(a in R_)') to clarify the assumptions about 'a' before computing the integral.
  • Another participant offers an alternative method to declare both 'x' and 'a' as real using syms x a real, suggesting it may be easier to remember.
  • One participant expresses gratitude for the clarification provided by others in the thread.
  • Another participant references the MATLAB documentation as a helpful resource for understanding the syms function.

Areas of Agreement / Disagreement

Participants generally agree on the importance of declaring variable assumptions in MATLAB to obtain correct results, but there is no consensus on the best approach to do so.

Contextual Notes

Limitations include the dependence on the assumptions made about the variable 'a' and the potential for different interpretations of the results based on those assumptions.

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!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
27
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
10K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K