Series approximation to SIN/COS.
This function is used to calculate the following Maclaurin series. To compute SIN:
To compute COS:
Arguments:
Function:
(defun compute-series (x parity ex fact num itr ans) (declare (xargs :guard (and (rationalp x) (booleanp parity) (rationalp ex) (integerp fact) (> fact 0) (integerp num) (>= num 0) (integerp itr) (>= itr 0) (rationalp ans)))) (if (zp itr) ans (compute-series x (not parity) (* x x ex) (* (+ 2 num) (+ 1 num) fact) (+ 2 num) (1- itr) (if parity (+ ans (/ ex fact)) (- ans (/ ex fact))))))