?

Average Accuracy: 47.2% → 84.4%
Time: 16.9s
Precision: binary64
Cost: 14408

?

\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.05 \cdot 10^{-35}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 5 \cdot 10^{+121}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{b_2 \cdot -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
 (if (<= b_2 -1.05e-35)
   (/ (* -0.5 c) b_2)
   (if (<= b_2 5e+121)
     (/
      (-
       (- b_2)
       (sqrt (+ (- (* b_2 b_2) (* c a)) (* 2.0 (fma a (- c) (* c a))))))
      a)
     (/ (* b_2 -2.0) 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 tmp;
	if (b_2 <= -1.05e-35) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 5e+121) {
		tmp = (-b_2 - sqrt((((b_2 * b_2) - (c * a)) + (2.0 * fma(a, -c, (c * a)))))) / a;
	} else {
		tmp = (b_2 * -2.0) / 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)
	tmp = 0.0
	if (b_2 <= -1.05e-35)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	elseif (b_2 <= 5e+121)
		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(Float64(b_2 * -2.0) / 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_] := If[LessEqual[b$95$2, -1.05e-35], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 5e+121], 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[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $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.05 \cdot 10^{-35}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

\mathbf{elif}\;b_2 \leq 5 \cdot 10^{+121}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if b_2 < -1.05e-35

    1. Initial program 14.6%

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

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

      [Start]14.6

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

      sub-neg [=>]14.6

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

      +-commutative [=>]14.6

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

      add-sqr-sqrt [=>]11.7

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

      hypot-def [=>]24.6

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

      *-commutative [=>]24.6

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

      distribute-rgt-neg-in [=>]24.6

      \[ \frac{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{\color{blue}{c \cdot \left(-a\right)}}, b_2\right)}{a} \]
    3. Taylor expanded in b_2 around -inf 0.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{c \cdot {\left(\sqrt{-1}\right)}^{2}}{b_2}} \]
    4. Simplified89.7%

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

      [Start]0.0

      \[ 0.5 \cdot \frac{c \cdot {\left(\sqrt{-1}\right)}^{2}}{b_2} \]

      associate-*r/ [=>]0.0

      \[ \color{blue}{\frac{0.5 \cdot \left(c \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{b_2}} \]

      *-commutative [=>]0.0

      \[ \frac{0.5 \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot c\right)}}{b_2} \]

      unpow2 [=>]0.0

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

      rem-square-sqrt [=>]89.7

      \[ \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]

      associate-*r* [=>]89.7

      \[ \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]

      metadata-eval [=>]89.7

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

    if -1.05e-35 < b_2 < 5.00000000000000007e121

    1. Initial program 77.9%

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

      \[\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} \]
      Proof

      [Start]77.9

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

      prod-diff [=>]77.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[ \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. Simplified77.9%

      \[\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} \]
      Proof

      [Start]77.9

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

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

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

      \[ \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 5.00000000000000007e121 < b_2

    1. Initial program 17.5%

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    3. Simplified95.0%

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
      Proof

      [Start]95.0

      \[ \frac{-2 \cdot b_2}{a} \]

      *-commutative [=>]95.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.05 \cdot 10^{-35}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 5 \cdot 10^{+121}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy84.5%
Cost7432
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -4.2 \cdot 10^{-38}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.9 \cdot 10^{+125}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]
Alternative 2
Accuracy79.2%
Cost7240
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-37}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 7.5 \cdot 10^{-39}:\\ \;\;\;\;\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 3
Accuracy78.7%
Cost7112
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-39}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.9 \cdot 10^{-36}:\\ \;\;\;\;\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 4
Accuracy43.2%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -9.5 \cdot 10^{-251}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]
Alternative 5
Accuracy43.2%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -2.25 \cdot 10^{-247}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]
Alternative 6
Accuracy64.7%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.12 \cdot 10^{-253}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]
Alternative 7
Accuracy16.9%
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-301}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]
Alternative 8
Accuracy12.1%
Cost64
\[0 \]

Error

Reproduce?

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