?

Average Accuracy: 47.4% → 85.0%
Time: 13.9s
Precision: binary64
Cost: 20552

?

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

\mathbf{elif}\;b_2 \leq 8.5 \cdot 10^{-73}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if b_2 < -9.9999999999999991e130

    1. Initial program 15.9%

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

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

      [Start]15.9

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

      +-commutative [=>]15.9

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

      unsub-neg [=>]15.9

      \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Taylor expanded in b_2 around -inf 96.4%

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

    if -9.9999999999999991e130 < b_2 < 8.4999999999999996e-73

    1. Initial program 81.0%

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

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

      [Start]81.0

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

      +-commutative [=>]81.0

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

      unsub-neg [=>]81.0

      \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Applied egg-rr81.0%

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

      [Start]81.0

      \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a} \]

      prod-diff [=>]81.0

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

      *-commutative [<=]81.0

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

      fma-def [<=]81.0

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

      associate-+l+ [=>]81.0

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

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

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

      fma-def [=>]81.0

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

      *-commutative [<=]81.0

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

      fma-udef [=>]81.0

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

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

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

      *-commutative [<=]81.0

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

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

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

      fma-def [=>]81.0

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

    if 8.4999999999999996e-73 < b_2

    1. Initial program 17.0%

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

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

      [Start]17.0

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

      +-commutative [=>]17.0

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

      unsub-neg [=>]17.0

      \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Applied egg-rr26.0%

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

      [Start]17.0

      \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a} \]

      clear-num [=>]16.9

      \[ \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}} \]

      inv-pow [=>]16.9

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

      sub-neg [=>]16.9

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

      add-sqr-sqrt [=>]14.2

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

      hypot-def [=>]26.0

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

      *-commutative [=>]26.0

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

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

      \[ {\left(\frac{a}{\mathsf{hypot}\left(b_2, \sqrt{\color{blue}{c \cdot \left(-a\right)}}\right) - b_2}\right)}^{-1} \]
    4. 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}} \]
    5. Simplified86.2%

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

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

      associate-*r* [=>]86.2

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

      metadata-eval [=>]86.2

      \[ \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.0%

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

Alternatives

Alternative 1
Accuracy85.1%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -3 \cdot 10^{+123}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.7 \cdot 10^{-71}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 2
Accuracy79.5%
Cost7176
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -9.4 \cdot 10^{-60}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 5.8 \cdot 10^{-73}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 3
Accuracy42.7%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 9.5 \cdot 10^{-233}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \end{array} \]
Alternative 4
Accuracy64.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 2.15 \cdot 10^{-232}:\\ \;\;\;\;\frac{-2}{\frac{a}{b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \end{array} \]
Alternative 5
Accuracy64.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 2.25 \cdot 10^{-232}:\\ \;\;\;\;\frac{-2}{\frac{a}{b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 6
Accuracy64.7%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.54 \cdot 10^{-232}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 7
Accuracy17.1%
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 2 \cdot 10^{-191}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 8
Accuracy12.3%
Cost64
\[0 \]

Error

Reproduce?

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