I have to compute a polynomial like this --
f(x) = x^4 - 2.274x^3 + 1.8x^2 - 0.576x + 1.0
with this lisp function --
(defun polynomial (x)
(+ (+ (+ (+ (expt x 4) (* -2.274 * (expt x 3)))
(* 1.8 (* x x))) (* -0.576 x)) 0.1))
when I call (polynomial 0.5) the result is different at different evaluations, like this --
CL-USER> (polynomial 0.5)
-1.9495
CL-USER> (polynomial 0.5)
0.8786454
CL-USER> (polynomial 0.5)
0.07474504
CL-USER> (polynomial 0.5)
0.3032537
CL-USER> (polynomial 0.5)
0.23830011
CL-USER>
what is going on ? I am using the latest sbcl.
(* -2.274 * (expt x 3))
was my coding mistake and the REPL is assigning values to*
! now I understand why lisp is an alien technology. – Benne