Integral from sin(x+y) from dx shows wierd result

28 visualizaciones (últimos 30 días)
Penescu Vlad
Penescu Vlad el 31 de Mayo de 2020
Comentada: Penescu Vlad el 1 de Jun. de 2020
I have to integrate the function f = sin (x+y) giveing that a=0 and b = pi /2 ( the heads of the integral ) ... the normal answer should had been sin(y) + cos(y) but my result is (2^(1/2)*sin(y + pi/4)) ... I think the problem are the heads becouse if I simply do int(f,x) I get the right answer , but I put the head int(f,x,a,b) it show that weird result
  2 comentarios
Walter Roberson
Walter Roberson el 31 de Mayo de 2020
I get cos(y) + sin(y) when I try.
Can you post your code for testing ?
Penescu Vlad
Penescu Vlad el 31 de Mayo de 2020
yeah my bad is y not x *

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 31 de Mayo de 2020
Editada: John D'Errico el 31 de Mayo de 2020
Computers don't really care that YOU think it looks wierd. The fact is, that form for the integral is correct, just as much so as the solution that you like. It may depend on your MATLAB release, of course, since with R2019b, I get:
syms x y
>> int(sin(x+y),x,0,pi/2)
ans =
cos(y) + sin(y)
However, if we recognize the trig identity:
sin(u + v) = sin(u)*cos(v) + cos(u)*sin(v)
Now consider what happens if u = y, and v = pi/4. Then
sin(y + pi/4) = sin(y)*cos(pi/4) + cos(y)*sin(pi/4)
But sin(pi/4) = cos(pi/4) = sqrt(2)/2. Therefore you should see that
cos(y) + sin(y) = 2/sqrt(2) * sin(y + pi/4) = sqrt(2)*sin(y + pi/4)
Same answer. You may think it is wierd. But at least your release of the symbolic toolbox decided it was a simple form to report the solution. In fact, it arguably is simpler, in the sense there is only one term in the solution. The solution you got was entirely valid, as was the alternative. Getting into the mind of a computer is sometimes difficult to know why it may choose any specific form for the solution.
  5 comentarios
madhan ravi
madhan ravi el 1 de Jun. de 2020
Editada: madhan ravi el 1 de Jun. de 2020
+1.An impressive and detailed answer ;).
Penescu Vlad
Penescu Vlad el 1 de Jun. de 2020
I got another way to do it I think ... by using expand(int(f,x,a,b)) it shows the answer the way I wanted ... But thanks for the explacations, it helped a lot

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by