Last active
July 27, 2020 20:27
-
-
Save justinmeiners/3358ed035dd46d9a97ce73d4e90d63ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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