Question: How to substitute a function

The following example tries to do the same thing two different ways.

Calling a procedure "M1" directly by name works fine.

Calling the same procedure by substitution fails to substitute, and when the substrituion is forced using "apply" I get an error message.

Why does the substitution not work, and where is the error?

Because of the complexity of my problem, I need to use substitute (or anything else equivalent) instead of directly calling the procedure by name.

Thank you.

> restart;
> M1:= proc(X1,X2,z);
> f(X1,X2,z); end proc;

             M1 := proc(X1, X2, z) f(X1, X2, z) end proc

> X1:=[X,Y,Z,W];
> X2:=[P,Q,R];
> try1:=(M1(X1,X2,1));
> try2:=subs(G=M1,G(X1,X2,1));
> apply(M1,try2);
>

                          X1 := [X, Y, Z, W]


                           X2 := [P, Q, R]


                try1 := f([X, Y, Z, W], [P, Q, R], 1)


                try2 := M1([X, Y, Z, W], [P, Q, R], 1)

Error, (in apply) invalid input: M1 uses a 2nd argument, X2, which is missing

>

Please Wait...