-- hyperfun for quaternions -- Author: Frederic Delhoume -- command: hfp quaternion.hf -g 100 -b 1.8 -d 2 my_quaternion(x[3], a[1]) { -- replace these values to obtain new objects c1 = -1.0; c2 = -0.13; c3 = 0.0; c4 = 0.0; bailout = 4.0; maxiter = 8; lvalue = 0.0; -- start of program q1 = x[1]; q2 = x[2]; q3 = x[3]; q4 = lvalue; bailoutsq = bailout * bailout; i = 0; while (i < maxiter) loop temp = 2.0 * q1; q1 = q1^2 - q2^2 - q3^2 - q4^2 + c1; q2 = (temp * q2) + c2; q3 = (temp * q3) + c3; q4 = (temp * q4) + c4; length = q1^2 + q2^2 + q3^2 + q4^2; if (length > bailoutsq) then i = maxiter; endif; i = i + 1; endloop; my_quaternion = sqrt(length) - bailout; }