?

Average Error: 34.1 → 13.4
Time: 12.8s
Precision: binary64
Cost: 36112

?

\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := -0.5 \cdot \frac{c}{b_2}\\ t_1 := \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-253}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 (* -0.5 (/ c b_2)))
        (t_1 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)))
   (if (<= t_1 (- INFINITY))
     t_0
     (if (<= t_1 -2e-253)
       t_1
       (if (<= t_1 0.0) t_0 (if (<= t_1 5e+306) t_1 t_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 t_0 = -0.5 * (c / b_2);
	double t_1 = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_0;
	} else if (t_1 <= -2e-253) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 5e+306) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
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 = -0.5 * (c / b_2);
	double t_1 = (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else if (t_1 <= -2e-253) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 5e+306) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	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 = -0.5 * (c / b_2)
	t_1 = (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
	tmp = 0
	if t_1 <= -math.inf:
		tmp = t_0
	elif t_1 <= -2e-253:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = t_0
	elif t_1 <= 5e+306:
		tmp = t_1
	else:
		tmp = t_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)
	t_0 = Float64(-0.5 * Float64(c / b_2))
	t_1 = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = t_0;
	elseif (t_1 <= -2e-253)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 5e+306)
		tmp = t_1;
	else
		tmp = t_0;
	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 = -0.5 * (c / b_2);
	t_1 = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = t_0;
	elseif (t_1 <= -2e-253)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 5e+306)
		tmp = t_1;
	else
		tmp = t_0;
	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[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, -2e-253], t$95$1, If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 5e+306], t$95$1, t$95$0]]]]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := -0.5 \cdot \frac{c}{b_2}\\
t_1 := \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq -2 \cdot 10^{-253}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -inf.0 or -2.0000000000000001e-253 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -0.0 or 4.99999999999999993e306 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a)

    1. Initial program 60.4

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

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

    if -inf.0 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -2.0000000000000001e-253 or -0.0 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < 4.99999999999999993e306

    1. Initial program 4.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \leq -\infty:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \leq -2 \cdot 10^{-253}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \leq 0:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \leq 5 \cdot 10^{+306}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]

Alternatives

Alternative 1
Error14.1
Cost7240
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -2.5 \cdot 10^{-149}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 4 \cdot 10^{-59}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]
Alternative 2
Error22.5
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.1 \cdot 10^{-237}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{a} \cdot b_2\\ \end{array} \]
Alternative 3
Error22.5
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -6.1 \cdot 10^{-238}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\frac{a}{b_2}}\\ \end{array} \]
Alternative 4
Error22.4
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.8 \cdot 10^{-238}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]
Alternative 5
Error39.6
Cost320
\[-0.5 \cdot \frac{c}{b_2} \]

Error

Reproduce?

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