Question about numerical integration for cos vs cosd

2 visualizaciones (últimos 30 días)
Chi So
Chi So el 8 de Oct. de 2020
Comentada: Chi So el 8 de Oct. de 2020
Hi all,
I came across this question yesterday. Here is the code:
syms theta
y = double(int(cos(theta),theta,[0 pi/12]));
The answer, of course, y = 0.2588.
However, when I use cosd instead:
y = double(int(cosd(theta),theta,[0 15]));
Then y = 14.8292.
If I do it by hand the answer is y = 0.2588 for both case.
I'm wondering what happened when we use cosd with int.
I also checked WolframAlpha and it gives me those two different answers as well. Did I misunderstandd anything during my academic years?

Respuesta aceptada

James Tursa
James Tursa el 8 de Oct. de 2020
Editada: James Tursa el 8 de Oct. de 2020
By hand:
int cosd(theta)
= int cos(theta*pi/180)
= sin(theta*pi/180)*180/pi
Integrated from 0 to 15 degrees:
sin(15*pi/180)*180/pi - sin(0*pi/180)*180/pi = 14.8292
Looks like MATLAB got the correct answer to me.
The key is that derivatives and integrals of cosd (and sind etc.) have to account for the rad/deg factor.
I.e., d/dtheta sind(theta) ≠ cosd(theta)
Rather, d/dtheta sind(theta) = cosd(theta) * (pi/180)
To see why this must be so, plot up both cos(x) from 0 to pi/12 and cosd(x) from 0 to 15 on the same plot. Which one has the largest area underneath it? The cosd(x) plot, of course, since it has a lot more x length under it.

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by