Average Error: 33.8 → 11.4
Time: 17.5s
Precision: binary64
Cost: 26828
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\ \mathbf{elif}\;b_2 \leq -1.22 \cdot 10^{-213}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.4 \cdot 10^{-278}:\\ \;\;\;\;\frac{{\left(e^{0.25 \cdot \left(\log \left(-a\right) - \log \left(\frac{1}{c}\right)\right)}\right)}^{2} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.7e+74)
   (+ (* -2.0 (/ b_2 a)) (/ 0.5 (/ b_2 c)))
   (if (<= b_2 -1.22e-213)
     (/ (- (sqrt (+ (* b_2 b_2) (fma a (- c) (fma a (- c) (* a c))))) b_2) a)
     (if (<= b_2 2.4e-278)
       (/ (- (pow (exp (* 0.25 (- (log (- a)) (log (/ 1.0 c))))) 2.0) b_2) a)
       (if (<= b_2 5.2e-76)
         (/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
         (* -0.5 (/ c b_2)))))))
double code(double a, double b_2, double c) {
	return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.7e+74) {
		tmp = (-2.0 * (b_2 / a)) + (0.5 / (b_2 / c));
	} else if (b_2 <= -1.22e-213) {
		tmp = (sqrt(((b_2 * b_2) + fma(a, -c, fma(a, -c, (a * c))))) - b_2) / a;
	} else if (b_2 <= 2.4e-278) {
		tmp = (pow(exp((0.25 * (log(-a) - log((1.0 / c))))), 2.0) - b_2) / a;
	} else if (b_2 <= 5.2e-76) {
		tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
	} else {
		tmp = -0.5 * (c / b_2);
	}
	return tmp;
}
function code(a, b_2, c)
	return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a)
end
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.7e+74)
		tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 / Float64(b_2 / c)));
	elseif (b_2 <= -1.22e-213)
		tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) + fma(a, Float64(-c), fma(a, Float64(-c), Float64(a * c))))) - b_2) / a);
	elseif (b_2 <= 2.4e-278)
		tmp = Float64(Float64((exp(Float64(0.25 * Float64(log(Float64(-a)) - log(Float64(1.0 / c))))) ^ 2.0) - b_2) / a);
	elseif (b_2 <= 5.2e-76)
		tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a);
	else
		tmp = Float64(-0.5 * Float64(c / b_2));
	end
	return tmp
end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.7e+74], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -1.22e-213], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] + N[(a * (-c) + N[(a * (-c) + N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.4e-278], N[(N[(N[Power[N[Exp[N[(0.25 * N[(N[Log[(-a)], $MachinePrecision] - N[Log[N[(1.0 / c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 5.2e-76], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+74}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\

\mathbf{elif}\;b_2 \leq -1.22 \cdot 10^{-213}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)} - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 2.4 \cdot 10^{-278}:\\
\;\;\;\;\frac{{\left(e^{0.25 \cdot \left(\log \left(-a\right) - \log \left(\frac{1}{c}\right)\right)}\right)}^{2} - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\


\end{array}

Error

Derivation

  1. Split input into 5 regimes
  2. if b_2 < -1.7e74

    1. Initial program 40.6

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

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]
    3. Applied egg-rr3.9

      \[\leadsto -2 \cdot \frac{b_2}{a} + \color{blue}{\frac{0.5}{\frac{b_2}{c}}} \]

    if -1.7e74 < b_2 < -1.22e-213

    1. Initial program 6.9

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

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

    if -1.22e-213 < b_2 < 2.4e-278

    1. Initial program 14.9

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

      \[\leadsto \frac{\left(-b_2\right) + \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
    3. Taylor expanded in c around inf 36.2

      \[\leadsto \frac{\color{blue}{{\left(e^{0.25 \cdot \left(\log \left(-a\right) + -1 \cdot \log \left(\frac{1}{c}\right)\right)}\right)}^{2} - b_2}}{a} \]

    if 2.4e-278 < b_2 < 5.1999999999999999e-76

    1. Initial program 21.9

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

    if 5.1999999999999999e-76 < b_2

    1. Initial program 53.0

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification11.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\ \mathbf{elif}\;b_2 \leq -1.22 \cdot 10^{-213}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.4 \cdot 10^{-278}:\\ \;\;\;\;\frac{{\left(e^{0.25 \cdot \left(\log \left(-a\right) - \log \left(\frac{1}{c}\right)\right)}\right)}^{2} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]

Alternatives

Alternative 1
Error9.8
Cost20552
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 2
Error9.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 3
Error13.6
Cost7176
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -6.6 \cdot 10^{-19}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{0.5}{\frac{b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 4
Error36.7
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.95 \cdot 10^{-194}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\ \end{array} \]
Alternative 5
Error22.7
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.95 \cdot 10^{-194}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\ \end{array} \]
Alternative 6
Error22.5
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.95 \cdot 10^{-194}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-0.5}{b_2}\\ \end{array} \]
Alternative 7
Error22.4
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.95 \cdot 10^{-194}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 8
Error53.3
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.75 \cdot 10^{-304}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a}\\ \end{array} \]
Alternative 9
Error56.3
Cost192
\[\frac{0}{a} \]

Error

Reproduce

herbie shell --seed 2022295 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))