|
From: Michel T. <ta...@lp...> - 2015-01-01 23:26:18
|
Dr. M Kanagasabapathy wrote:
> Dear Maxima members,
> I am a very newbie to Maxima. Actually I am shifting from mathematica.
> Really Maxima is rather intuitive. I have 'n' number of x, y data sets and
> i wish to fit in the form of (n-1) order polynomial equation. y =
> a*x^(n-1)+b*x^(n-2) ....and so on. I have tried these codes:
> load (lsquares) $
> p:matrix([x, y set Data 1], [x, y set Data 2], [x, y set Data 3]...)
> lsquares_estimates ( p, [x,y], a*x^(n-1)+b*x^(n-2) ..., [a, b,c,...]);
Since you have the same number of equations and unknowns, you should get
an exact solution, not an estimation as in least square methods. In fact
the solution is given by the classic interpolation formula, looking like
sum_i y_i*prod_j(x-x_j)/prod_j(x_i-x_j)
since the above gives obviously y_i for x=x_i.
Beware that numerically these things are very unstable.
> *Also please help me to get the code to load a set of numeric data from an
> Excel file into Maxima.*
I don't know if there are specific tools for that in maxima, but i would dump
the excel data to CSV (comma separated values), then use any editor to throw
these in a form that maxima likes (for example awk would easily do the job).
To discover the appropriate form you can look at this example:
lilas% maxima
(%i1) a:[1,2,3]$
(%i2) save("toto",a)$
(%i3) forget(a)$
(%i4) load("toto")$
(%i5) a;
(%o5) [1, 2, 3]
(%i6) ^D
lilas% cat toto
;;; -*- Mode: LISP; package:maxima; syntax:common-lisp; -*-
(in-package :maxima)
(DSKSETQ $A '((MLIST SIMP) 1 2 3))
(ADD2LNC '$A $VALUES)
Basically you can replace 1,2,3 here by the values you are extracting from the
excel file.
--
Michel Talon
|