PatrickT

Dr. Patrick T

2163 Reputation

18 Badges

16 years, 340 days

MaplePrimes Activity


These are replies submitted by PatrickT

Thanks a lot Preben,

I had actually tried to use the tilde, but I was doing this:


mtaylor~(F(X),[X[1],X[2],X[3]],3);

instead of:

mtaylor~(F(X),[[X[1],X[2],X[3]]$3],3);

I am guessing that the dollar serves the purpose you describe "you need a list of lists as the second argument."

This will be a useful trick to keep in mind, thanks.

However, if I try to make that expression into a function that could take vectors of any size, the $3 is a problem, because it will work only for size-3 Vectors. So I need to manually change it every time to accommodate Vectors of different sizes.

I will post shortly about the workaround I found.


Patrick.


Thanks a lot Preben,

I had actually tried to use the tilde, but I was doing this:


mtaylor~(F(X),[X[1],X[2],X[3]],3);

instead of:

mtaylor~(F(X),[[X[1],X[2],X[3]]$3],3);

I am guessing that the dollar serves the purpose you describe "you need a list of lists as the second argument."

This will be a useful trick to keep in mind, thanks.

However, if I try to make that expression into a function that could take vectors of any size, the $3 is a problem, because it will work only for size-3 Vectors. So I need to manually change it every time to accommodate Vectors of different sizes.

I will post shortly about the workaround I found.


Patrick.


@Dave L 

 

Thanks Dave, I now realize that floats are an altogether different ball game. Your explanations clarify the issues for me. I was careless with my comparisons.

many thanks,

Patrick.

P.S.

KPKP does not work here at all. I have Maple 14 on Windows 7 and 64 bits. Not sure what's wrong.

A := Matrix([[1,2,3],[4,5,6]]):
B := Matrix([[1,2,3],[4,5,6],[7,8,9],[10,11,12]]):
  KPKP(A,B)    ;
Error, (in KPKP) Matrix index out of range

@acer 

I'm very sorry, I didn't realize the issues raised by floats.

The KPKP proc gives me:

Error, (in KPKP) Matrix index out of range

KP appears to be much slower than LinearAlgebra:-KroneckerProduct on the float matrices. Am I doing something wrong?

> You could also use kernelopts(bytesalloc) to compute a memory difference, ie an allocation increase incurred for each operation.

Oh yes, I'll look into that, that would seem to be very useful indeed. I noticed that the run times often differred for apparently random reasons (not just because of the random terms in the Matrices but also for very simple operations).

Thanks acer.

acer and advocatus diaboli, you both make some very sound points.

I should have fooled around longer before posting this foolish "ranking."

Another quick test one can perform is the following, rather than running the proc 1,000 times, I ran it on large Matrices, perhaps a more common need, based on DJ Keenan's suggestion, e.g.

A:= Matrix(10, 25, [seq(1e-10*rand(), i=1..10*25)]):
B:= Matrix(99, 99, [seq(1e-10*rand(), i=1..99*99)]):
t := time():
#  LinearAlgebra:-KroneckerProduct(A,B):
  myKroneckerProduct(A,B);
time() - t;

The results are then very different.

First, the native LinearAlgebra:-KroneckerProduct comes on top. Again. Nice.

Secondly, many procs exhaust the memory available (this may be because my system is not optimized to make full use of my processors and/or RAM or something like that). Only the native LinearAlgebra:-KroneckerProduct could compute this (in the restricted sense of not returning an error message):

A:= Matrix(100, 25, [seq(1e-10*rand(), i=1..100*25)]):
B:= Matrix(199, 199, [seq(1e-10*rand(), i=1..199*199)]):
t := time():
  LinearAlgebra:-KroneckerProduct(A,B)    :
time() - t;

Thirdly, the ranking is completely different. Jon Fredsted's and DJ Keenan's first proc (v.1.b by my numbering system) do very well this time. But they do take slightly over 2 seconds. The native LinearAlgebra proc is consistently under 1 second with this type of Matrix.

DISCLAIMER: Again, this is not a scientific study. I'm not doing this to compare different users' ability or anything like that. My understanding was that the procs were written in the spirit of sharing ideas and experimenting, not at all as a competition. My understanding of the original exchange and of this one is that it might foster Maple learning by ignoramuses like myself.

No worries, above all, thanks for your interest pagan. All this is accurately documented, by the way, I just wonder why the limitations. Hessian is even less versatile as it can only take algebraic expressions. With LISTS as arguments, what works with VectorCalculus[Jacobian] doesn't work with VectorCalculus[Hessian]. Is there a good reason, some fool-proof restriction?

VectorCalculus[Hessian](Flst,Xlst);
Error, invalid input: VectorCalculus:-Hessian expects its 1st argument, f, to be of type algebraic, but received [x[1]*x[2], 3*x[3]]

