Why does this does not work for assigning a function:
F(t) := Matrix(matrixDE(A, t)[1])
While using a label to reference the output works:
Matrix(matrixDE(A, t)[1]) (1)
F1(t) := (1)
matrixDE(A, t)[1] (2)
F2(t) := Matrix((2))
It seems the indexing operation [1]
is what poses the problem, but I don't understand the mechanic behind this.
I found this question but it did not make me any wiser...
Edit:
I ended up getting my desired effect using eval
and :
F(x) := eval(Matrix(matrixDE(A, t)[1]), t = x)
The price to pay being that the argument of F
is named x
instead of t
.
The problem has nothing to with the indexing. The problem is exactly what you said in your title: You cannot (properly) assign a Maple function by directly using an (unevalauted) expression; rather, you must reference the output (or evaluation).
More specifically, it depends on the desired order of these two operations: evaluation of a parameterized expression and substitution of values for the parameter. If you want to first evaluate the expression with a symbolic parameter (your t in this case), then the command to use is unapply:
F:= unapply(Matrix(matrixDE(A, t)[1]), t);