?

Average Error: 34.5 → 7.1
Time: 1.4min
Precision: binary64
Cost: 42576

?

\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := \frac{0.5 \cdot c}{\left|b_2\right|} - \frac{\left|b_2\right| + b_2}{a}\\ 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^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+236}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a}}{-a} - \frac{b_2}{a}\\ \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) (fabs b_2)) (/ (+ (fabs b_2) b_2) a)))
        (t_1 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)))
   (if (<= t_1 (- INFINITY))
     t_0
     (if (<= t_1 -2e-264)
       t_1
       (if (<= t_1 0.0)
         t_0
         (if (<= t_1 2e+236)
           (- (/ (sqrt (- (pow b_2 2.0) (* c a))) (- a)) (/ b_2 a))
           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) / fabs(b_2)) - ((fabs(b_2) + b_2) / a);
	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-264) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e+236) {
		tmp = (sqrt((pow(b_2, 2.0) - (c * a))) / -a) - (b_2 / a);
	} 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) / Math.abs(b_2)) - ((Math.abs(b_2) + b_2) / a);
	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-264) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e+236) {
		tmp = (Math.sqrt((Math.pow(b_2, 2.0) - (c * a))) / -a) - (b_2 / a);
	} 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) / math.fabs(b_2)) - ((math.fabs(b_2) + b_2) / a)
	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-264:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = t_0
	elif t_1 <= 2e+236:
		tmp = (math.sqrt((math.pow(b_2, 2.0) - (c * a))) / -a) - (b_2 / a)
	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(Float64(Float64(0.5 * c) / abs(b_2)) - Float64(Float64(abs(b_2) + b_2) / a))
	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-264)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e+236)
		tmp = Float64(Float64(sqrt(Float64((b_2 ^ 2.0) - Float64(c * a))) / Float64(-a)) - Float64(b_2 / a));
	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) / abs(b_2)) - ((abs(b_2) + b_2) / a);
	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-264)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e+236)
		tmp = (sqrt(((b_2 ^ 2.0) - (c * a))) / -a) - (b_2 / a);
	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[(N[(N[(0.5 * c), $MachinePrecision] / N[Abs[b$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Abs[b$95$2], $MachinePrecision] + b$95$2), $MachinePrecision] / a), $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-264], t$95$1, If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 2e+236], N[(N[(N[Sqrt[N[(N[Power[b$95$2, 2.0], $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-a)), $MachinePrecision] - N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := \frac{0.5 \cdot c}{\left|b_2\right|} - \frac{\left|b_2\right| + b_2}{a}\\
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^{-264}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+236}:\\
\;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a}}{-a} - \frac{b_2}{a}\\

\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 3 regimes
  2. if (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -inf.0 or -2e-264 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < 0.0 or 2.00000000000000011e236 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a)

    1. Initial program 58.7

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{\sqrt{{b_2}^{2}}} + -1 \cdot \frac{\sqrt{{b_2}^{2}} + b_2}{a}} \]
    3. Simplified9.2

      \[\leadsto \color{blue}{\frac{0.5 \cdot c}{\left|b_2\right|} - \frac{\left|b_2\right| + b_2}{a}} \]
      Proof

    if -inf.0 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -2e-264

    1. Initial program 4.3

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

    if 0.0 < (/.f64 (-.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < 2.00000000000000011e236

    1. Initial program 4.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{{b_2}^{2} - c \cdot a}}{-a} - \frac{b_2}{a}} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error7.1
Cost42448
\[\begin{array}{l} t_0 := \frac{0.5 \cdot c}{\left|b_2\right|} - \frac{\left|b_2\right| + b_2}{a}\\ 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^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+236}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error10.4
Cost7432
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-41}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 9.2 \cdot 10^{+51}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 3
Error14.1
Cost7112
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.85 \cdot 10^{-39}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.16 \cdot 10^{-24}:\\ \;\;\;\;\frac{-\sqrt{-c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 4
Error36.4
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.95 \cdot 10^{-234}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]
Alternative 5
Error22.6
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1.2 \cdot 10^{-234}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \end{array} \]
Alternative 6
Error59.3
Cost256
\[\frac{-b_2}{a} \]

Error

Reproduce?

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