| 1 | initial version |
Sage (through Pynac and GiNaC) automatically evaluates sin(pi/6), cos(pi/6), tan(pi/6):
sage: sin(pi/6)
1/2
sage: cos(pi/6)
1/2*sqrt(3)
sage: tan(pi/6)
1/3*sqrt(3)
For the comparison, it checks if tan(pi/6) - sin(pi/6)/cos(pi/6) is 0:
sage: t = tan(pi/6) - sin(pi/6)/cos(pi/6)
sage: t
0
sage: t.is_trivial_zero()
True
For pi/5, tan() and sin() are left unevaluated, while cos() is:
sage: tan(pi/5)
tan(1/5*pi)
sage: sin(pi/5)
sin(1/5*pi)
sage: cos(pi/5)
1/4*sqrt(5) + 1/4
This makes the difference tan(pi/5) - sin(pi/5)/cos(pi/5) a symbolic expression not trivially equal to 0:
sage: t = tan(pi/5) - sin(pi/5)/cos(pi/5)
sage: t
-4*sin(1/5*pi)/(sqrt(5) + 1) + tan(1/5*pi)
sage: t.is_trivial_zero()
False
sage: t.n()
1.11022302462516e-16
Any patches to improve this behavior would be more than welcome.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.