Search code examples
maple

How take coordinates from Vector in maple


Is any way to get coordinates from Vector in maple? For example if I would like have function f(V) = sin(V[0]) + cos(V[1]) + V[2] Where V = (x,y,z). Is it possible in maple?


Solution

  • In Maple a Vector starts its indexing from 1 (not from 0). So the first entry is V[1], rather than V[0].

    Also, a Vector can be constructed with either the Vector command or its angle-bracket shortcut notation. Round brackets do not construct a Vector, as they are delimiters for either grouping or arguments of function application.

    restart:
    
    f := V -> sin(V[1]) + cos(V[2]) + V[3]:
    
    W := Vector([a,b,c]):
    
    f(W);
                             sin(a) + cos(b) + c
    
    Y := <3,7,11>:
    
    f(Y);
                            sin(3) + cos(7) + 11
    

    An Array is more flexible and can be constructed so as to start its indexing from 0.

    g := V -> sin(V[0]) + cos(V[1]) + V[2]:
    
    W := Array(0..2,[q,r,s]):
    
    g(W);
                             sin(q) + cos(r) + s
    

    Note that the LinearAlgebra package deals with Matrix and Vector. Also, some arithmetic operations (such as .) act in an elementwise manner for Array and not a way you might expect for doing computational linear algebra.

    restart:
    
    F := Array(1..3,[q,r,s]):
    
    F . F;
                                [ 2   2   2]
                                [q , r , s ]
    
    U := Vector[row]([q,r,s]):
    
    U . U;
                               _     _     _  
                               q q + r r + s s
    

    Note the complex conjugation occuring in the last example. And in contrast with Matrix structures, 2-dimensional Arrays are also multiplied elementwise under the . operator.