Average Error: 34.1 → 13.1
Time: 6.4s
Precision: binary64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -3\right)\\ \mathbf{if}\;b \leq -4.895509654010244 \cdot 10^{+141}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -1.4196138185551953 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, t_0\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 2.634688304178707 \cdot 10^{-39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{t_0}\right)\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot \frac{c}{b}\right) \cdot -1.5}{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 (* c (* a -3.0))))
   (if (<= b -4.895509654010244e+141)
     (* -0.6666666666666666 (/ b a))
     (if (<= b -1.4196138185551953e-103)
       (/ (- (sqrt (fma b b t_0)) b) (* a 3.0))
       (if (<= b 2.634688304178707e-39)
         (/ (fma -1.0 b (hypot b (sqrt t_0))) (* a 3.0))
         (/ (* (* a (/ c b)) -1.5) (* 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 = c * (a * -3.0);
	double tmp;
	if (b <= -4.895509654010244e+141) {
		tmp = -0.6666666666666666 * (b / a);
	} else if (b <= -1.4196138185551953e-103) {
		tmp = (sqrt(fma(b, b, t_0)) - b) / (a * 3.0);
	} else if (b <= 2.634688304178707e-39) {
		tmp = fma(-1.0, b, hypot(b, sqrt(t_0))) / (a * 3.0);
	} else {
		tmp = ((a * (c / b)) * -1.5) / (a * 3.0);
	}
	return tmp;
}
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 * Float64(a * -3.0))
	tmp = 0.0
	if (b <= -4.895509654010244e+141)
		tmp = Float64(-0.6666666666666666 * Float64(b / a));
	elseif (b <= -1.4196138185551953e-103)
		tmp = Float64(Float64(sqrt(fma(b, b, t_0)) - b) / Float64(a * 3.0));
	elseif (b <= 2.634688304178707e-39)
		tmp = Float64(fma(-1.0, b, hypot(b, sqrt(t_0))) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(Float64(a * Float64(c / b)) * -1.5) / Float64(a * 3.0));
	end
	return tmp
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[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.895509654010244e+141], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -1.4196138185551953e-103], N[(N[(N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.634688304178707e-39], N[(N[(-1.0 * b + N[Sqrt[b ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] * -1.5), $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 := c \cdot \left(a \cdot -3\right)\\
\mathbf{if}\;b \leq -4.895509654010244 \cdot 10^{+141}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \leq -1.4196138185551953 \cdot 10^{-103}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, t_0\right)} - b}{a \cdot 3}\\

\mathbf{elif}\;b \leq 2.634688304178707 \cdot 10^{-39}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{t_0}\right)\right)}{a \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot \frac{c}{b}\right) \cdot -1.5}{a \cdot 3}\\


\end{array}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -4.89550965401024432e141

    1. Initial program 58.1

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

      \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}}{3 \cdot a} \]
    3. Applied egg-rr35.2

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right)}}{3 \cdot a} \]
    4. Taylor expanded in b around -inf 2.9

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]

    if -4.89550965401024432e141 < b < -1.4196138185551953e-103

    1. Initial program 6.0

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

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

    if -1.4196138185551953e-103 < b < 2.6346883041787069e-39

    1. Initial program 19.3

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

      \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}}{3 \cdot a} \]
    3. Applied egg-rr18.9

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

    if 2.6346883041787069e-39 < b

    1. Initial program 54.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Taylor expanded in b around inf 18.4

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{c \cdot a}{b}}}{3 \cdot a} \]
    3. Simplified15.8

      \[\leadsto \frac{\color{blue}{\left(a \cdot \frac{c}{b}\right) \cdot -1.5}}{3 \cdot a} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.895509654010244 \cdot 10^{+141}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -1.4196138185551953 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 2.634688304178707 \cdot 10^{-39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot \frac{c}{b}\right) \cdot -1.5}{a \cdot 3}\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))