?

Average Error: 28.9 → 1.3
Time: 25.5s
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}^{2}}}{t_0}}{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)) (pow t_0 2.0)) t_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)) / pow(t_0, 2.0)) / t_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 ^ 2.0)) / t_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] / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $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}^{2}}}{t_0}}{a \cdot 3}
\end{array}

Error?

Derivation?

  1. Initial program 28.9

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

    \[\leadsto \frac{\color{blue}{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{{\left(\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}\right)}^{2}}}{\sqrt[3]{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}}}{3 \cdot a} \]
  3. Taylor expanded in b around 0 1.3

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

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

Alternatives

Alternative 1
Error6.4
Cost41028
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1:\\ \;\;\;\;\frac{e^{\log \left(\frac{b \cdot b - t_0}{b + \sqrt{t_0}}\right)}}{a} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\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(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\\ \end{array} \]
Alternative 2
Error6.4
Cost40964
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1:\\ \;\;\;\;\frac{b \cdot b - t_0}{a} \cdot \frac{-0.3333333333333333}{b + \sqrt{t_0}}\\ \mathbf{else}:\\ \;\;\;\;\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(a \cdot \left(c \cdot c\right)\right)}{{b}^{3}}\right)\right)\\ \end{array} \]
Alternative 3
Error9.0
Cost28228
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00395:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{b \cdot b - t_0}{a \cdot \left(b + \sqrt{t_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \]
Alternative 4
Error9.0
Cost28228
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00395:\\ \;\;\;\;\frac{b \cdot b - t_0}{a} \cdot \frac{-0.3333333333333333}{b + \sqrt{t_0}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \]
Alternative 5
Error9.2
Cost21124
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -0.00395:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, \frac{c \cdot c}{\frac{{b}^{3}}{a}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \]
Alternative 6
Error14.8
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.65 \cdot 10^{-6}:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 7
Error14.7
Cost21060
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.65 \cdot 10^{-6}:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right) \cdot \frac{-0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 8
Error14.8
Cost14788
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3} \leq -1.65 \cdot 10^{-6}:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 9
Error22.5
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023047 
(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)))