?

Average Error: 34.5 → 6.6
Time: 15.5s
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 - c \cdot a}\\ \mathbf{if}\;b_2 \leq -1.05 \cdot 10^{+154}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.05 \cdot 10^{-174}:\\ \;\;\;\;\frac{-c}{b_2 - t_0}\\ \mathbf{elif}\;b_2 \leq 1.75 \cdot 10^{+144}:\\ \;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \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) (* c a)))))
   (if (<= b_2 -1.05e+154)
     (* -0.5 (/ c b_2))
     (if (<= b_2 2.05e-174)
       (/ (- c) (- b_2 t_0))
       (if (<= b_2 1.75e+144)
         (/ (- (- b_2) t_0) a)
         (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)))))))
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) - (c * a)));
	double tmp;
	if (b_2 <= -1.05e+154) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 2.05e-174) {
		tmp = -c / (b_2 - t_0);
	} else if (b_2 <= 1.75e+144) {
		tmp = (-b_2 - t_0) / a;
	} else {
		tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
	}
	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) - (c * a)))
    if (b_2 <= (-1.05d+154)) then
        tmp = (-0.5d0) * (c / b_2)
    else if (b_2 <= 2.05d-174) then
        tmp = -c / (b_2 - t_0)
    else if (b_2 <= 1.75d+144) then
        tmp = (-b_2 - t_0) / a
    else
        tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
    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) - (c * a)));
	double tmp;
	if (b_2 <= -1.05e+154) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 2.05e-174) {
		tmp = -c / (b_2 - t_0);
	} else if (b_2 <= 1.75e+144) {
		tmp = (-b_2 - t_0) / a;
	} else {
		tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
	}
	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) - (c * a)))
	tmp = 0
	if b_2 <= -1.05e+154:
		tmp = -0.5 * (c / b_2)
	elif b_2 <= 2.05e-174:
		tmp = -c / (b_2 - t_0)
	elif b_2 <= 1.75e+144:
		tmp = (-b_2 - t_0) / a
	else:
		tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5)
	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(c * a)))
	tmp = 0.0
	if (b_2 <= -1.05e+154)
		tmp = Float64(-0.5 * Float64(c / b_2));
	elseif (b_2 <= 2.05e-174)
		tmp = Float64(Float64(-c) / Float64(b_2 - t_0));
	elseif (b_2 <= 1.75e+144)
		tmp = Float64(Float64(Float64(-b_2) - t_0) / a);
	else
		tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5));
	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) - (c * a)));
	tmp = 0.0;
	if (b_2 <= -1.05e+154)
		tmp = -0.5 * (c / b_2);
	elseif (b_2 <= 2.05e-174)
		tmp = -c / (b_2 - t_0);
	elseif (b_2 <= 1.75e+144)
		tmp = (-b_2 - t_0) / a;
	else
		tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
	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[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -1.05e+154], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.05e-174], N[((-c) / N[(b$95$2 - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.75e+144], N[(N[((-b$95$2) - t$95$0), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $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 - c \cdot a}\\
\mathbf{if}\;b_2 \leq -1.05 \cdot 10^{+154}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 2.05 \cdot 10^{-174}:\\
\;\;\;\;\frac{-c}{b_2 - t_0}\\

\mathbf{elif}\;b_2 \leq 1.75 \cdot 10^{+144}:\\
\;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\

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


\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 < -1.04999999999999997e154

    1. Initial program 64.0

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

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

    if -1.04999999999999997e154 < b_2 < 2.05e-174

    1. Initial program 31.6

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

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

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

      [Start]31.7

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

      *-commutative [=>]31.7

      \[ \left(b_2 + \sqrt{b_2 \cdot b_2 - \color{blue}{c \cdot a}}\right) \cdot \frac{-1}{a} \]
    4. Applied egg-rr31.7

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

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{b_2 - \sqrt{b_2 \cdot b_2 - c \cdot a}} \]
    6. Simplified9.8

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

      [Start]9.8

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

      mul-1-neg [=>]9.8

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

    if 2.05e-174 < b_2 < 1.7499999999999999e144

    1. Initial program 6.7

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

    if 1.7499999999999999e144 < b_2

    1. Initial program 60.1

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

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.05 \cdot 10^{+154}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.05 \cdot 10^{-174}:\\ \;\;\;\;\frac{-c}{b_2 - \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{elif}\;b_2 \leq 1.75 \cdot 10^{+144}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array} \]

Alternatives

Alternative 1
Error10.0
Cost7432
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -9.8 \cdot 10^{+153}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.3 \cdot 10^{-57}:\\ \;\;\;\;\frac{-c}{b_2 - \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array} \]
Alternative 2
Error13.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -3.9 \cdot 10^{-62}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 4.2 \cdot 10^{-57}:\\ \;\;\;\;\frac{\left(-b_2\right) - {\left(c \cdot \left(-a\right)\right)}^{0.5}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array} \]
Alternative 3
Error13.4
Cost7240
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -7.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.5 \cdot 10^{-59}:\\ \;\;\;\;\frac{-c}{b_2 - \sqrt{c \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array} \]
Alternative 4
Error13.5
Cost7240
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.02 \cdot 10^{-60}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 4 \cdot 10^{-57}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\ \end{array} \]
Alternative 5
Error36.4
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.4 \cdot 10^{-243}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b_2}{a}\\ \end{array} \]
Alternative 6
Error22.9
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -4.4 \cdot 10^{-238}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;b_2 \cdot \frac{-2}{a}\\ \end{array} \]
Alternative 7
Error22.9
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.25 \cdot 10^{-237}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;b_2 \cdot \frac{-2}{a}\\ \end{array} \]
Alternative 8
Error22.8
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.45 \cdot 10^{-243}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]
Alternative 9
Error53.5
Cost388
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1 \cdot 10^{-300}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;-\frac{b_2}{a}\\ \end{array} \]
Alternative 10
Error56.5
Cost64
\[0 \]

Error

Reproduce?

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