These functions implement the expression, which can calculate scalar quantities when given x1 and x2 components of a 2-element vector.

\[ f(\mathbf x) = \mathbf x^T \mathbf A \mathbf x \]

In this case, I take the matrix A to positive definite or negative definite. Then, I pass the same vectors into the function to see the behavior of positive or negative definite matrices.

functionneg_definite(x1::Float64, x2::Float64) A = [-1.00.0; 0.0-2.0] x = [x1; x2] x'* A * xend

neg_definite (generic function with 1 method)

Surface plots

Positive definite plot

xs =-5:0.1:5ys =-5:0.1:5zs = [pos_definite(x, y) for x in xs, y in ys]display(surface(xs, ys, zs, title="Positive Definite Matrix Transform", xlabel="x", ylabel="y", zlabel="z", cmap=:cool))

Negative definite plot

xs =-5:0.1:5ys =-5:0.1:5zs = [neg_definite(x, y) for x in xs, y in ys]display(surface(xs, ys, zs, title="Negative Definite Matrix Transform", xlabel="x", ylabel="y", zlabel="z", cmap=:cool))