0

I'm very new to Wolfram-alpha. I'm trying to compute the Hessian Matrix of ||x|| where x is a vector. I tried this command HessianMatrix (norm[2][x]) in mathematica 13 where I use Wolframalpha input cell but nothing happens. Any idea ? I'm probably lacking some basic knowledge.

Tomer
  • 434
  • Input HessianMatrix (norm2) , expected outpit : some expression with A and x – Tomer Jan 08 '23 at 17:24
  • I don't need a numeric solution I want a symbolic solution – Tomer Jan 08 '23 at 19:41
  • HessianMatrix (norm2) is symbolic input, right ? x is a symbol for a vector. The expected output is some expression with the symbol x which I don't know but want it to be computed. – Tomer Jan 08 '23 at 19:54

1 Answers1

1

In WolframAlpha, you can get the Hessian determinant for a multivariable function $f(x_1,x_2,\ldots)$ with the syntax

Hessian matrix (or determinant) f(x1, x2, ...)

This usually also works if you have additional parameters, in which case one should specify which variables to use in the component derivatives, e.g.

Hessian matrix f(x1, x2, y) w.r.t. {x1, x2}

Both matrix and determinant are included in either flavor of input. For your use case, one would resort to

Hessian matrix norm({x, y, z})

enter image description here

As you can see, the output doesn't know how to handle derivatives of the built-in Abs function (absolute value). Sadly, there doesn't appear to be any means elaborating on the WA query and introducing extra conditions on the variables, such as fixing $(x,y,z)\in\Bbb R^3$. However, we can reduce Abs'[x] and Abs''[x] based on the sign of x so cleaning up the output isn't a difficult task.

Since you mentioned you were working in a notebook, you can carry out this cleanup with the following code:

D[Norm[{x, y, z}], {{x, y, z}, 2}]
(* Hessian matrix *)

Simplify[% /. Abs -> RealAbs, Element[{x, y, z}, Reals]] (* in the Hessian, replace Abs with RealAbs, then simplify assuming all arguments are real *)

Why RealAbs? Because Abs is blind to the domain of x, whereas RealAbs assumes a purely real argument. According to documentation, it's implemented as a Piecewise function; see what happens when you run

PiecewiseExpand[RealAbs[x]]
PiecewiseExpand[RealAbs'[x]]
PiecewiseExpand[RealAbs''[x]]

vs the same inputs with Abs.

I also assume norm[2] refers to the $2$-norm, which is implemented as Norm[f], but if you happened to mean something else, you may specify a different $p$-norm using the syntax Norm[f, p].

user170231
  • 19,334