Borrar filtros
Borrar filtros

Why the trigonometry results are different

5 visualizaciones (últimos 30 días)
Madhu
Madhu el 21 de Ag. de 2014
Respondida: Peter Perkins el 22 de Ag. de 2014
Why there is a difference in the results. in degrees it is showing inf and in radians a different result?
>> a=tan(90)
a =
-1.9952
>> b=tand(90)
b =
Inf
>> c=tan(pi/2)
c =
1.6331e+16

Respuesta aceptada

Peter Perkins
Peter Perkins el 22 de Ag. de 2014
1.6331e+16 is the right answer. Remember that pi/ is irrational. There is no way to represent it in double precision. The tangent of the double precision value pi/2 evaluates to is 1.6331e+16. That's the main reason for the existence of tand -- 90 is exact.

Más respuestas (3)

David Sanchez
David Sanchez el 21 de Ag. de 2014
The different result between tan(90) and tan(pi/2) is obvious.
1.6331e+16 might be considered equal to inf

Iain
Iain el 21 de Ag. de 2014
That's likely just the effect of small numerical errors.
After all, according to matlab,
1E300 + 1 - 1E300 = 0, and
1E300 - 1E300 + 1 = 1

Adam
Adam el 21 de Ag. de 2014
tan is asymptotic at 90 degrees, but pi/2 will not evaluate to the precise equivalent with a numerical estimate of pi so its result will not be precisely on the asymptote

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by