Creating a function?



>>>>> "Barton" == Barton Willis <willisb at unk.edu> writes:

    Barton> maxima-bounces at math.utexas.edu wrote on 03/30/2011
    Barton> 09:03:22 AM:
    >> In Michel's example, the boundary conditions are expressed as
    >> the vector function
    >>
    >> g(z) := [z[2] - 2.0d0*z[1]*(v-z[3]-z[4]), z[2] -
    >> 2.0d0*z[1]*z[3], z[1] - 1.0d0, z[2] - 2.0d0*z[1]*z[4]];
    >>

    Barton> It's tempting to use z[1], z[2], ... as subscripted
    Barton> variables, but doing this will cause bugs. Example: What
    Barton> if a user does the perfectly reasonable:

[snip other issues]

    >> The function we want is then
    >>
    >> dg:jacobian(g(z), [z[1],z[2],z[3],z[4]]); dgsub(i, z) :=
    >> row(dg, i)[1];

Yeah, these are all good issues that need to be dealt with.  This was
done this way because that's how the original Fortran code is
arranged and matching it made it much easier to verify that the
interface worked.  It shouldn't be hard to expect a zk instead of
z[k].

    Barton> The free variable (z) in dgsub looks like a bug waiting to
    Barton> happen. Should dgsub have another argument? But I'm not
    Barton> sure what dgsub is suppose to do.

dgsub(i, z) is supposed compute the i'th row of the Jabobian of the
boundary conditions vector g(z) (or g(z1,z2,z3,z4) in your new world).
The Fortran code expects a function dgsub to compute this.  Of course,
in maxima interface, we could just ask the user to supply g(z) and
have maxima compute the jacobian, although that's not so good if g(z)
is a piecewise function.  The interface could just supply the Jacobian
itself and have an internal function dgsub that extracts the
appropriate row.

Actually, I think this is a nicer interface.

    Barton> Sorry to be so negative, nonhelpful, and grumpy.

I will think about changing the colnew interface to take into account
your comments, once Michel (mostly) and I have a new version that
supports the continuation feature of colnew.

Ray