400 Reputation

7 years, 271 days

caling the function...

@Carl Love Mnay thanks.   Can you explain the options you have added to the calling args of the function, specially the variable v?

many thanks....

@Carl Love Many thanks.  Nice explanation. Some of the syntax used is unknown to me.  Any tutorial, book and so on that might be useful to grasp the usage and meaning of them?  Again, thank you.

many thanks...

@John Fredsted Thank you ever so much for the solutions and I will stick with eval (no predilection for subs).   I found my mistake in all other examples: I have type r*x (1-x) instead of r*x*(1-x).

yes, but...

@John Fredsted Many thanks but that it is exactly what i am trying to avoid, that is, the function using l[1], l[2] and etc.  f will be used inside of a proc.

If instead of what you proposed I define  f:=(x,y,z) -> [y, y z - x, -15 x y - x z - x], (f@@4)  returns an error message.

It seems that f:=()->[] and f:=()-> (), unless defined as you did,  are not the answer.  Same goes for the solution using eval.   All of them work if the list has more than one element, that is, [x,y,z] but they don't work if the list is [x]. I hope I am wrong.

It seems that my only alternative is to use subs if I want to stick with list.

let me try...

@John Fredsted what I would like to achieve is f...f(f(f(f(x)))), where x is always a list.  Let me simplify the last example to hopefully clarify where I am facing the problem.

ee := [r*x(1-x)];
[r x(1 - x)]
eval(ee, [x]=~[x]);
[r x(1 - x)]
eval(ee, [x]=~eval(ee,[x]=~[x]));
[r r(1 - r x(1 - x)) x(1 - x)(1 - r x(1 - x))]

ff := x-> [r*x(1-x)];
x -> r x(1 - x)
ff(op([x]));
[r x(1 - x)]
ff(op([r*x(1-x)]));
[r r(1 - r x(1 - x)) x(1 - x)(1 - r x(1 - x))]
subs(x = x, [r*x(1-x)]);
[r x(1 - x)]
subs(x = op([r*x(1-x)]), r*x(1-x));
[r (r x(1 - x))(1 - r x(1 - x))]

subs gives what I need but I don't know why the other two commands give different results. What bothers me is if I do something similar using the orginal problem, the result is the same as in subs.

bb := [y, y*z-x, -15*x*y-x*z-x]:

eval(bb, [x, y, z]=~[x, y, z]);
[y, y z - x, -15 x y - x z - x]

eval(bb, [x, y, z]=~bb));
[y z - x, (y z - x) (-15 x y - x z - x) - y,-15 y (y z - x) - y (-15 x y - x z - x) - y]

subs([x = bb[1], y = bb[2], z = bb[3]], bb);
[y z - x, (y z - x) (-15 x y - x z - x) - y,-15 y (y z - x) - y (-15 x y - x z - x) - y]

I must be missing something.

something funny going on...

@emendes Please tell me what I am doing wrong.

G := createFunc([r*x(1-x)], [x]);

s1 := G(op([x]));

G(op([x+~T/2*~s1]));

The last command returns something different from r (1-x-1/2 r T (1-x) x) (x+1/2 r T (1-x) x) which is just to plug x+1/2 r T (1-x) x into the place of x in r*x(1-x).

createFunc...

@John Fredsted  Many thanks.  Nice function.  I completely forgot unapply.

symbol...

@Carl Love Yes, it is a symbol.  I want to include it as the third arg when calling test2. Is the use of args the right thing to do?  Or can I do something like proc(f,vars,samp) where samp is optional and f and vars are list.  If not given, samp will be T.  Many thanks.

test2...

@Kitonum Many thanks.  arg was a typo.   test2 is part of what I need.  Below is a modified version of test2 with f of f.

test2 := proc ()

local f, vars, res;

f := args[1];

vars := args[2];

res := eval(f, [x,y,z]=~vars);

res :=eval(f, [x,y,z]=~(vars+T*~res));

end proc

is that correct?  Is there a more concise way of doing f of f?   How can I add  simplify between the stages of f of f (4 times) ?

help...

@Carl Love Thanks.   The extra messages are data type, order and etc.   Although I no longer use Vector or vector, I wonder whether why Maple returns lot of stuff when issuing the command Vector[row]([x1*x2-u0,x1*x1+x2]) inside a proc.   Odd enough, when I restarted maple, the extra stuff did not show up.

As for the HelpTools, many thanks.  I will try searching the web to see if there is an example of building a package with help files from scratch.  Fortunately Maple 18 has the HelpTools.

and list works...

@emendes Thank you all for all the help and patience.   I managed to get rid of all vectors and Vectors and now the code is free from calling extra packages (inner is needed though but a solution is already given).

As a final question I wonder if you could give some pointers on how to write a help file for the procs.   Thank you!

if that is the case...

@Carl Love If that is the case, how can I avoid the extra messages that comes with Vector?   The extra messages wreck the old function.   linalg[vector] does not return such messages and therefore it works fine.

numelems...

@Carl Love Thank you. I have changed the code to use numelems.  I am not sure of anything since the code is 24 years old.  I don't even know if using vector is necessary.  Perhaps list will do the job.  The only thing I need is to calculate the dotproduct (and inner works with list) and the Lie derivative.  I am moving one step at the time and in doing so I hope I will remember how to use Maple.

LinearAlgebra[ColumnDimension](f)...

@emendes LinearAlgebra[ColumnDimension](f) does the trick since all the vectors are defined with Row.

sorry nops cannot be used...

@emendes  Sorry, I am mistaken, nops cannot be used in this case.

 First 16 17 18 19 Page 18 of 19
﻿