no time to compete with you guys... but I guess is that the tangent formula is wrong no?
if my lisp's spirits still are around, I recall that a tan formula can be like:
(setq *INFINITY* 1.7e308)
(defun TAN (z / cosz)
(if (zerop (setq cosz (cos z))) *INFINITY*
(/ (sin z) cosz)))
if not, please ignore me, I am use to that....