Re: help with numeric speed optimization
- From: verec <verec@xxxxxxx>
- Date: Sat, 19 Aug 2006 16:24:22 +0100
Thanks to all for your replies. It helped win the case: we're
using Lisp for the project! Yeap! BTW: the math guy apologized:
the reason that the initial pi/2 wasn't very accurate (15% off
or so) is that the formula he gave me was for (sqrt pi), not
(/ pi 2) ...
CL-USER 11 > (defun pi/2-opt4 () ;;; formula for (sqrt pi) not for (/ pi 2) !!
(declare (optimize (speed 3) (safety 0) (debug 0) (float 0)))
(loop with sum of-type double-float = #.(realpart (+ (exp (- (expt -10.0d0 2.0d0)))
(exp (- (expt 10.0d0 2.0d0)))))
for x of-type double-float from -9.99d0 below 10.0d0 by 0.01d0
do (incf sum (* 2d0 (exp (- (realpart (expt x 2.0d0))))))
finally (return (* sum 0.005d0))))
CL-USER 12 > (pi/2-opt4)
1.7724538509055174D0
CL-USER 13 > (sqrt pi)
1.7724538509055159D0
CL-USER 14 > (/ pi 2)
1.5707963267948966D0
Many thanks again.
--
JFB
.
- References:
- help with numeric speed optimization
- From: verec
- help with numeric speed optimization
- Prev by Date: Re: The Weakness of Lisp
- Next by Date: Re: Erlang brings up interesting questions about Lisp
- Previous by thread: Re: help with numeric speed optimization
- Next by thread: Re: elisp: format-time-string's %z problem
- Index(es):
Relevant Pages
|