?

Average Accuracy: 46.6% → 90.4%
Time: 19.0s
Precision: binary64
Cost: 7564

?

\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\ \mathbf{if}\;b_2 \leq -4 \cdot 10^{+152}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq -8.5 \cdot 10^{-292}:\\ \;\;\;\;\frac{t_0 - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 10^{+117}:\\ \;\;\;\;\frac{-c}{b_2 + t_0}\\ \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
 (let* ((t_0 (sqrt (- (* b_2 b_2) (* a c)))))
   (if (<= b_2 -4e+152)
     (/ (* b_2 -2.0) a)
     (if (<= b_2 -8.5e-292)
       (/ (- t_0 b_2) a)
       (if (<= b_2 1e+117) (/ (- c) (+ b_2 t_0)) (/ (* 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 t_0 = sqrt(((b_2 * b_2) - (a * c)));
	double tmp;
	if (b_2 <= -4e+152) {
		tmp = (b_2 * -2.0) / a;
	} else if (b_2 <= -8.5e-292) {
		tmp = (t_0 - b_2) / a;
	} else if (b_2 <= 1e+117) {
		tmp = -c / (b_2 + t_0);
	} else {
		tmp = (c * -0.5) / b_2;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((b_2 * b_2) - (a * c)))
    if (b_2 <= (-4d+152)) then
        tmp = (b_2 * (-2.0d0)) / a
    else if (b_2 <= (-8.5d-292)) then
        tmp = (t_0 - b_2) / a
    else if (b_2 <= 1d+117) then
        tmp = -c / (b_2 + t_0)
    else
        tmp = (c * (-0.5d0)) / b_2
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
public static double code(double a, double b_2, double c) {
	double t_0 = Math.sqrt(((b_2 * b_2) - (a * c)));
	double tmp;
	if (b_2 <= -4e+152) {
		tmp = (b_2 * -2.0) / a;
	} else if (b_2 <= -8.5e-292) {
		tmp = (t_0 - b_2) / a;
	} else if (b_2 <= 1e+117) {
		tmp = -c / (b_2 + t_0);
	} else {
		tmp = (c * -0.5) / b_2;
	}
	return tmp;
}
def code(a, b_2, c):
	return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
def code(a, b_2, c):
	t_0 = math.sqrt(((b_2 * b_2) - (a * c)))
	tmp = 0
	if b_2 <= -4e+152:
		tmp = (b_2 * -2.0) / a
	elif b_2 <= -8.5e-292:
		tmp = (t_0 - b_2) / a
	elif b_2 <= 1e+117:
		tmp = -c / (b_2 + t_0)
	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)
	t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))
	tmp = 0.0
	if (b_2 <= -4e+152)
		tmp = Float64(Float64(b_2 * -2.0) / a);
	elseif (b_2 <= -8.5e-292)
		tmp = Float64(Float64(t_0 - b_2) / a);
	elseif (b_2 <= 1e+117)
		tmp = Float64(Float64(-c) / Float64(b_2 + t_0));
	else
		tmp = Float64(Float64(c * -0.5) / b_2);
	end
	return tmp
end
function tmp = code(a, b_2, c)
	tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
end
function tmp_2 = code(a, b_2, c)
	t_0 = sqrt(((b_2 * b_2) - (a * c)));
	tmp = 0.0;
	if (b_2 <= -4e+152)
		tmp = (b_2 * -2.0) / a;
	elseif (b_2 <= -8.5e-292)
		tmp = (t_0 - b_2) / a;
	elseif (b_2 <= 1e+117)
		tmp = -c / (b_2 + t_0);
	else
		tmp = (c * -0.5) / b_2;
	end
	tmp_2 = 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_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -4e+152], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -8.5e-292], N[(N[(t$95$0 - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1e+117], N[((-c) / N[(b$95$2 + t$95$0), $MachinePrecision]), $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}
t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -4 \cdot 10^{+152}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\

\mathbf{elif}\;b_2 \leq -8.5 \cdot 10^{-292}:\\
\;\;\;\;\frac{t_0 - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 10^{+117}:\\
\;\;\;\;\frac{-c}{b_2 + t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 4 regimes
  2. if b_2 < -4.0000000000000002e152

    1. Initial program 0.8%

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

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

      [Start]0.8

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

      +-commutative [=>]0.8

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

      unsub-neg [=>]0.8

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    4. Simplified97.4%

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

      [Start]97.4

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

      *-commutative [=>]97.4

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

    if -4.0000000000000002e152 < b_2 < -8.50000000000000066e-292

    1. Initial program 87.4%

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

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

      [Start]87.4

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

      +-commutative [=>]87.4

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

      unsub-neg [=>]87.4

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

    if -8.50000000000000066e-292 < b_2 < 1.00000000000000005e117

    1. Initial program 49.7%

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

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

      [Start]49.7

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

      +-commutative [=>]49.7

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

      unsub-neg [=>]49.7

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

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

      [Start]49.7

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

      clear-num [=>]49.6

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

      inv-pow [=>]49.6

      \[ \color{blue}{{\left(\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\right)}^{-1}} \]
    4. Applied egg-rr49.6%

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

      [Start]49.6

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

      unpow-1 [=>]49.6

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

      associate-/r/ [=>]49.6

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

      sub-neg [=>]49.6

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

      flip-+ [=>]49.6

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

      associate-*r/ [=>]49.5

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

      add-sqr-sqrt [<=]49.6

      \[ \frac{\frac{1}{a} \cdot \left(\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} - \left(-b_2\right) \cdot \left(-b_2\right)\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)} \]
    5. Taylor expanded in a around 0 86.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)} \]
    6. Simplified86.9%

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

      [Start]86.9

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

      mul-1-neg [=>]86.9

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

    if 1.00000000000000005e117 < b_2

    1. Initial program 4.7%

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

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

      [Start]4.7

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

      +-commutative [=>]4.7

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

      unsub-neg [=>]4.7

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    4. Simplified96.8%

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

      [Start]96.8

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

      associate-*r/ [=>]96.8

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

      *-commutative [=>]96.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -4 \cdot 10^{+152}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq -8.5 \cdot 10^{-292}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 10^{+117}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy84.7%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.7 \cdot 10^{+153}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{elif}\;b_2 \leq 1.15 \cdot 10^{-80}:\\ \;\;\;\;\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
Accuracy77.8%
Cost7176
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -130000000:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.8 \cdot 10^{-81}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 3
Accuracy65.4%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 4.6 \cdot 10^{-260}:\\ \;\;\;\;b_2 \cdot \frac{-2}{a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{-0.5}{b_2}\\ \end{array} \]
Alternative 4
Accuracy65.1%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 2.2 \cdot 10^{-259}:\\ \;\;\;\;b_2 \cdot \frac{-2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\ \end{array} \]
Alternative 5
Accuracy65.2%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 9.8 \cdot 10^{-260}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{\frac{b_2}{c}}\\ \end{array} \]
Alternative 6
Accuracy65.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.95 \cdot 10^{-260}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]
Alternative 7
Accuracy29.4%
Cost320
\[b_2 \cdot \frac{-2}{a} \]
Alternative 8
Accuracy7.5%
Cost256
\[\frac{-b_2}{a} \]

Error

Reproduce?

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