?

Average Accuracy: 55.7% → 97.9%
Time: 29.8s
Precision: binary64
Cost: 46720

?

\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := \sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}}\\ \frac{\frac{\frac{-3 \cdot \left(c \cdot a\right)}{t_0}}{{t_0}^{2}}}{a \cdot 3} \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 (cbrt (+ b (sqrt (fma b b (* c (* -3.0 a))))))))
   (/ (/ (/ (* -3.0 (* c a)) t_0) (pow t_0 2.0)) (* a 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 = cbrt((b + sqrt(fma(b, b, (c * (-3.0 * a))))));
	return (((-3.0 * (c * a)) / t_0) / pow(t_0, 2.0)) / (a * 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 = cbrt(Float64(b + sqrt(fma(b, b, Float64(c * Float64(-3.0 * a))))))
	return Float64(Float64(Float64(Float64(-3.0 * Float64(c * a)) / t_0) / (t_0 ^ 2.0)) / Float64(a * 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[(b + N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[(N[(N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $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 := \sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}}\\
\frac{\frac{\frac{-3 \cdot \left(c \cdot a\right)}{t_0}}{{t_0}^{2}}}{a \cdot 3}
\end{array}

Error?

Derivation?

  1. Initial program 55.7%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Applied egg-rr56.8%

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

    [Start]55.7

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

    +-commutative [=>]55.7

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

    flip-+ [=>]55.7

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

    add-sqr-sqrt [=>]0.0

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

    sqrt-unprod [=>]1.3

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

    sqr-neg [=>]1.3

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

    sqrt-prod [=>]1.6

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

    add-sqr-sqrt [<=]1.3

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

    unsub-neg [<=]1.3

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

    +-commutative [<=]1.3

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

    add-cube-cbrt [=>]1.3

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

    *-commutative [=>]1.3

    \[ \frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\color{blue}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left(\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}}}{3 \cdot a} \]
  3. Taylor expanded in b around 0 97.9%

    \[\leadsto \frac{\frac{\frac{\color{blue}{-3 \cdot \left(c \cdot a\right)}}{\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}}{{\left(\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}\right)}^{2}}}{3 \cdot a} \]
  4. Final simplification97.9%

    \[\leadsto \frac{\frac{\frac{-3 \cdot \left(c \cdot a\right)}{\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}}}}{{\left(\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}}\right)}^{2}}}{a \cdot 3} \]

Alternatives

Alternative 1
Accuracy90.4%
Cost41540
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \frac{a}{\frac{b \cdot b - t_0}{b + \sqrt{t_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c}{{b}^{3}} \cdot \left(a \cdot a\right), -0.5 \cdot \frac{a}{b} + \frac{{a}^{3}}{{b}^{5}} \cdot \left(0.2222222222222222 \cdot \left(\frac{{c}^{4}}{c} \cdot \frac{-6.328125}{c}\right) + \left(c \cdot c\right) \cdot 0.84375\right)\right)\right)}\\ \end{array} \]
Alternative 2
Accuracy85.3%
Cost21188
\[\begin{array}{l} t_0 := c \cdot \left(-3 \cdot a\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 3} \leq -0.00225:\\ \;\;\;\;\frac{b - \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}{-3} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(-0.5, \frac{a}{b}, \frac{b \cdot 0.6666666666666666}{c}\right)}\\ \end{array} \]
Alternative 3
Accuracy88.9%
Cost21188
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \frac{a}{\frac{b \cdot b - t_0}{b + \sqrt{t_0}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c \cdot \left(a \cdot a\right)}{{b}^{3}}, -0.5 \cdot \frac{a}{b}\right)\right)}\\ \end{array} \]
Alternative 4
Accuracy85.3%
Cost21060
\[\begin{array}{l} t_0 := c \cdot \left(-3 \cdot a\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b + t_0} - b}{a \cdot 3} \leq -0.00225:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, t_0\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(-0.5, \frac{a}{b}, \frac{b \cdot 0.6666666666666666}{c}\right)}\\ \end{array} \]
Alternative 5
Accuracy85.3%
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b + c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3} \leq -0.00225:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(-0.5, \frac{a}{b}, \frac{b \cdot 0.6666666666666666}{c}\right)}\\ \end{array} \]
Alternative 6
Accuracy88.9%
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{b \cdot b - t_0}{b + \sqrt{t_0}} \cdot \frac{-0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c \cdot \left(a \cdot a\right)}{{b}^{3}}, -0.5 \cdot \frac{a}{b}\right)\right)}\\ \end{array} \]
Alternative 7
Accuracy88.9%
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 27:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{\frac{b \cdot b - t_0}{b + \sqrt{t_0}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c \cdot \left(a \cdot a\right)}{{b}^{3}}, -0.5 \cdot \frac{a}{b}\right)\right)}\\ \end{array} \]
Alternative 8
Accuracy88.9%
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{b \cdot b - t_0}{\frac{b + \sqrt{t_0}}{\frac{-0.3333333333333333}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c \cdot \left(a \cdot a\right)}{{b}^{3}}, -0.5 \cdot \frac{a}{b}\right)\right)}\\ \end{array} \]
Alternative 9
Accuracy88.5%
Cost20868
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \mathsf{fma}\left(-0.375, \frac{c \cdot \left(a \cdot a\right)}{{b}^{3}}, -0.5 \cdot \frac{a}{b}\right)\right)}\\ \end{array} \]
Alternative 10
Accuracy88.5%
Cost14660
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \left(0.6666666666666666 \cdot \frac{b}{c} + \left(-0.5 \cdot \frac{a}{b} + -0.375 \cdot \frac{c \cdot {a}^{2}}{{b}^{3}}\right)\right)}\\ \end{array} \]
Alternative 11
Accuracy84.9%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \left(-0.5 \cdot \frac{a}{b} + 0.6666666666666666 \cdot \frac{b}{c}\right)}\\ \end{array} \]
Alternative 12
Accuracy85.0%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(-0.5, \frac{a}{b}, \frac{b \cdot 0.6666666666666666}{c}\right)}\\ \end{array} \]
Alternative 13
Accuracy85.0%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \frac{-0.5}{\frac{b}{a}}\right)}\\ \end{array} \]
Alternative 14
Accuracy85.0%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right) + b \cdot b} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \frac{-0.5}{\frac{b}{a}}\right)}\\ \end{array} \]
Alternative 15
Accuracy85.0%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 27:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot -0.3333333333333333}{a \cdot \mathsf{fma}\left(0.6666666666666666, \frac{b}{c}, \frac{-0.5}{\frac{b}{a}}\right)}\\ \end{array} \]
Alternative 16
Accuracy81.6%
Cost1088
\[\frac{a \cdot -0.3333333333333333}{a \cdot \left(-0.5 \cdot \frac{a}{b} + 0.6666666666666666 \cdot \frac{b}{c}\right)} \]
Alternative 17
Accuracy64.1%
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))