Average Error: 34.1 → 9.8
Time: 18.5s
Precision: binary64
Cost: 13896
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
\[\begin{array}{l} \mathbf{if}\;b \leq -1.5 \cdot 10^{+129}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.36 \cdot 10^{-84}:\\ \;\;\;\;\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}{a} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -2}{\mathsf{fma}\left(b, 2, \frac{c \cdot 0.5}{\frac{b}{a \cdot -4}}\right)}\\ \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
 (if (<= b -1.5e+129)
   (- (/ c b) (/ b a))
   (if (<= b 1.36e-84)
     (* (/ (- b (sqrt (fma a (* c -4.0) (* b b)))) a) -0.5)
     (/ (* c -2.0) (fma b 2.0 (/ (* c 0.5) (/ b (* a -4.0))))))))
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 tmp;
	if (b <= -1.5e+129) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.36e-84) {
		tmp = ((b - sqrt(fma(a, (c * -4.0), (b * b)))) / a) * -0.5;
	} else {
		tmp = (c * -2.0) / fma(b, 2.0, ((c * 0.5) / (b / (a * -4.0))));
	}
	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)
	tmp = 0.0
	if (b <= -1.5e+129)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.36e-84)
		tmp = Float64(Float64(Float64(b - sqrt(fma(a, Float64(c * -4.0), Float64(b * b)))) / a) * -0.5);
	else
		tmp = Float64(Float64(c * -2.0) / fma(b, 2.0, Float64(Float64(c * 0.5) / Float64(b / Float64(a * -4.0)))));
	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_] := If[LessEqual[b, -1.5e+129], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.36e-84], N[(N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(c * -2.0), $MachinePrecision] / N[(b * 2.0 + N[(N[(c * 0.5), $MachinePrecision] / N[(b / N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+129}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.36 \cdot 10^{-84}:\\
\;\;\;\;\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}{a} \cdot -0.5\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -2}{\mathsf{fma}\left(b, 2, \frac{c \cdot 0.5}{\frac{b}{a \cdot -4}}\right)}\\


\end{array}

Error

Target

Original34.1
Target20.6
Herbie9.8
\[\begin{array}{l} \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \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 3 regimes
  2. if b < -1.50000000000000015e129

    1. Initial program 54.2

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

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

      [Start]54.2

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

      /-rgt-identity [<=]54.2

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

      metadata-eval [<=]54.2

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

      *-commutative [=>]54.2

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

      associate-/l* [=>]54.2

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

      associate-/l* [<=]54.2

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

      associate-*r/ [<=]54.3

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

      /-rgt-identity [<=]54.3

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

      metadata-eval [<=]54.3

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

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

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

      [Start]2.3

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

      associate-*r/ [=>]2.3

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

      mul-1-neg [=>]2.3

      \[ \frac{c}{b} + \frac{\color{blue}{-b}}{a} \]
    5. Taylor expanded in c around 0 2.3

      \[\leadsto \color{blue}{\frac{c}{b} + -1 \cdot \frac{b}{a}} \]
    6. Simplified2.3

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

      [Start]2.3

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

      mul-1-neg [=>]2.3

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

      sub-neg [<=]2.3

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

    if -1.50000000000000015e129 < b < 1.36e-84

    1. Initial program 12.3

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

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

      [Start]12.3

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

      associate-/r* [=>]12.3

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

      /-rgt-identity [<=]12.3

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

      metadata-eval [<=]12.3

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

      associate-/l/ [<=]12.3

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

      associate-/l* [<=]12.3

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

      associate-*r/ [<=]12.4

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

      times-frac [<=]12.3

      \[ \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 [=>]12.3

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

      times-frac [=>]12.3

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

    if 1.36e-84 < b

    1. Initial program 52.8

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

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

      [Start]52.8

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

      /-rgt-identity [<=]52.8

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

      metadata-eval [<=]52.8

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

      *-commutative [=>]52.8

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

      associate-/l* [=>]52.8

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

      associate-/l* [<=]52.8

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

      associate-*r/ [<=]52.8

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

      /-rgt-identity [<=]52.8

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

      metadata-eval [<=]52.8

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

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

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

      [Start]55.4

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

      associate-/l* [<=]55.4

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

      *-commutative [=>]55.4

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

      associate-*l/ [<=]55.4

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

      *-commutative [=>]55.4

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

      associate-/r* [=>]54.1

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

      fma-def [<=]54.1

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

      +-commutative [=>]54.1

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

      fma-def [=>]54.1

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

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

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

      [Start]26.6

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

      *-commutative [=>]26.6

      \[ 0.5 \cdot \frac{\color{blue}{c \cdot -4}}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)} \]
    7. Applied egg-rr26.6

      \[\leadsto \color{blue}{\frac{-2 \cdot c}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}} \]
    8. Taylor expanded in b around inf 64.0

      \[\leadsto \frac{-2 \cdot c}{\color{blue}{0.5 \cdot \frac{c \cdot \left(a \cdot {\left(\sqrt{-4}\right)}^{2}\right)}{b} + 2 \cdot b}} \]
    9. Simplified9.2

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

      [Start]64.0

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

      +-commutative [=>]64.0

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

      *-commutative [=>]64.0

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

      fma-def [=>]64.0

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

      associate-/l* [=>]64.0

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

      associate-*r/ [=>]64.0

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

      unpow2 [=>]64.0

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

      rem-square-sqrt [=>]9.2

      \[ \frac{-2 \cdot c}{\mathsf{fma}\left(b, 2, \frac{0.5 \cdot c}{\frac{b}{a \cdot \color{blue}{-4}}}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.8

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

Alternatives

Alternative 1
Error9.9
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{+130}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.36 \cdot 10^{-84}:\\ \;\;\;\;-0.5 \cdot \frac{b - \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
Alternative 2
Error9.8
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+129}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-84}:\\ \;\;\;\;-0.5 \cdot \frac{b - \sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -2}{\mathsf{fma}\left(b, 2, \frac{c \cdot 0.5}{\frac{b}{a \cdot -4}}\right)}\\ \end{array} \]
Alternative 3
Error13.4
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -9.5 \cdot 10^{-40}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 2.7 \cdot 10^{-85}:\\ \;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
Alternative 4
Error13.3
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -7.2 \cdot 10^{-44}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{-84}:\\ \;\;\;\;-0.5 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
Alternative 5
Error22.7
Cost580
\[\begin{array}{l} \mathbf{if}\;b \leq -1.05 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
Alternative 6
Error40.2
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq 1.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \]
Alternative 7
Error22.7
Cost388
\[\begin{array}{l} \mathbf{if}\;b \leq 1.65 \cdot 10^{-288}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
Alternative 8
Error56.8
Cost192
\[\frac{c}{b} \]

Error

Reproduce

herbie shell --seed 2023017 
(FPCore (a b c)
  :name "quadp (p42, positive)"
  :precision binary64

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

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