About Multi-Variate Functions in EMT

You define a vector valued function of two variables in EMT as follows.

>function f([x,y]) := [x^2+y^2-10,x*y-1]
 [0.317837,  3.14626]

Then f can be used in the form f(x,y) or f(v) with a 1×2 vector v. The Broyden algorithm needs the second form. This can also be done for a symbolic function.

>function f([x,y]) &= [x^2+y^2-10,x*y-1]
                            2    2
                          [y  + x  - 10, x y - 1]
>function Df([x,y]) &= jacobian(f(x,y),[x,y])
                                [ 2 x  2 y ]
                                [          ]
                                [  y    x  ]
   [0.317837,  3.14626]

The function f can now work numerically just as above. As a symbolic function, it is defined in Maxima too. There, it can only be used as f(x,y). Likewise for the derivative of f defined in Df. The Newton algorithm needs this derivative matrix to do its job.

Note, that the Broyden and the Newton algorithms work for row and for column vectors alike. It depends on the start vector. E.g., if you start with a row vector, the algorithms expect the functions to return row vectors.

You can also use the following trick.

>function f(v) &= [v[1]^2+v[2]^2-10,v[1]*v[2]-1]
                         2    2
                       [v  + v  - 10, v  v  - 1]
                         2    1        1  2
>function Df(v) &= jacobian(f(v),[v[1],v[2]])
                             [ 2 v   2 v  ]
                             [    1     2 ]
                             [            ]
                             [  v     v   ]
                             [   2     1  ]
 [0.317837,  3.14626]

The first definition is a valid definition of a numerical function. But for Maxima, the symbolic function can also be defined this way. Maxima interprets v[1] as a variable, as you see in the definition of Df. Of course, you can no longer write f(x,y).

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.