![]() These points can be assumed to be 0 without loss of sin or cos natures. % count the points where the output is less than epsilon. ![]() We can count the number of points where abs(sin(k*pi)) 6*pi radians, the *_rad functions happen to show non-zero at the intended points due to further loss of precision of large multiple of pi. These files are very short sample codes for understanding. Those show correct results around pi/2 and pi points if we want to take 'pi' as the real 'pi'. Now we can provide 4 functions with abused pi definition: V*diag(exp_rad(diag(D)))/V % expm_rad(A) example The exp_rad also responses with matrix input: Pi is not a rational number, but the 180 degrees are rational number.Ĭonverting radians to degrees makes the exact result around pi. This would be a trick for handling 'pi' as if it is a real 'pi'. The function exp_rad slightly abuses the definition pi. The exp function is not easy to handle with degree.Įxp_rad = exp(real(theta)).*(cos_rad(imag(theta)) + i* sin_rad(imag(theta))) Or, we can define functions with radian input: When your application needs to use correct values around such angles. You had better use degrees rather than radians ![]() There is another way without using symbolic toolbox. One approach to go around it is to use symbolic toolbox: sin(sym(pi)) returns 0. It is because pi value cannot be represented in floating-point number. These unwanted results do not come from function evaluations. Trigonometric functions around pi may have errors close to machine precision. But it is only a floating-point number close to 'pi'.
0 Comments
Leave a Reply. |