fit nonlinear model to data - better way to code it?



On 05/18/2012 09:24 AM, Rupert Swarbrick wrote:
>
> Hmm, I was going to suggest that
>
>    ev(f(x), [p1,p2,p3] = ans[1])
>
> should work, but surprisingly it doesn't. For example:
>
>    (%i14) p1, [p1,p2,p3]=[3,4,5];
>    (%o14)                                p1
>
> Does anyone know if there is a reason for this? It seems at odds with
>
>    (%i15) [p1,p2,p3]: ans[1];
>    (%o15)   [- .2694298415835076, - .4248176441471781, 1.331747718996615]
>    (%i16) p1;
>    (%o16)                        - .2694298415835076
>
If I remember correctly, parallel substitution

[p1,p2,p3]: ans[1]

was added a few years ago by Robert, but function ev() has not been modified
to accept a similar syntax:

p1, [p1,p2,p3]=[3,4,5];

You still have to use the syntax:

   p1, [p1=3, p2=4, p=5];

and the same goes for subst:

   subst([p1=3, p2=4, p=5], p1);

rather than

   subst([p1,p2,p3]=[3,4,5],p1);

which is not implemented yet.

Regards,
Jaime