?

Average Accuracy: 42.4% → 77.1%
Time: 16.4s
Precision: binary64
Cost: 13704

?

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

\mathbf{elif}\;b_2 \leq 9.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

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


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if b_2 < -1.1000000000000001e127

    1. Initial program 10.6%

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

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

      [Start]10.6

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

      +-commutative [=>]10.6

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

      unsub-neg [=>]10.6

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

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

    if -1.1000000000000001e127 < b_2 < 9.1999999999999995e-58

    1. Initial program 81.5%

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

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

      [Start]81.5

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

      +-commutative [=>]81.5

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

      unsub-neg [=>]81.5

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

    if 9.1999999999999995e-58 < b_2

    1. Initial program 14.8%

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

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

      [Start]14.8

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

      +-commutative [=>]14.8

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

      unsub-neg [=>]14.8

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

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

      [Start]14.8

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

      clear-num [=>]14.8

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

      inv-pow [=>]14.8

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

      sub-neg [=>]14.8

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

      add-sqr-sqrt [=>]13.5

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

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

      *-commutative [=>]24.5

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

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

      \[ {\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}{\left(0.5 \cdot \frac{a}{b_2} + 2 \cdot \frac{b_2}{c \cdot {\left(\sqrt{-1}\right)}^{2}}\right)}}^{-1} \]
    5. Simplified86.1%

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

      [Start]0.0

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

      fma-def [=>]0.0

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

      associate-*r/ [=>]0.0

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

      *-commutative [=>]0.0

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

      unpow2 [=>]0.0

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

      rem-square-sqrt [=>]86.1

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

      times-frac [=>]86.1

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

      metadata-eval [=>]86.1

      \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \color{blue}{-2} \cdot \frac{b_2}{c}\right)\right)}^{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.1 \cdot 10^{+127}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 9.2 \cdot 10^{-58}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, -2 \cdot \frac{b_2}{c}\right)\right)}^{-1}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy77.4%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.35 \cdot 10^{+127}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.5 \cdot 10^{-57}:\\ \;\;\;\;\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
Accuracy72.7%
Cost7176
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -4.8 \cdot 10^{-78}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 4.6 \cdot 10^{-57}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(-a\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 3
Accuracy35.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a}\\ \end{array} \]
Alternative 4
Accuracy60.3%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 3.6 \cdot 10^{-292}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 5
Accuracy60.3%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 4.5 \cdot 10^{-291}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 6
Accuracy15.3%
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a}\\ \end{array} \]
Alternative 7
Accuracy11.0%
Cost192
\[\frac{0}{a} \]

Error

Reproduce?

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