Function: math-solve-cubic
math-solve-cubic is a byte-compiled function defined in
calcalg2.el.gz.
Signature
(math-solve-cubic VAR D C B A)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calcalg2.el.gz
(defun math-solve-cubic (var d c b a)
(let* ((p (math-div b a))
(q (math-div c a))
(r (math-div d a))
(psqr (math-sqr p))
(aa (math-sub q (math-div psqr 3)))
(bb (math-add r
(math-div (math-sub (math-mul 2 (math-mul psqr p))
(math-mul 9 (math-mul p q)))
27)))
m)
(if (Math-zerop aa)
(math-try-solve-for (math-pow (math-add var (math-div p 3)) 3)
(math-neg bb) nil t)
(if (Math-zerop bb)
(math-try-solve-for
(math-mul (math-add var (math-div p 3))
(math-add (math-sqr (math-add var (math-div p 3)))
aa))
0 nil t)
(setq m (math-mul 2 (list 'calcFunc-sqrt (math-div aa -3))))
(math-try-solve-for
var
(math-sub
(math-normalize
(math-mul
m
(list 'calcFunc-cos
(math-div
(math-sub (list 'calcFunc-arccos
(math-div (math-mul 3 bb)
(math-mul aa m)))
(math-mul 2
(math-mul
(math-add 1 (math-solve-get-int
1 3))
(math-half-circle
calc-symbolic-mode))))
3))))
(math-div p 3))
nil t)))))