Search code examples
matrixmaple

Maple: How to define new elements of a matrix?


In Maple, I have a matrix N and its elements N[i,j], If I modify the elements of this matrix as follows for example

>for j from 1 to 4 do
>print(F[i,j]=(diff(N[i,j],x)));
>od;od;

where the matrix elements are functions of x.

I've wanted to define new matrix elements

>BA[i,j]:=(diff(N[i,j],x)));

but I can't do this with Maple, through the above command. Can someone help me ?


Solution

  • Better than using a loop is simply BA:= diff~(N,x). The ~ can be appended to any operator to mean "apply the operator to each member of the container and return a new container containing the modified members."

    Also, be careful about using print. Its only purpose is to print stuff on the screen from the middle (not the end) of a computation. It can't be used to change any stored values. Good programs use print very sparingly, if at all. The end result of a computation is displayed automatically, without needing a print command.