'' Some "Strange Attractor" math Per Bloland copied from a web page: (setf a1 1.0) ;;a bunch of coefficients, which i left alone for the assn (setf a2 .1) ;;if i follow my plan to write variations on this, (setf a3 -1.0);;i will play with these. (setf a4 .6) (setf a5 -.1) (setf a6 -.7) (setf a7 -.1) (setf a8 -.6) (setf a9 -.4) (setf a10 -.5) (setf a11 -.6) (setf a12 -.1) (defun quadraticx (x y) ;;1st half of the formulataken from mathworld.wolfram.com (+ a1 (* a2 x) (* a3 x x) (* a4 x y) (* a5 y) (* a6 y y))) (defun quadraticy (x y) (+ a7 (* a8 x) (* a9 x x) (* a10 x y) (* a11 y) (* a12 y y))) (defun run-quads (x y &key (times 20));;run those suckers! (loop repeat times collect (setf xtemp (quadraticx x y)) collect (setf y (quadraticy x y)) do (setf x xtemp) )) ;; A procedure to make random values for all the coefficients: (defun randomize-coefficients () (setf a1 (between -1.0 1.0)) (setf a2 (between -1.0 1.0)) (setf a3 (between -1.0 1.0)) (setf a4 (between -1.0 1.0)) (setf a5 (between -1.0 1.0)) (setf a6 (between -1.0 1.0)) (setf a7 (between -1.0 1.0)) (setf a8 (between -1.0 1.0)) (setf a9 (between -1.0 1.0)) (setf a10 (between -1.0 1.0)) (setf a11 (between -1.0 1.0)) (setf a12 (between -1.0 1.0))) ;; A procedure that randomizes the coefficients and tries to ;; get a list of 10 x, y values in the range [-2,2]. If a number ;; is out of range, it re-randomizes the coefficients and starts over. (defun safe-run (x y &key (times 20));;run those suckers! (let ((original-x x) (original-y y)) (randomize-coefficients) (let ((possible-result (loop repeat times for oldx = x for oldy = y with ok = T while ok collect (setf x (quadraticx oldx oldy)) collect (setf y (quadraticy oldx oldy)) do (print (list 'x x 'y y 'ok ok)) (if (or (> (abs x) 2) (> (abs y) 2)) (progn (print '(this is not OK!)) (setf ok nil) (print (list 'ok 'is 'now ok))))))) (if (= (* 2 times) (length possible-result)) possible-result (safe-run original-x original-y :times times)))))