Interpolation function



El sáb, 10-12-2005 a las 10:12 +1300, Glenn Ramsey escribió:
> Hi,
> 
> Is there a function in Maxima that will allow me to use data points to 
> obtain values by linear (or otherwise) interpolation of the data?
> 
> Glenn
> 

There is a small program for Lagrangian interpolation. I plan to write
some other functions in the next future. Let me know if you have ideas
for new implementations.




Maxima 5.9.2.4cvs http://maxima.sourceforge.net
Using Lisp CLISP ()
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) load(interpol);
(%o1)    /usr/local/share/maxima/5.9.2.4cvs/share/numeric/interpol.mac
(%i2) /* empiric points */
      p:[[1,0],[2,1],[3,4],[4,9],[5,16],[6,25],[7,36]]$
(%i3) lagrange(p);
                                  2
(%o3)                            x  - 2 x + 1
(%i4) /* defining a function based on the polynomial */
      f(x):=''%;
                                      2
(%o4)                        f(x) := x  - 2 x + 1
(%i5) /* evaluating f in some other points */
      f(x),x=[2.3,5/7,%pi];
                                4      2
(%o5)                    [1.69, --, %pi  - 2 %pi + 1]
                                49
(%i6) /* now in decimal format */
      %,numer;
(%o6)            [1.69, .08163265306122448, 4.586419093909772]
(%i7) /* plot points together with the fitted curve */
     plot2d([f(x),[discrete,p]],[x,0,10],
     [gnuplot_curve_styles,["with lines","with points pointsize 3"]])$



Mario.



-- 
Mario Rodriguez Riotorto
www.biomates.net