Skip to content

Instantly share code, notes, and snippets.

@justinmeiners
Last active July 27, 2020 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinmeiners/3358ed035dd46d9a97ce73d4e90d63ab to your computer and use it in GitHub Desktop.
Save justinmeiners/3358ed035dd46d9a97ce73d4e90d63ab to your computer and use it in GitHub Desktop.
; my own sin and cos functions using taylor seris
(defun eval-poly (coef x)
; horners method
(prog* ((i (- (length coef) 1))
(acc (aref coef i)))
accum
(decf i)
(if (< i 0) (return acc))
(setf acc (+ (aref coef i) (* x acc)))
(go accum)))
(defun my-cos (x)
(eval-poly
#(1 0 -1/2 0 1/24 0 -1/720)
(rem x (/ pi 2))))
(defun my-sin (x) (my-cos (- x (/ pi 2))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment