Re: Maple 8 | subs and matrices

From: Joe Riel (joer_at_k-online.com)
Date: 11/05/04


Date: Fri, 05 Nov 2004 15:55:17 GMT

cooch17@NOSPAMverizon.net writes:

> I'm using the linalg package in Maple, to do various calculations with
> one or more matrices. Suppose, for example, I have a matrix with
> symbolic structure
>
> [[a,b],[c,d]]

The linalg package is deprecated; you really should switch to the
LinearAlgebra package.

> What I want to be able to do is substitute in values for the variables
> a -> d, using the subs command. But, I don't seem to be able to figure
> out how one does this.
>
> If I try
>
> mat:=array([[a,b],[c,d]]);
> subs(a=0.5,b=0.2,c=1,d=0,mat);

Here are two ways to accomplish this

map2(subs,{a=0.5,b=0.2,c=1,d=0},mat);
subs(a=0.5,b=0.2,c=1,d=0, eval(mat));

> But, if I use
>
> mat:=Matrix([[a,b],[c,d]]);
> subs(a=0.5,b=0.2,c=1,d=0,mat);
>
>
> Things work fine. OK - there is a difference between array and Matrix.
> Fine - IF I explicitly define a matrix using Matrix. But, what if I
> don't, or can't? For example, suppose I derive a Jacobian matrix,
> using (say)
>
> jac:=jacobian(a,[n[1],n[2]]);

Try VectorCalculus:-Jacobian to work with Matrices. Okay, you're now
wondering (or should be 8-), "how am I supposed to figure that out?"
Well, I didn't know where it was, either. In fact, one of the reasons
I continued to use linalg for a while was precisely this; I needed to
compute jacobians and couldn't find an equivalent in the LinearAlgebra
package. The solution, at least in the Classic GUI, is to use the
Full Text Search in the Help menu. Or ask in appropriate forum;
comp.soft-sys.math.maple is better than sci.math.symbolic because
it is specific to maple.

> where a is the vector of functions, and n[1] and n[2] are the
> variables I want to differentiat the functions in a with respect to.
> Maple correctly gives me the Jacobian matrix, but I then want/need to
> be able to subs in the values of various parameters. Yes, I could subs
> them into the functions in a first, then differentiate, but this is
> not always practical, or desirable (for some purposes).

Joe Riel



Relevant Pages

  • Re: Exporting in two packages but one file
    ... I have a Package A with serveral subs in it and now I want to make a package A::Types with some constants in it. ... our @ISA = qw; ... use Exporter qw/import/; ...
    (perl.beginners)
  • Exporting in two packages but one file
    ... I have a Package A with serveral subs in it and now I want to make a package A::Types with some constants in it. ... our @ISA = qw; ...
    (perl.beginners)

Loading