(p,q) = sosdecTernary(f)
Given a nonnegative ternary form $f$, this method uses Hilbert's algorithm to compute a decomposition of $f$ as $f=\frac{\prod_ip_i}{\prod_iq_i}$ where each factor $p_i$ and $q_i$ is a sum of squares. The method returns null if $f$ is not nonnegative. As an example, consider the homogeneous Motzkin polynomial.



The result, in this case, is a quotient of two sums of squares.


References: Products of positive forms, linear matrix inequalities, and Hilbert 17th problem for ternary forms, E. de Klerk, and D.V. Pasechnik, European J. Oper. Res. (2004), pp. 3945.
$\bullet$ This implementation only works with the solvers "CSDP" and "MOSEK".
$\bullet$ Due to the iterative nature of the algorithm, it could happen that some of the output sums of squares are rational while some are real.
The object sosdecTernary is a method function with options.