Hi. I'm new to symbolic toolbox.
Can anyone please explain why there is a different result obtained from what is virtually two identical expressions?
How is Matlab interpreting f1, that it produces an "unexpected" result for the integral_f1?
syms a b t
f1 = a*(1-t/b);
integral_f1 = int(f1, t)
integral_f1 = 
f2 = a - a*t/b;
integral_f2 = int(f2, t)
integral_f2 = 

 채택된 답변

Torsten
Torsten 2024년 1월 8일
편집: Torsten 2024년 1월 8일

1 개 추천

If you had specified a definite integral, the results would have been the same.
Indefinite integrals are only unique up to an arbitrary constant. And the constant in the first call to int is -ab/2, in the second call 0. So everything in order.
The question "why" MATLAB decided to integrate the way it did can only be explained by the software developers, I guess. You could ask Technical Support if you are really interested in the technical details.

댓글 수: 3

Thank you for the answer Torsten.
Well, the issue is that I was expecting MATLAB to default to a zero constant, and i was puzzled by the first call.
I don't understand the underlying rule it uses for picking the random constant i.e. how is the form (arrangement) of the expresion to be integrated influencing the outcome.
"I don't understand the underlying rule it uses"
No one other than people who wrote it knows the workings of SymEngine or the set of instructions it follows to give the output for computations involving symbolic variables and expressions.
As Torsten suggested, you can ask TMW technical support regarding this.
Well, the issue is that I was expecting MATLAB to default to a zero constant, and i was puzzled by the first call.
If you always want an integration constant of 0, use
syms a b t
f1 = a*(1-t/b);
integral_f1 = int(f1, t, 0, t)
integral_f1 = 
f2 = a - a*t/b;
integral_f2 = int(f2, t, 0, t)
integral_f2 = 

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

질문:

2024년 1월 8일

댓글:

2024년 1월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by