Edit: To be perfectly honest, I haven't looked into it and there may be a special package to deal with tensors.

 

 

 

No worries, above all, thanks for your interest pagan. All this is accurately documented, by the way, I just wonder why the limitations. Hessian is even less versatile as it can only take algebraic expressions. With LISTS as arguments, what works with VectorCalculus[Jacobian] doesn't work with VectorCalculus[Hessian]. Is there a good reason, some fool-proof restriction?

VectorCalculus[Hessian](Flst,Xlst);
Error, invalid input: VectorCalculus:-Hessian expects its 1st argument, f, to be of type algebraic, but received [x[1]*x[2], 3*x[3]]

Edit: To be perfectly honest, I haven't looked into it and there may be a special package to deal with tensors.

 

 

 

An improved presentation:

#List,List
VectorCalculus[Jacobian]([x[1]*x[2],3*x[3]],[x[1],x[2]]);
                    Matrix(%id = 153334860)
#Vector,List
VectorCalculus[Jacobian](Vector([x[1]*x[2],3*x[3]]),[x[1],x[2]]);
                    Matrix(%id = 153334988)
#List,Vector
VectorCalculus[Jacobian]([x[1]*x[2],3*x[3]],Vector([x[1],x[2]]));
Error, invalid input: too many and/or wrong type of arguments passed to VectorCalculus:-Jacobian; first unused argument is Vector(2, {(1) = x[1], (2) = x[2]})
#Vector,Vector
VectorCalculus[Jacobian](Vector([x[1]*x[2],3*x[3]]),Vector([x[1],x[2]]));
Error, invalid input: too many and/or wrong type of arguments passed to VectorCalculus:-Jacobian; first unused argument is Vector(2, {(1) = x[1], (2) = x[2]})

where it has Matrix(%id=... it worked, where it has an Error message it didn't.

An improved presentation:

#List,List
VectorCalculus[Jacobian]([x[1]*x[2],3*x[3]],[x[1],x[2]]);
                    Matrix(%id = 153334860)
#Vector,List
VectorCalculus[Jacobian](Vector([x[1]*x[2],3*x[3]]),[x[1],x[2]]);
                    Matrix(%id = 153334988)
#List,Vector
VectorCalculus[Jacobian]([x[1]*x[2],3*x[3]],Vector([x[1],x[2]]));
Error, invalid input: too many and/or wrong type of arguments passed to VectorCalculus:-Jacobian; first unused argument is Vector(2, {(1) = x[1], (2) = x[2]})
#Vector,Vector
VectorCalculus[Jacobian](Vector([x[1]*x[2],3*x[3]]),Vector([x[1],x[2]]));
Error, invalid input: too many and/or wrong type of arguments passed to VectorCalculus:-Jacobian; first unused argument is Vector(2, {(1) = x[1], (2) = x[2]})

where it has Matrix(%id=... it worked, where it has an Error message it didn't.

Reference to Robert's suggestion and context:

http://www.math.rwth-aachen.de/mapleAnswers/html/1603.html

> MyJacobian:= (F::list, V::list) ->
Matrix([seq([seq(diff(f,v),v=V)], f=F)]);

Reference to Robert's suggestion and context:

http://www.math.rwth-aachen.de/mapleAnswers/html/1603.html

> MyJacobian:= (F::list, V::list) ->
Matrix([seq([seq(diff(f,v),v=V)], f=F)]);

I noticed that if you click on "student" then all the things tagged as "student" are listed. It's a good idea. But why isn't there a "student" tag you can click on right next to the "submit" button? what if you type sutdent or something instead? (I haven't tried, I suppose I could) does it mean your post or question or whatever is misled forever? or if you don't type anything at all? I too couldn't find anything about this in a "sticky" but perhaps I looked in the wrong place. A sticky would be useful. Anything really at this stage would be useful. I don't even see any tags I could tag my comment with at this time. True, I haven't tried very hard, but I don't much understand the new mapleprimes organization... what's the difference between a "post" and a "question"? is a "comment" a "post" or not quite? what if I want to post questions and comments at the same time? is there a rule against asking question inside a "comment"? (which is what I'm currently doing, hope it's okay this time!)

thanks that's useful, I'd been wondering how to get rid of having the maple input bold by default. In the process of unticking "bold" it turns out that the text coloring disappeared, so that the Maple input is now black. Well, you know what? that ain't bad at all!

thanks that's useful, I'd been wondering how to get rid of having the maple input bold by default. In the process of unticking "bold" it turns out that the text coloring disappeared, so that the Maple input is now black. Well, you know what? that ain't bad at all!

It could be useful, e.g. a link near the post that would toggle the list.

First 55 56 57 58 59 60 61 Last Page 57 of 93