?

Average Error: 53.66% → 10.09%
Time: 22.0s
Precision: binary64
Cost: 14028

?

\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
\[\begin{array}{l} t_0 := \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\\ \mathbf{if}\;b \leq -2 \cdot 10^{+117}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-305}:\\ \;\;\;\;-0.5 \cdot \frac{c \cdot 4}{b - t_0}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{+127}:\\ \;\;\;\;-0.5 \cdot \frac{b + t_0}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (fma c (* a -4.0) (* b b)))))
   (if (<= b -2e+117)
     (* -0.5 (* (/ c (* 2.0 (- b (/ a (/ b c))))) 4.0))
     (if (<= b 3.4e-305)
       (* -0.5 (/ (* c 4.0) (- b t_0)))
       (if (<= b 8.4e+127) (* -0.5 (/ (+ b t_0) a)) (- (/ c b) (/ b a)))))))
double code(double a, double b, double c) {
	return (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
double code(double a, double b, double c) {
	double t_0 = sqrt(fma(c, (a * -4.0), (b * b)));
	double tmp;
	if (b <= -2e+117) {
		tmp = -0.5 * ((c / (2.0 * (b - (a / (b / c))))) * 4.0);
	} else if (b <= 3.4e-305) {
		tmp = -0.5 * ((c * 4.0) / (b - t_0));
	} else if (b <= 8.4e+127) {
		tmp = -0.5 * ((b + t_0) / a);
	} else {
		tmp = (c / b) - (b / a);
	}
	return tmp;
}
function code(a, b, c)
	return Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a))
end
function code(a, b, c)
	t_0 = sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))
	tmp = 0.0
	if (b <= -2e+117)
		tmp = Float64(-0.5 * Float64(Float64(c / Float64(2.0 * Float64(b - Float64(a / Float64(b / c))))) * 4.0));
	elseif (b <= 3.4e-305)
		tmp = Float64(-0.5 * Float64(Float64(c * 4.0) / Float64(b - t_0)));
	elseif (b <= 8.4e+127)
		tmp = Float64(-0.5 * Float64(Float64(b + t_0) / a));
	else
		tmp = Float64(Float64(c / b) - Float64(b / a));
	end
	return tmp
