4.3 Vector Differentiation

4.3.1 DirectionalD[expr, aVariable, h]

Aliases: DirD
Description: Takes the Directional Derivative of expression expr with respect to the variable aV ariable in direction h.
Arguments: expr is an expression containing var. aV ariable is a variable. h is the direction which the derivative is taken in.
Comments / Limitations: None.

4.3.2 Grad[expr, aVariable]

Aliases: Grad, NEVER USE Gradient
Description: Grad[expr,aV ariable] takes the gradient of expression expr with respect to the variable aV ariable. Quite useful for computations with quadratic Hamiltonians in H control. BEWARE Gradient calls the Mma gradient and makes a mess.
Arguments: expr is an expression containing var. aV ariable is a variable.
Comments / Limitations: This only works reliably for quadratic expressions. It is not even correct on all of these. For example, Grad[a **x + a **tp[x],x] returns 2tp[a]. The reason is fundamental mathematics, not programming. If a is a row vector and x is a column vector, then a **x is a number, but a **tp[x] is not.

4.3.3 CriticalPoint[expr, aVariable]

Aliases: Crit, Cri
Description: It finds the value of aV ariable which makes the gradient of the expression expr with respect to the variable aV ariable equal to 0.
Arguments: expr is an expression containing aV ariable. aV ariable is a variable.
Comments / Limitations: Uses the Grad and NCSolve functions. Both Grad and NCSolve are severely limited. Therefore, the CriticalPoint command has a very limited range of applications.

4.3.4 NCHessian[afunction, {X1,H1},,{Xk,Hk} ]

Aliases: None.
Description: NCHessian[afunction,{X1,H1},{X2,H2},,{Xk,Hk} ]
computes the Hessian of a afunction of noncommutting variables and coefficients. The Hessian recall is the second derivative. Here we are computing the noncommutative directional derivative of a noncommutative function. Using repeated calls to DirectionalD, the Hessian of afunction is computed with respect to the variables X1,X2,,Xk and the search directions H1 , H2 , , Hk. The Hessian HΓ of a function Γ is defined by
                2            ∣
H Γ (⃗X)[H⃗] :=  d--Γ (⃗X + t⃗H) ∣
               dt2           t=0
One can easily show that the second derivative of a hereditary symmetric noncommutative rational function Γ with respect to one variable X has the form
                  [k                ]
                    ∑       T
H Γ (X)[H]  =  sym      A ℓH  B ℓHC  ℓ  ,
                    ℓ=1
where A, B, and C are functions of X determined by Γ. (An analogous expression holds for more variables.) The Hessian will always be quadratic with respect to ⃗H. (A noncommutative polynomial in variables H1, H2, , Hk, is said to be quadratic if each monomial in the polynomial expression is of order two in the variables H1, H2, , Hk.)
Arguments: afunction is a function of the variables X1,X2,,Xk. The Hessian will be computed with respect to the search directions H1 , H2 , , Hk.
For example, suppose F(x,y) = x + x **y + y **x. Then,
NCHessian[F,{x,h},{y,k}] gives 2h**k + 2k **h As another example, if G(x,y,z) = inv[y] + z **x, then NCHessian[G,{x,h},{y,k},{z,i}] gives 2i **h + 2inv[y] **k * *inv[y] **k **inv[y].
The results of NCHessian can be factored into the form vtMv by calling NCMatrixofQuadratic. (see NCMatrixofQuadratic).
Comments / Limitations: None.