0
votes

I have the following matlab code which calucaltes the Hessian of a non linear function using the symbolic toolbox

clc;
syms x1 x2 x3;
f = 4*x1^4*x2^(5/3)*x3^(-5);
h(x1,x2,x3) = hessian(f)
h(1,1,1)
eig(h(1,1,1))

I am trying to find the Eigen values of the Hessian so that I can prove that it is not a positive semi definite matrix.

My issue is the way the output is formatted. I am getting all my calculations as fractions and not decimals? Can i change it anywhere to output decimals instead of fractions? Output http://pastebin.com/11HHnmRn

1

1 Answers

2
votes

Look e.g. at the result h(1,1,1):

ans =
    [   48,   80/3,    -80]
    [ 80/3,   40/9, -100/3]
    [  -80, -100/3,    120]

You can not simplify 80/3 any further without losing precision. This is why the MATLAB Symbolic Toolbox doesn't do anything further with it. The same happens e.g. with sqrt(2), which can't be simplified anymore either.

If you chose to discard this precision, in order get decimals, and be able to do further calculations with MATLAB, you can simply convert the expression to double precision:

double(h(1,1,1))

ans =
   48.0000   26.6667  -80.0000
   26.6667    4.4444  -33.3333
  -80.0000  -33.3333  120.0000