-1

why in matlab sin(pi) and cos(pi/2) arent 0?! but the answer of sin(pi/2) and cos (0) are 1.

i try it and the answer arent zero. The mathematical reason for this is clear, but the reason for this happening in MATLAB is unknown to me, please explain it. why the answer arent zero.

  • 4
    What do you mean by "The mathematical reason for this is clear"? How much do you know about floating-point arithmetic? – Cris Luengo Aug 15 '23 at 17:15
  • 4
    Check out the `sinpi` and `cospi` functions if you actually need more precision numerical evaluation of such cases: https://www.mathworks.com/help/matlab/ref/double.sinpi.html# – horchler Aug 15 '23 at 17:18

0 Answers0