Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Maple 8 | subs and matrices

17 views
Skip to first unread message

coo...@nospamverizon.net

unread,
Nov 5, 2004, 10:02:05 AM11/5/04
to
I think I asked something similar some time ago, but I've misplaced
the answer.

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]]

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);

Nothing happens.

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]]);

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).

So, is there a way to subs things into matrices that are NOT
explicitly created using the Matrix command? If not, then this is
(IMO) a real limitation to Maple.

Thanks in advance...

Joe Riel

unread,
Nov 5, 2004, 10:55:17 AM11/5/04
to
coo...@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

coo...@nospamverizon.net

unread,
Nov 5, 2004, 11:54:03 AM11/5/04
to
On Fri, 05 Nov 2004 15:55:17 GMT, Joe Riel <jo...@k-online.com> wrote:

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

OK - sounds like sage advice to start.

Thanks - I ended up discovering the VectorCalculus option just about
the same time you posted your reply.

And, as for the appropriate forum - good point. At one point, there
wasn't a Maple-specific list (or, if there was, my Unviersity news
server didn't have it available).


But, on the larger topic - I wonder if there is a 'rationale' reason
for Maple not being consistent throughout - I don't see an obvious
reason for subs to work for some things, but not others.

Carl Devore

unread,
Nov 5, 2004, 2:43:07 PM11/5/04
to
On Fri, 5 Nov 2004 coo...@NOSPAMverizon.net wrote:
> And, as for the appropriate forum - good point. At one point, there
> wasn't a Maple-specific list (or, if there was, my Unviersity news
> server didn't have it available).

I have on-and-off over the years had particular trouble accessing
comp.soft-sys.math.maple form my Uniersity's servers, and even when the
group is accessible, sometimes postings, even my own posings, take a week
or so to appear. I have had no such trouble with other groups. I wonder
how that happens. During those periods of trouble, I used Google to
access the group. There is always a several-hour delay with Google
(http://groups.google.com), but it is never, in my experience, a longer
delay than that. Google is also useful when you want searchable archives
or web-based access.

> But, on the larger topic - I wonder if there is a 'rationale' reason
> for Maple not being consistent throughout - I don't see an obvious
> reason for subs to work for some things, but not others.

The reason for this particular weirdness is explained on the page
?last_name_eval. However, please give MapleSoft credit where credit is
due: This inconsistency was corrected years ago by the LinearAlgebra
package. However, in order to support the running of user legacy code,
the old package with its idiosyncracies must remain. One supports
consistency by using the newer package.

0 new messages