?

Average Accuracy: 48.4% → 83.9%
Time: 13.4s
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 -3.3 \cdot 10^{+104}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)} - 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 -3.3e+104)
   (* -2.0 (/ b_2 a))
   (if (<= b_2 1.6e-110)
     (/ (- (sqrt (+ (fma b_2 b_2 (* c (- a))) (fma a (- c) (* 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 <= -3.3e+104) {
		tmp = -2.0 * (b_2 / a);
	} else if (b_2 <= 1.6e-110) {
		tmp = (sqrt((fma(b_2, b_2, (c * -a)) + fma(a, -c, (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 <= -3.3e+104)
		tmp = Float64(-2.0 * Float64(b_2 / a));
	elseif (b_2 <= 1.6e-110)
		tmp = Float64(Float64(sqrt(Float64(fma(b_2, b_2, Float64(c * Float64(-a))) + fma(a, Float64(-c), 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, -3.3e+104], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.6e-110], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2 + N[(c * (-a)), $MachinePrecision]), $MachinePrecision] + N[(a * (-c) + N[(a * c), $MachinePrecision]), $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 -3.3 \cdot 10^{+104}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)} - 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 < -3.29999999999999985e104

    1. Initial program 28.7%

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

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

      [Start]28.7

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

      +-commutative [=>]28.7

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

      unsub-neg [=>]28.7

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

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

    if -3.29999999999999985e104 < b_2 < 1.60000000000000014e-110

    1. Initial program 81.6%

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

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

      [Start]81.6

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

      +-commutative [=>]81.6

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

      unsub-neg [=>]81.6

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

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

      [Start]81.6

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

      prod-diff [=>]81.6

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

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

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

      *-commutative [<=]81.6

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

      fma-udef [=>]81.6

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

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

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

      *-commutative [<=]81.6

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

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

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

      fma-def [=>]81.6

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

    if 1.60000000000000014e-110 < b_2

    1. Initial program 20.6%

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

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

      [Start]20.6

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

      +-commutative [=>]20.6

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

      unsub-neg [=>]20.6

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

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

      [Start]20.6

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

      clear-num [=>]20.6

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

      inv-pow [=>]20.6

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

      sub-neg [=>]20.6

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

      add-sqr-sqrt [=>]17.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 [=>]28.2

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

      *-commutative [=>]28.2

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

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

      \[ {\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. Simplified82.2%

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

      [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 [=>]82.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -3.3 \cdot 10^{+104}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)} - 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
Accuracy83.9%
Cost13704
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -3.1 \cdot 10^{+104}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\ \;\;\;\;\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} \]
Alternative 2
Accuracy84.0%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -3.3 \cdot 10^{+104}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.2 \cdot 10^{-114}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 3
Accuracy78.8%
Cost7176
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -8.5 \cdot 10^{-53}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(-a\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 4
Accuracy64.0%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 5.3 \cdot 10^{-297}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 5
Accuracy29.0%
Cost320
\[-2 \cdot \frac{b_2}{a} \]

Error

Reproduce?

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