Inconsistent results from "int" function

Hi, everyone. For the same question, the "int" function provided me with different results.
syms x y
int(x*y/24+y^2/48,x)
int((y*(2*x + y))/48,x)
The second line gave me "(x*y*(x + y))/48" which was what I originally wanted,
but the third line gave me "'(y*(2*x + y)^2)/192" which is wrong.
Can anyone explain the reason?
Thanks for your time and help in advance!

 Respuesta aceptada

Alan Stevens
Alan Stevens el 27 de Nov. de 2022

2 votos

You can express '(y*(2*x + y)^2)/192 as (x*y*(x + y))/48+y^3/198
As far as the integral is concerned y is a constant, so the two results are the same to within a constant, which is all you can guarantee from an integral with no specific limits.

5 comentarios

YoungJoo Lee
YoungJoo Lee el 27 de Nov. de 2022
Dear Alan,
Thanks for your kind answer. I am also aware that the problem is about an indefinite integral, and the result may get involved with a constant. However, I think there is no mathematically-valid reason that the constant can be specified as y^3/192. If this is how the "int" function works, it seems the function cannot be used for indefinite integral problems...
However, I think there is no mathematically-valid reason that the constant can be specified as y^3/192.
There is a mathematically-valid reason that each function f that only depends on y can be specified as the constant of integration. The reason is d/dx(f(y)) = 0.
MATLAB does not perform an "evaluation of the most beautiful antiderivative".
In this case, you can use
syms x y
int(x*y/24+y^2/48,x,0,x)
ans = 
int((y*(2*x + y))/48,x,0,x)
ans = 
But in other examples, the lower limit might be different from 0 to get a "nice" antiderivative.
YoungJoo Lee
YoungJoo Lee el 27 de Nov. de 2022
Dear Torsten,
I appreciate you on your detailed explanation. I agree with you that "any" function f that only depends on y can be the constant of the integration in my problem. However, I am still doubting whether it is reasonable to provide only one specific function for y (e.g., y^3/192 in my case) as output, as if it were the only and unique answer...
I believe, for my problem, providing something like "(x*y*(x + y))/48+C (where C is a constant)" as output would be more appropriate.
Anyway, I got your point and also thank you for sharing your tip.
Torsten
Torsten el 27 de Nov. de 2022
I believe, for my problem, providing something like "(x*y*(x + y))/48+C (where C is a constant)" as output would be more appropriate.
"(x*y*(x + y))/48+C(y) (where C is a function solely depending on y)"
YoungJoo Lee
YoungJoo Lee el 27 de Nov. de 2022
Oh, sure. Thanks for the correction!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Variables en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Nov. de 2022

Comentada:

el 27 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by