?

Average Error: 52.7 → 1.5
Time: 16.6s
Precision: binary64
Cost: 54144

?

\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := {\left(c \cdot a\right)}^{4}\\ \mathsf{fma}\left(-0.5625, \left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right), \mathsf{fma}\left(-0.16666666666666666, \frac{t_0 \cdot 1.265625 + t_0 \cdot 5.0625}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right) \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (* c a) 4.0)))
   (fma
    -0.5625
    (* (* c c) (* c (/ (* a a) (pow b 5.0))))
    (fma
     -0.16666666666666666
     (/ (+ (* t_0 1.265625) (* t_0 5.0625)) (* a (pow b 7.0)))
     (fma -0.5 (/ c b) (/ (* -0.375 (* (* c c) a)) (pow b 3.0)))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
	double t_0 = pow((c * a), 4.0);
	return fma(-0.5625, ((c * c) * (c * ((a * a) / pow(b, 5.0)))), fma(-0.16666666666666666, (((t_0 * 1.265625) + (t_0 * 5.0625)) / (a * pow(b, 7.0))), fma(-0.5, (c / b), ((-0.375 * ((c * c) * a)) / pow(b, 3.0)))));
}
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function code(a, b, c)
	t_0 = Float64(c * a) ^ 4.0
	return fma(-0.5625, Float64(Float64(c * c) * Float64(c * Float64(Float64(a * a) / (b ^ 5.0)))), fma(-0.16666666666666666, Float64(Float64(Float64(t_0 * 1.265625) + Float64(t_0 * 5.0625)) / Float64(a * (b ^ 7.0))), fma(-0.5, Float64(c / b), Float64(Float64(-0.375 * Float64(Float64(c * c) * a)) / (b ^ 3.0)))))
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision]}, N[(-0.5625 * N[(N[(c * c), $MachinePrecision] * N[(c * N[(N[(a * a), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[(N[(N[(t$95$0 * 1.265625), $MachinePrecision] + N[(t$95$0 * 5.0625), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(N[(-0.375 * N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := {\left(c \cdot a\right)}^{4}\\
\mathsf{fma}\left(-0.5625, \left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right), \mathsf{fma}\left(-0.16666666666666666, \frac{t_0 \cdot 1.265625 + t_0 \cdot 5.0625}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right)
\end{array}

Error?

Derivation?

  1. Initial program 52.7

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Simplified52.7

    \[\leadsto \color{blue}{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}} \]
    Proof

    [Start]52.7

    \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

    remove-double-neg [<=]52.7

    \[ \frac{\left(-b\right) + \color{blue}{\left(-\left(-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right)}}{3 \cdot a} \]

    sub-neg [<=]52.7

    \[ \frac{\color{blue}{\left(-b\right) - \left(-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]

    div-sub [=>]52.9

    \[ \color{blue}{\frac{-b}{3 \cdot a} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}} \]

    neg-mul-1 [=>]52.9

    \[ \frac{\color{blue}{-1 \cdot b}}{3 \cdot a} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

    associate-*l/ [<=]52.6

    \[ \color{blue}{\frac{-1}{3 \cdot a} \cdot b} - \frac{-\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

    distribute-frac-neg [=>]52.6

    \[ \frac{-1}{3 \cdot a} \cdot b - \color{blue}{\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)} \]

    fma-neg [=>]51.8

    \[ \color{blue}{\mathsf{fma}\left(\frac{-1}{3 \cdot a}, b, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right)} \]

    /-rgt-identity [<=]51.8

    \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \color{blue}{\frac{b}{1}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right) \]

    metadata-eval [<=]51.8

    \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{b}{\color{blue}{\frac{-1}{-1}}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right) \]

    associate-/l* [<=]51.8

    \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \color{blue}{\frac{b \cdot -1}{-1}}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right) \]

    *-commutative [<=]51.8

    \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{\color{blue}{-1 \cdot b}}{-1}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right) \]

    neg-mul-1 [<=]51.8

    \[ \mathsf{fma}\left(\frac{-1}{3 \cdot a}, \frac{\color{blue}{-b}}{-1}, -\left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)\right) \]

    fma-neg [<=]52.6

    \[ \color{blue}{\frac{-1}{3 \cdot a} \cdot \frac{-b}{-1} - \left(-\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\right)} \]

    neg-mul-1 [=>]52.6

    \[ \frac{-1}{3 \cdot a} \cdot \frac{-b}{-1} - \color{blue}{-1 \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}} \]
  3. Taylor expanded in b around inf 1.5

    \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
  4. Simplified1.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right)} \]
    Proof

    [Start]1.5

    \[ -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]

    fma-def [=>]1.5

    \[ \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]

    associate-/l* [=>]1.5

    \[ \mathsf{fma}\left(-0.5625, \color{blue}{\frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]

    unpow2 [=>]1.5

    \[ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{\color{blue}{a \cdot a}}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]

    fma-def [=>]1.5

    \[ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \color{blue}{\mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}\right) \]
  5. Applied egg-rr1.8

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right)}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]
  6. Simplified1.5

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]
    Proof

    [Start]1.8

    \[ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]

    expm1-def [=>]1.5

    \[ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)\right)}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]

    expm1-log1p [=>]1.5

    \[ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]
  7. Applied egg-rr1.5

    \[\leadsto \mathsf{fma}\left(-0.5625, \color{blue}{\left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right)}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]
  8. Applied egg-rr1.5

    \[\leadsto \mathsf{fma}\left(-0.5625, \left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right), \mathsf{fma}\left(-0.16666666666666666, \frac{\color{blue}{{\left(c \cdot a\right)}^{4} \cdot 1.265625} + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\right) \]
  9. Final simplification1.5

    \[\leadsto \mathsf{fma}\left(-0.5625, \left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right), \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(c \cdot a\right)}^{4} \cdot 1.265625 + {\left(c \cdot a\right)}^{4} \cdot 5.0625}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right)\right) \]

Alternatives

Alternative 1
Error2.3
Cost33536
\[\mathsf{fma}\left(-0.5625, \frac{a \cdot a}{\frac{{b}^{5}}{{c}^{3}}}, \mathsf{fma}\left(-0.375, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, \frac{-0.5}{\frac{b}{c}}\right)\right) \]
Alternative 2
Error2.1
Cost33536
\[\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{-0.375 \cdot \left(\left(c \cdot c\right) \cdot a\right)}{{b}^{3}}\right)\right) \]
Alternative 3
Error2.3
Cost27520
\[\mathsf{fma}\left(\left(c \cdot c\right) \cdot \frac{a}{{b}^{3}}, 1.125, \frac{c}{b} \cdot 1.5\right) \cdot -0.3333333333333333 + -0.3333333333333333 \cdot \left(\left({c}^{3} \cdot {b}^{-5}\right) \cdot \left(\left(a \cdot a\right) \cdot 1.6875\right)\right) \]
Alternative 4
Error2.4
Cost27264
\[-0.3333333333333333 \cdot \mathsf{fma}\left({c}^{3}, {b}^{-5} \cdot \left(a \cdot \left(a \cdot 1.6875\right)\right), c \cdot \left(\frac{1.5}{b} + 1.125 \cdot \left(c \cdot \frac{a}{{b}^{3}}\right)\right)\right) \]
Alternative 5
Error5.6
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3} \leq -1 \cdot 10^{-5}:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 6
Error5.6
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3} \leq -2 \cdot 10^{-7}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 7
Error5.6
Cost14788
\[\begin{array}{l} t_0 := \frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 8
Error3.0
Cost13696
\[\mathsf{fma}\left(-0.375, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, -0.5 \cdot \frac{c}{b}\right) \]
Alternative 9
Error6.3
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 10
Error6.3
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 11
Error6.1
Cost320
\[\frac{c \cdot -0.5}{b} \]
Alternative 12
Error61.9
Cost192
\[\frac{0}{a} \]

Error

Reproduce?

herbie shell --seed 2023067 
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))