end
code[a_, b_, c_] := N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2e+117], N[(-0.5 * N[(N[(c / N[(2.0 * N[(b - N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-305], N[(-0.5 * N[(N[(c * 4.0), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.4e+127], N[(-0.5 * N[(N[(b + t$95$0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+117}:\\
\;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\

\mathbf{elif}\;b \leq 3.4 \cdot 10^{-305}:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot 4}{b - t_0}\\

\mathbf{elif}\;b \leq 8.4 \cdot 10^{+127}:\\
\;\;\;\;-0.5 \cdot \frac{b + t_0}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\


\end{array}

Error?

Target

Original53.66%
Target33.1%
Herbie10.09%
\[\begin{array}{l} \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array} \]

Derivation?

  1. Split input into 4 regimes
  2. if b < -2.0000000000000001e117

    1. Initial program 94.91

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Simplified94.91

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

      [Start]94.91

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      *-lft-identity [<=]94.91

      \[ \color{blue}{1 \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]

      metadata-eval [<=]94.91

      \[ \color{blue}{\left(--1\right)} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      associate-*r/ [=>]94.91

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}{2 \cdot a}} \]

      associate-*l/ [<=]94.91

      \[ \color{blue}{\frac{--1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-neg-frac [<=]94.91

      \[ \color{blue}{\left(-\frac{-1}{2 \cdot a}\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]

      distribute-lft-neg-in [<=]94.91

      \[ \color{blue}{-\frac{-1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-rgt-neg-out [<=]94.91

      \[ \color{blue}{\frac{-1}{2 \cdot a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)} \]

      associate-/r* [=>]94.91

      \[ \color{blue}{\frac{\frac{-1}{2}}{a}} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      metadata-eval [=>]94.91

      \[ \frac{\color{blue}{-0.5}}{a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      sub-neg [=>]94.91

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(\left(-b\right) + \left(-\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      distribute-neg-out [=>]94.91

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(-\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      remove-double-neg [=>]94.91

      \[ \frac{-0.5}{a} \cdot \color{blue}{\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      sub-neg [=>]94.91

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]

      +-commutative [=>]94.91

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{\left(-4 \cdot \left(a \cdot c\right)\right) + b \cdot b}}\right) \]
    3. Applied egg-rr94.99

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{a \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
    4. Simplified84.77

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
      Proof

      [Start]94.99

      \[ \frac{-0.5}{\frac{a \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]

      *-commutative [<=]94.99

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

      associate-/l* [<=]94.99

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

      *-commutative [<=]94.99

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

      associate-*l/ [<=]94.99

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

      *-commutative [=>]94.99

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

      *-commutative [=>]94.99

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

      associate-/r* [=>]94.9

      \[ -0.5 \cdot \color{blue}{\frac{\frac{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}{a}}{b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
    5. Taylor expanded in b around -inf 85

      \[\leadsto -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \color{blue}{\left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)}} \]
    6. Simplified85

      \[\leadsto -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \color{blue}{\left(\frac{a}{\frac{b}{c}} \cdot 2 - b\right)}} \]
      Proof

      [Start]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)} \]

      mul-1-neg [=>]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \left(2 \cdot \frac{c \cdot a}{b} + \color{blue}{\left(-b\right)}\right)} \]

      unsub-neg [=>]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \color{blue}{\left(2 \cdot \frac{c \cdot a}{b} - b\right)}} \]

      *-commutative [=>]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \left(\color{blue}{\frac{c \cdot a}{b} \cdot 2} - b\right)} \]

      *-commutative [=>]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \left(\frac{\color{blue}{a \cdot c}}{b} \cdot 2 - b\right)} \]

      associate-/l* [=>]85

      \[ -0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \left(\color{blue}{\frac{a}{\frac{b}{c}}} \cdot 2 - b\right)} \]
    7. Applied egg-rr57.48

      \[\leadsto -0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{a \cdot \left(c \cdot 4\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}\right)} - 1\right)} \]
    8. Simplified2.67

      \[\leadsto -0.5 \cdot \color{blue}{\left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)} \]
      Proof

      [Start]57.48

      \[ -0.5 \cdot \left(e^{\mathsf{log1p}\left(\frac{a \cdot \left(c \cdot 4\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}\right)} - 1\right) \]

      expm1-def [=>]26.55

      \[ -0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a \cdot \left(c \cdot 4\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}\right)\right)} \]

      expm1-log1p [=>]22.19

      \[ -0.5 \cdot \color{blue}{\frac{a \cdot \left(c \cdot 4\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}} \]

      *-lft-identity [<=]22.19

      \[ -0.5 \cdot \color{blue}{\left(1 \cdot \frac{a \cdot \left(c \cdot 4\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}\right)} \]

      associate-*r/ [=>]22.19

      \[ -0.5 \cdot \color{blue}{\frac{1 \cdot \left(a \cdot \left(c \cdot 4\right)\right)}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)}} \]

      associate-*l/ [<=]22.23

      \[ -0.5 \cdot \color{blue}{\left(\frac{1}{a \cdot \left(b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)\right)} \cdot \left(a \cdot \left(c \cdot 4\right)\right)\right)} \]

      associate-/r* [=>]21.42

      \[ -0.5 \cdot \left(\color{blue}{\frac{\frac{1}{a}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)}} \cdot \left(a \cdot \left(c \cdot 4\right)\right)\right) \]

      associate-*l/ [=>]12.32

      \[ -0.5 \cdot \color{blue}{\frac{\frac{1}{a} \cdot \left(a \cdot \left(c \cdot 4\right)\right)}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)}} \]

      associate-/r/ [<=]12.33

      \[ -0.5 \cdot \frac{\color{blue}{\frac{1}{\frac{a}{a \cdot \left(c \cdot 4\right)}}}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      associate-/r* [=>]3.03

      \[ -0.5 \cdot \frac{\frac{1}{\color{blue}{\frac{\frac{a}{a}}{c \cdot 4}}}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      *-commutative [=>]3.03

      \[ -0.5 \cdot \frac{\frac{1}{\frac{\frac{a}{a}}{\color{blue}{4 \cdot c}}}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      associate-/r* [=>]3.03

      \[ -0.5 \cdot \frac{\frac{1}{\color{blue}{\frac{\frac{\frac{a}{a}}{4}}{c}}}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      *-inverses [=>]3.03

      \[ -0.5 \cdot \frac{\frac{1}{\frac{\frac{\color{blue}{1}}{4}}{c}}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      associate-/r/ [=>]2.89

      \[ -0.5 \cdot \frac{\color{blue}{\frac{1}{\frac{1}{4}} \cdot c}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      metadata-eval [=>]2.89

      \[ -0.5 \cdot \frac{\frac{1}{\color{blue}{0.25}} \cdot c}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      metadata-eval [=>]2.89

      \[ -0.5 \cdot \frac{\color{blue}{4} \cdot c}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

      *-commutative [<=]2.89

      \[ -0.5 \cdot \frac{\color{blue}{c \cdot 4}}{b + \left(b - \left(a \cdot 2\right) \cdot \frac{c}{b}\right)} \]

    if -2.0000000000000001e117 < b < 3.4000000000000001e-305

    1. Initial program 52.01

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Simplified52.09

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

      [Start]52.01

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      *-lft-identity [<=]52.01

      \[ \color{blue}{1 \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]

      metadata-eval [<=]52.01

      \[ \color{blue}{\left(--1\right)} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      associate-*r/ [=>]52.01

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}{2 \cdot a}} \]

      associate-*l/ [<=]52.07

      \[ \color{blue}{\frac{--1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-neg-frac [<=]52.07

      \[ \color{blue}{\left(-\frac{-1}{2 \cdot a}\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]

      distribute-lft-neg-in [<=]52.07

      \[ \color{blue}{-\frac{-1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-rgt-neg-out [<=]52.07

      \[ \color{blue}{\frac{-1}{2 \cdot a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)} \]

      associate-/r* [=>]52.03

      \[ \color{blue}{\frac{\frac{-1}{2}}{a}} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      metadata-eval [=>]52.03

      \[ \frac{\color{blue}{-0.5}}{a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      sub-neg [=>]52.03

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(\left(-b\right) + \left(-\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      distribute-neg-out [=>]52.03

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(-\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      remove-double-neg [=>]52.03

      \[ \frac{-0.5}{a} \cdot \color{blue}{\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      sub-neg [=>]52.03

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]

      +-commutative [=>]52.03

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{\left(-4 \cdot \left(a \cdot c\right)\right) + b \cdot b}}\right) \]
    3. Applied egg-rr58.97

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{a \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
    4. Simplified25.37

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4 + 0 \cdot \left(b \cdot b\right)}{a}}{b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
      Proof

      [Start]58.97

      \[ \frac{-0.5}{\frac{a \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]

      *-commutative [<=]58.97

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

      associate-/l* [<=]58.94

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

      *-commutative [<=]58.94

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

      associate-*l/ [<=]58.93

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

      *-commutative [=>]58.93

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

      *-commutative [=>]58.93

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

      associate-/r* [=>]52

      \[ -0.5 \cdot \color{blue}{\frac{\frac{b \cdot b - \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}{a}}{b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
    5. Taylor expanded in c around 0 13.48

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

    if 3.4000000000000001e-305 < b < 8.39999999999999967e127

    1. Initial program 13.49

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Simplified13.59

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

      [Start]13.49

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      /-rgt-identity [<=]13.49

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\color{blue}{\frac{2 \cdot a}{1}}} \]

      metadata-eval [<=]13.49

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\frac{2 \cdot a}{\color{blue}{--1}}} \]

      associate-/l* [=>]13.66

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\color{blue}{\frac{2}{\frac{--1}{a}}}} \]

      distribute-neg-frac [<=]13.66

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\frac{2}{\color{blue}{-\frac{-1}{a}}}} \]

      associate-/r/ [=>]13.74

      \[ \color{blue}{\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot \left(-\frac{-1}{a}\right)} \]

      neg-mul-1 [=>]13.74

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot \color{blue}{\left(-1 \cdot \frac{-1}{a}\right)} \]

      *-commutative [<=]13.74

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot \color{blue}{\left(\frac{-1}{a} \cdot -1\right)} \]

      associate-/r/ [<=]13.74

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot \color{blue}{\frac{-1}{\frac{a}{-1}}} \]

      times-frac [<=]13.49

      \[ \color{blue}{\frac{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot -1}{2 \cdot \frac{a}{-1}}} \]

      *-commutative [<=]13.49

      \[ \frac{\color{blue}{-1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}{2 \cdot \frac{a}{-1}} \]

      times-frac [=>]13.53

      \[ \color{blue}{\frac{-1}{2} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\frac{a}{-1}}} \]

      metadata-eval [=>]13.53

      \[ \color{blue}{-0.5} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\frac{a}{-1}} \]

      associate-/r/ [=>]13.53

      \[ -0.5 \cdot \color{blue}{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a} \cdot -1\right)} \]

      *-commutative [<=]13.53

      \[ -0.5 \cdot \color{blue}{\left(-1 \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\right)} \]

      neg-mul-1 [<=]13.53

      \[ -0.5 \cdot \color{blue}{\left(-\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\right)} \]

      distribute-frac-neg [<=]13.53

      \[ -0.5 \cdot \color{blue}{\frac{-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}{a}} \]

    if 8.39999999999999967e127 < b

    1. Initial program 86.11

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Simplified86.17

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

      [Start]86.11

      \[ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      *-lft-identity [<=]86.11

      \[ \color{blue}{1 \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]

      metadata-eval [<=]86.11

      \[ \color{blue}{\left(--1\right)} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]

      associate-*r/ [=>]86.11

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}{2 \cdot a}} \]

      associate-*l/ [<=]86.17

      \[ \color{blue}{\frac{--1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-neg-frac [<=]86.17

      \[ \color{blue}{\left(-\frac{-1}{2 \cdot a}\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]

      distribute-lft-neg-in [<=]86.17

      \[ \color{blue}{-\frac{-1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      distribute-rgt-neg-out [<=]86.17

      \[ \color{blue}{\frac{-1}{2 \cdot a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)} \]

      associate-/r* [=>]86.17

      \[ \color{blue}{\frac{\frac{-1}{2}}{a}} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      metadata-eval [=>]86.17

      \[ \frac{\color{blue}{-0.5}}{a} \cdot \left(-\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right) \]

      sub-neg [=>]86.17

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(\left(-b\right) + \left(-\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      distribute-neg-out [=>]86.17

      \[ \frac{-0.5}{a} \cdot \left(-\color{blue}{\left(-\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\right)}\right) \]

      remove-double-neg [=>]86.17

      \[ \frac{-0.5}{a} \cdot \color{blue}{\left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]

      sub-neg [=>]86.17

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]

      +-commutative [=>]86.17

      \[ \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{\left(-4 \cdot \left(a \cdot c\right)\right) + b \cdot b}}\right) \]
    3. Taylor expanded in a around 0 5.33

      \[\leadsto \color{blue}{\frac{c}{b} + -1 \cdot \frac{b}{a}} \]
    4. Simplified5.33

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
      Proof

      [Start]5.33

      \[ \frac{c}{b} + -1 \cdot \frac{b}{a} \]

      mul-1-neg [=>]5.33

      \[ \frac{c}{b} + \color{blue}{\left(-\frac{b}{a}\right)} \]

      unsub-neg [=>]5.33

      \[ \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.09

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+117}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-305}:\\ \;\;\;\;-0.5 \cdot \frac{c \cdot 4}{b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{+127}:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error16.27%
Cost13896
\[\begin{array}{l} \mathbf{if}\;b \leq -8.6 \cdot 10^{-14}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 8.2 \cdot 10^{+127}:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 2
Error16.23%
Cost7688
\[\begin{array}{l} \mathbf{if}\;b \leq -9.2 \cdot 10^{-14}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 8.2 \cdot 10^{+127}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 3
Error16.36%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{-14}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 8.2 \cdot 10^{+127}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 4
Error21.24%
Cost7496
\[\begin{array}{l} \mathbf{if}\;b \leq -9.6 \cdot 10^{-11}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{-81}:\\ \;\;\;\;-0.5 \cdot \frac{c \cdot 4}{b - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 5
Error22.13%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -1.04 \cdot 10^{-13}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{elif}\;b \leq 1.52 \cdot 10^{-24}:\\ \;\;\;\;-0.5 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 6
Error34.61%
Cost1092
\[\begin{array}{l} \mathbf{if}\;b \leq 1.9 \cdot 10^{-304}:\\ \;\;\;\;-0.5 \cdot \left(\frac{c}{2 \cdot \left(b - \frac{a}{\frac{b}{c}}\right)} \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 7
Error34.91%
Cost580
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array} \]
Alternative 8
Error62.06%
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -52000000:\\ \;\;\;\;\frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 9
Error34.94%
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq -4.5 \cdot 10^{-304}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array} \]
Alternative 10
Error97.41%
Cost192
\[\frac{b}{a} \]
Alternative 11
Error88.53%
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023089 
(FPCore (a b c)
  :name "quadm (p42, negative)"
  :precision binary64

  :herbie-target
  (if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))