Problem with lsquares



~~~~

At 10:21 AM 7/21/2007, Shaikh Surabuddin wrote:

>I am trying to run the examples listed in the Manual and I am having the following problem
>
>(%i1) load("mnewton")$
>(%i2) load("lsquares")$
>(%i3) lsquares(matrix([1.1,7.1],[2.1,13.1],[3.1,25.1],[4.1,49.1]), [x,y], y=a*b^x+c, [a,b,c], [5,5,5]);
>quotient is not exact

Shaikh,

I dont know anything about the particulates of mnewton and lsquares, 
but solving solving this lsq by hand we get:

(%i1) declare(sum,linear)$
(%i2) warnings:false$
(%i4) er: y[j]-(c1*c2^x[j]+c3)$  /* the model equation for the data set */ 
(%i5) s1:sum((er^2),j,1,n)$      /* the square error */
(%i6) s2:[diff(expand(s1),c1),diff(expand(s1),c2),diff(expand(s1),c3)]% /* the equation system */
(%i7) s3:[c1,c2,c3]$             /* the model adjustable parameters */
(%i8) x:[1.1,2.1,3.1,4.1]$       /* the data */
(%i9) y:[7.1,13.1,25.1,49.1]$    /* the data */
(%i10) n1:length(x)$
(%i11) s2n:ev(s2,n:n1,sum);      /* evaluate the system for the data */

(%o11) [2*(c2^4.1+c2^3.1+c2^2.1+c2^1.1)*c3+2*c1*(c2^8.199999999999999+c2^6.2+c2^4.2+c2^2.2)-2*
(49.1*c2^4.1+25.1*c2^3.1+13.1*c2^2.1+7.1*c2^1.1),2*c1*(4.1*c2^3.1+3.1*c2^2.1+2.1*c2^1.1+1.1*
c2^0.1)*c3+2*c1^2*(4.1*c2^7.199999999999999+3.1*c2^5.2+2.1*c2^3.2+1.1*c2^1.2)-2*c1* 
(201.31*c2^3.1+77.81*c2^2.1+27.51*c2^1.1+7.810000000000001*c2^0.1),
8*c3+2*c1*(c2^4.1+c2^3.1+c2^2.1+c2^1.1)-188.8]

we try 

(%i16) mnewton(expand(s2n),s3,[5,5,5]);
quotient is not exact
 -- an error.  To debug this try debugmode(true);

Conclusion: lsquares did its job ok, but mnewton seems unable to solve this system.


Ed

~~~