quad2m (problem 3.2.1, negative)

?

Percentage Accurate: 57.4% → 88.2%
Time: 30.8s
Precision: binary64
Cost: 20808

?

\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := \frac{-0.5 \cdot c}{b_2}\\ \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq -1.75 \cdot 10^{-37}:\\ \;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + c \cdot a}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}{a}\\ \mathbf{elif}\;b_2 \leq -1.35 \cdot 10^{-119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq 0.0002:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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
 (let* ((t_0 (/ (* -0.5 c) b_2)))
   (if (<= b_2 -1.85e+28)
     t_0
     (if (<= b_2 -1.75e-37)
       (/
        (/
         (+ (- (* b_2 b_2) (* b_2 b_2)) (* c a))
         (fma -1.0 b_2 (hypot b_2 (sqrt (* c (- a))))))
        a)
       (if (<= b_2 -1.35e-119)
         t_0
         (if (<= b_2 0.0002)
           (/
            (-
             (- b_2)
             (sqrt (+ (- (* b_2 b_2) (* c a)) (* 2.0 (fma a (- c) (* c a))))))
            a)
           (* -2.0 (/ b_2 a))))))))
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 t_0 = (-0.5 * c) / b_2;
	double tmp;
	if (b_2 <= -1.85e+28) {
		tmp = t_0;
	} else if (b_2 <= -1.75e-37) {
		tmp = ((((b_2 * b_2) - (b_2 * b_2)) + (c * a)) / fma(-1.0, b_2, hypot(b_2, sqrt((c * -a))))) / a;
	} else if (b_2 <= -1.35e-119) {
		tmp = t_0;
	} else if (b_2 <= 0.0002) {
		tmp = (-b_2 - sqrt((((b_2 * b_2) - (c * a)) + (2.0 * fma(a, -c, (c * a)))))) / a;
	} else {
		tmp = -2.0 * (b_2 / a);
	}
	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)
	t_0 = Float64(Float64(-0.5 * c) / b_2)
	tmp = 0.0
	if (b_2 <= -1.85e+28)
		tmp = t_0;
	elseif (b_2 <= -1.75e-37)
		tmp = Float64(Float64(Float64(Float64(Float64(b_2 * b_2) - Float64(b_2 * b_2)) + Float64(c * a)) / fma(-1.0, b_2, hypot(b_2, sqrt(Float64(c * Float64(-a)))))) / a);
	elseif (b_2 <= -1.35e-119)
		tmp = t_0;
	elseif (b_2 <= 0.0002)
		tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(Float64(b_2 * b_2) - Float64(c * a)) + Float64(2.0 * fma(a, Float64(-c), Float64(c * a)))))) / a);
	else
		tmp = Float64(-2.0 * Float64(b_2 / a));
	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_] := Block[{t$95$0 = N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision]}, If[LessEqual[b$95$2, -1.85e+28], t$95$0, If[LessEqual[b$95$2, -1.75e-37], N[(N[(N[(N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * b$95$2 + N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -1.35e-119], t$95$0, If[LessEqual[b$95$2, 0.0002], N[(N[((-b$95$2) - N[Sqrt[N[(N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(a * (-c) + N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := \frac{-0.5 \cdot c}{b_2}\\
\mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;b_2 \leq -1.35 \cdot 10^{-119}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b_2 \leq 0.0002:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\


\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 10 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Derivation?

  1. Split input into 4 regimes
  2. if b_2 < -1.85e28 or -1.7500000000000001e-37 < b_2 < -1.35000000000000013e-119

    1. Initial program 20.5%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Simplified89.9%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
      Step-by-step derivation

      [Start]89.9%

      \[ -0.5 \cdot \frac{c}{b_2} \]

      associate-*r/ [=>]89.9%

      \[ \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]

    if -1.85e28 < b_2 < -1.7500000000000001e-37

    1. Initial program 73.9%

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

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{1.5}\right)}^{0.3333333333333333}}}{a} \]
      Step-by-step derivation

      [Start]73.9%

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

      add-cbrt-cube [=>]55.9%

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

      pow3 [=>]55.3%

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

      pow1/3 [=>]51.9%

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

      sqrt-pow2 [=>]51.9%

      \[ \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{3}{2}\right)}\right)}}^{0.3333333333333333}}{a} \]

      metadata-eval [=>]51.9%

      \[ \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}}{a} \]
    3. Simplified55.6%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]
      Step-by-step derivation

      [Start]51.9%

      \[ \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{1.5}\right)}^{0.3333333333333333}}{a} \]

      unpow1/3 [=>]55.6%

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

      *-commutative [=>]55.6%

      \[ \frac{\left(-b_2\right) - \sqrt[3]{{\left(b_2 \cdot b_2 - \color{blue}{c \cdot a}\right)}^{1.5}}}{a} \]
    4. Applied egg-rr73.5%

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b_2\right)}^{2} - \left(b_2 \cdot b_2 - a \cdot c\right)}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}}{a} \]
      Step-by-step derivation

      [Start]55.6%

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

      flip-- [=>]54.7%

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

      pow2 [=>]54.7%

      \[ \frac{\frac{\color{blue}{{\left(-b_2\right)}^{2}} - \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}} \cdot \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow1/3 [=>]51.2%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \color{blue}{{\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}\right)}^{0.3333333333333333}} \cdot \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow1/3 [=>]50.3%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - {\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}\right)}^{0.3333333333333333} \cdot \color{blue}{{\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}\right)}^{0.3333333333333333}}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow-prod-down [=>]42.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \color{blue}{{\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5} \cdot {\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}\right)}^{0.3333333333333333}}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow-prod-up [=>]42.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - {\color{blue}{\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{\left(1.5 + 1.5\right)}\right)}}^{0.3333333333333333}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      metadata-eval [=>]42.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - {\left({\left(b_2 \cdot b_2 - c \cdot a\right)}^{\color{blue}{3}}\right)}^{0.3333333333333333}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow3 [<=]42.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - {\color{blue}{\left(\left(\left(b_2 \cdot b_2 - c \cdot a\right) \cdot \left(b_2 \cdot b_2 - c \cdot a\right)\right) \cdot \left(b_2 \cdot b_2 - c \cdot a\right)\right)}}^{0.3333333333333333}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      pow1/3 [<=]45.6%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \color{blue}{\sqrt[3]{\left(\left(b_2 \cdot b_2 - c \cdot a\right) \cdot \left(b_2 \cdot b_2 - c \cdot a\right)\right) \cdot \left(b_2 \cdot b_2 - c \cdot a\right)}}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      add-cbrt-cube [<=]55.9%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \color{blue}{\left(b_2 \cdot b_2 - c \cdot a\right)}}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]

      *-commutative [=>]55.9%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \left(b_2 \cdot b_2 - \color{blue}{a \cdot c}\right)}{\left(-b_2\right) + \sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{1.5}}}}{a} \]
    5. Simplified91.1%

      \[\leadsto \frac{\color{blue}{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + a \cdot c}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{a \cdot \left(-c\right)}\right)\right)}}}{a} \]
      Step-by-step derivation

      [Start]73.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \left(b_2 \cdot b_2 - a \cdot c\right)}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}{a} \]

      unpow2 [<=]73.5%

      \[ \frac{\frac{{\left(-b_2\right)}^{2} - \left(\color{blue}{{b_2}^{2}} - a \cdot c\right)}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}{a} \]

      associate--r- [=>]91.1%

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

      unpow2 [=>]91.1%

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

      sqr-neg [=>]91.1%

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

      unpow2 [=>]91.1%

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

      distribute-rgt-neg-out [=>]91.1%

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

      *-commutative [<=]91.1%

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

      distribute-rgt-neg-out [<=]91.1%

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

    if -1.35000000000000013e-119 < b_2 < 2.0000000000000001e-4

    1. Initial program 81.0%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied egg-rr81.0%

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

      [Start]81.0%

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

      prod-diff [=>]81.0%

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

      *-commutative [<=]81.0%

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

      fma-neg [<=]81.0%

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

      prod-diff [=>]81.0%

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

      *-commutative [<=]81.0%

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

      fma-neg [<=]81.0%

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

      associate-+l+ [=>]81.0%

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

      *-commutative [<=]81.0%

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

      fma-udef [=>]81.0%

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

      distribute-lft-neg-in [<=]81.0%

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

      *-commutative [<=]81.0%

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

      distribute-rgt-neg-in [=>]81.0%

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

      fma-def [=>]81.0%

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

      *-commutative [<=]81.0%

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

      fma-udef [=>]81.0%

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

      distribute-lft-neg-in [<=]81.0%

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

      *-commutative [<=]81.0%

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

      distribute-rgt-neg-in [=>]81.0%

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

      fma-def [=>]81.0%

      \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)}\right)}}{a} \]
    3. Simplified81.0%

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

      [Start]81.0%

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

      *-commutative [=>]81.0%

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

      count-2 [=>]81.0%

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

      *-commutative [=>]81.0%

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

    if 2.0000000000000001e-4 < b_2

    1. Initial program 86.6%

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

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification90.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq -1.75 \cdot 10^{-37}:\\ \;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + c \cdot a}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}{a}\\ \mathbf{elif}\;b_2 \leq -1.35 \cdot 10^{-119}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 0.0002:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy88.2%
Cost20808
\[\begin{array}{l} t_0 := \frac{-0.5 \cdot c}{b_2}\\ \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq -1.75 \cdot 10^{-37}:\\ \;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + c \cdot a}{\mathsf{fma}\left(-1, b_2, \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right)}}{a}\\ \mathbf{elif}\;b_2 \leq -1.35 \cdot 10^{-119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq 0.0002:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]
Alternative 2
Accuracy86.6%
Cost14672
\[\begin{array}{l} t_0 := b_2 \cdot b_2 - c \cdot a\\ t_1 := \frac{-0.5 \cdot c}{b_2}\\ \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b_2 \leq -1.82 \cdot 10^{-37}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{t_0}}{a}\\ \mathbf{elif}\;b_2 \leq -2.3 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b_2 \leq 0.0002:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{t_0 + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]
Alternative 3
Accuracy86.5%
Cost7696
\[\begin{array}{l} t_0 := \frac{-0.5 \cdot c}{b_2}\\ t_1 := \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq -1.82 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b_2 \leq -2.25 \cdot 10^{-120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b_2 \leq 0.0002:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]
Alternative 4
Accuracy85.9%
Cost7240
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.55 \cdot 10^{-120}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 9.5 \cdot 10^{-179}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 5
Accuracy85.8%
Cost7112
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-119}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 3.1 \cdot 10^{-179}:\\ \;\;\;\;\frac{-\sqrt{c \cdot \left(-a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 6
Accuracy77.1%
Cost836
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 7
Accuracy47.1%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{0}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]
Alternative 8
Accuracy76.8%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -8 \cdot 10^{-304}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array} \]
Alternative 9
Accuracy28.6%
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{0}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]
Alternative 10
Accuracy10.0%
Cost192
\[\frac{0}{a} \]

Reproduce?

herbie shell --seed 2023277 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))