Created
July 7, 2015 08:22
-
-
Save yaraki/55dc19bb2a881358ba7c to your computer and use it in GitHub Desktop.
Simple sine calculation by taylor expansion
This file contains 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
(defconst if3 (* 2 3)) | |
(defconst if5 (* if3 4 5)) | |
(defconst if7 (* if5 6 7)) | |
(defconst if9 (* if7 8 9)) | |
(defconst if11 (* if9 10 11)) | |
(defun simple-sine (x) | |
(unless (eq 'float (type-of x)) | |
(setf x (float x))) | |
(let* ((x2 (* x x)) | |
(x3 (* x2 x)) | |
(x5 (* x3 x2)) | |
(x7 (* x5 x2)) | |
(x9 (* x7 x2)) | |
(x11 (* x9 x2))) | |
(+ x | |
(- (/ x3 if3)) | |
(/ x5 if5) | |
(- (/ x7 if7)) | |
(/ x9 if9) | |
(- (/ x11 if11))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment