# Determine if hessian is positive semi-definite

I have a log-likelihood function, and I am trying to determine if it is convex or concave to see if I can use standard optimization techniques. So I am trying to determine if the hessian is positive (or negative) semi-definite. This is what I have done:

from sage.symbolic.constants import Constant
var('E,a,k')
assume(k != 0)
assume(a > 0)
assume(E,'real')
Constant('x')
f(E,a,k) = -log(a - k * (x - E))
g(E,a,k) = -(log(1-k*(x-E)/a))^2/(2*k^2*s^2)
l(E,a,k) = f + g
solve(l.hessian() >= 0, [E,a,k])


However, I am getting this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-90-f091cf87ab45> in <module>()
----> 1 solve(l.hessian() >= Integer(0), [E,a,k])
2
3
4

/usr/lib64/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817     if not isinstance(f, (list, tuple)):
--> 818         raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820     if len(f)==1:

TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.


How can I fix this so I can get what I want? Is there a better way to do this?

edit retag close merge delete

What is s ?
Supposing that s is an aone can introduce with or without declaring constants h.hessian() which is a 3x3 matrix valued function with parameters. Now what do we want? That h.hessian() >= 0 is too much, we can split this inequation in parts using diagonal minors, but also in that case the hessian will be positive semi-definite even for fixed $x$ on a "complicated domain" (with boundary expected to be given by a transcendental equation). Please state in words what is needed / wanted. Please try to reduce the problem to a minimal one, for one fixed value of $x$. (Maybe even more, by fixing one of the three variables.)