Jump to content

User:Spekkio: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 67:
x
(+ (* (/ (powint -1 n) (factorial (+ (* 2 n) 1)) ) (powint x (+ (* 2 n) 1))) (sine x (- n 1)))))
 
(defun sinetest(x n)
(if
(= (* (sine x (1+ n)) 1.0) (* (sine x n) 1.0))
(sine x n)
(sinetest x (1+ n))
)
)
 
(defun mysin (x) (sinetest x 1))
 
(defun cosi(x n) (if (= n 0) 1 (+ (* (/ (powint -1 n) (factorial (* 2 n)) ) (powint x (* 2 n))) (cosi x (- n 1)))))
Line 77 ⟶ 87:
(+ (/ (* (factorial (* 2 n)) (powint x (+ (* 2 n) 1))) (* (powint 4 n) (powint (factorial n) 2) (+ (* 2 n) 1))) (asine x (- n 1)))))
 
 
(defun asinetest(x n)
(if
(= (* (asine x (1+ n)) 1.0) (* (asine x n) 1.0))
(asine x n)
(asinetest x (1+ n))
)
)
 
(defun myasin (x) (asinetest x 1))
(defun fibcalc (n p)
(let ((sqrtFive (sqrtn 5 p)))
Line 88 ⟶ 108:
(+ (fibrec (- n 1)) (fibrec (- n 2))))))
</lang>
 
test:
[3]> (asin 1/10)
0.100167416
[3]> (* (myasin 1/10) 1.0)
0.10016742
 
Compare with Mathematica:
In: N[ArcSin[1/10], 8]
Out: 0.10016742
 
(myasin) seems to be more accurate, though trying to compute (myasin 1) is very slow.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.