?

Average Error: 28.7 → 1.3
Time: 20.3s
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.7

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

    \[\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.7
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 7.3:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{\frac{b \cdot b - t_0}{a}}{b + \sqrt{t_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \mathsf{fma}\left(3, \left(a \cdot a\right) \cdot \left(\frac{c}{{b}^{3}} \cdot 0.375\right), \frac{a \cdot 1.5}{b}\right)\right)}\\ \end{array} \]
Alternative 2
Error6.7
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 7.3:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \frac{b \cdot b - t_0}{b + \sqrt{t_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \mathsf{fma}\left(3, \left(a \cdot a\right) \cdot \left(\frac{c}{{b}^{3}} \cdot 0.375\right), \frac{a \cdot 1.5}{b}\right)\right)}\\ \end{array} \]
Alternative 3
Error6.7
Cost20932
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ \mathbf{if}\;b \leq 7.3:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a} \cdot \left(b \cdot b - t_0\right)}{b + \sqrt{t_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \mathsf{fma}\left(3, \left(a \cdot a\right) \cdot \left(\frac{c}{{b}^{3}} \cdot 0.375\right), \frac{a \cdot 1.5}{b}\right)\right)}\\ \end{array} \]
Alternative 4
Error6.9
Cost20740
\[\begin{array}{l} \mathbf{if}\;b \leq 7.3:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \mathsf{fma}\left(3, \left(a \cdot a\right) \cdot \left(\frac{c}{{b}^{3}} \cdot 0.375\right), \frac{a \cdot 1.5}{b}\right)\right)}\\ \end{array} \]
Alternative 5
Error9.3
Cost13764
\[\begin{array}{l} \mathbf{if}\;b \leq 11.8:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}\\ \end{array} \]
Alternative 6
Error9.3
Cost13764
\[\begin{array}{l} \mathbf{if}\;b \leq 11.2:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}\\ \end{array} \]
Alternative 7
Error9.3
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 11.2:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}\\ \end{array} \]
Alternative 8
Error9.3
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 11.2:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}\\ \end{array} \]
Alternative 9
Error11.4
Cost7104
\[\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, \frac{a \cdot 1.5}{b}\right)} \]
Alternative 10
Error11.4
Cost832
\[\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}} \]
Alternative 11
Error22.6
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

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