|
|
|
@ -31,6 +31,27 @@
|
|
|
|
|
|
|
|
|
|
; Thiele's interpolation formula
|
|
|
|
|
; ==============================
|
|
|
|
|
;
|
|
|
|
|
; In the following example, we use Thiele's interpolation formula
|
|
|
|
|
; for computing the inverse cos function cos^(-1) from 32 points
|
|
|
|
|
; given by the cos function itself.
|
|
|
|
|
;
|
|
|
|
|
; We create two vectors:
|
|
|
|
|
; * the vector 'a' contains regularly spaced points in [0..1.55]
|
|
|
|
|
; * the vector 'b' contains cos(x) for each x in vector 'a'
|
|
|
|
|
;
|
|
|
|
|
; We set the keepfloat flag to true in order to prevent Maxima
|
|
|
|
|
; to replace the values with rational approximations.
|
|
|
|
|
;
|
|
|
|
|
; Then we compute the inverse function by using thiele(b,a);
|
|
|
|
|
; we evaluate this interpolation at 0.5 expecting some value
|
|
|
|
|
; close to pi/3.
|
|
|
|
|
;
|
|
|
|
|
; (%i1) a:makelist(0.05*i,i,0,31)$
|
|
|
|
|
; (%i2) b:makelist(float(cos(0.05*i)),i,0,31)$
|
|
|
|
|
; (%i3) keepfloat:true$
|
|
|
|
|
; (%i4) subst(x=0.5, thiele(b,a))*3;
|
|
|
|
|
; (%o4) 3.14159265357928
|
|
|
|
|
|
|
|
|
|
(defun $thiele (u v)
|
|
|
|
|
(loop for rh on
|
|
|
|
|