?

Average Error: 34.4 → 10.3
Time: 23.9s
Precision: binary64
Cost: 7761

?

\[\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 -1.06 \cdot 10^{+153}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-138}:\\ \;\;\;\;\frac{t_0 - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 3.8 \cdot 10^{-16} \lor \neg \left(b_2 \leq 0.00019\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{a} - \frac{b_2}{a}\\ \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 -1.06e+153)
     (* -2.0 (/ b_2 a))
     (if (<= b_2 2.3e-138)
       (/ (- t_0 b_2) a)
       (if (or (<= b_2 3.8e-16) (not (<= b_2 0.00019)))
         (* -0.5 (/ c b_2))
         (- (/ t_0 a) (/ b_2 a)))))))
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 <= -1.06e+153) {
		tmp = -2.0 * (b_2 / a);
	} else if (b_2 <= 2.3e-138) {
		tmp = (t_0 - b_2) / a;
	} else if ((b_2 <= 3.8e-16) || !(b_2 <= 0.00019)) {
		tmp = -0.5 * (c / b_2);
	} else {
		tmp = (t_0 / a) - (b_2 / a);
	}
	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 <= (-1.06d+153)) then
        tmp = (-2.0d0) * (b_2 / a)
    else if (b_2 <= 2.3d-138) then
        tmp = (t_0 - b_2) / a
    else if ((b_2 <= 3.8d-16) .or. (.not. (b_2 <= 0.00019d0))) then
        tmp = (-0.5d0) * (c / b_2)
    else
        tmp = (t_0 / a) - (b_2 / a)
    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 <= -1.06e+153) {
		tmp = -2.0 * (b_2 / a);
	} else if (b_2 <= 2.3e-138) {
		tmp = (t_0 - b_2) / a;
	} else if ((b_2 <= 3.8e-16) || !(b_2 <= 0.00019)) {
		tmp = -0.5 * (c / b_2);
	} else {
		tmp = (t_0 / a) - (b_2 / a);
	}
	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 <= -1.06e+153:
		tmp = -2.0 * (b_2 / a)
	elif b_2 <= 2.3e-138:
		tmp = (t_0 - b_2) / a
	elif (b_2 <= 3.8e-16) or not (b_2 <= 0.00019):
		tmp = -0.5 * (c / b_2)
	else:
		tmp = (t_0 / a) - (b_2 / a)
	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 <= -1.06e+153)
		tmp = Float64(-2.0 * Float64(b_2 / a));
	elseif (b_2 <= 2.3e-138)
		tmp = Float64(Float64(t_0 - b_2) / a);
	elseif ((b_2 <= 3.8e-16) || !(b_2 <= 0.00019))
		tmp = Float64(-0.5 * Float64(c / b_2));
	else
		tmp = Float64(Float64(t_0 / a) - Float64(b_2 / a));
	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 <= -1.06e+153)
		tmp = -2.0 * (b_2 / a);
	elseif (b_2 <= 2.3e-138)
		tmp = (t_0 - b_2) / a;
	elseif ((b_2 <= 3.8e-16) || ~((b_2 <= 0.00019)))
		tmp = -0.5 * (c / b_2);
	else
		tmp = (t_0 / a) - (b_2 / a);
	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, -1.06e+153], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.3e-138], N[(N[(t$95$0 - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[Or[LessEqual[b$95$2, 3.8e-16], N[Not[LessEqual[b$95$2, 0.00019]], $MachinePrecision]], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / a), $MachinePrecision] - N[(b$95$2 / a), $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 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -1.06 \cdot 10^{+153}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

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

\mathbf{elif}\;b_2 \leq 3.8 \cdot 10^{-16} \lor \neg \left(b_2 \leq 0.00019\right):\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{a} - \frac{b_2}{a}\\


\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.05999999999999995e153

    1. Initial program 63.7

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

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

      [Start]63.7

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

      +-commutative [=>]63.7

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

      unsub-neg [=>]63.7

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

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

    if -1.05999999999999995e153 < b_2 < 2.2999999999999999e-138

    1. Initial program 10.6

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

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

      [Start]10.6

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

      +-commutative [=>]10.6

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

      unsub-neg [=>]10.6

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

    if 2.2999999999999999e-138 < b_2 < 3.80000000000000012e-16 or 1.9000000000000001e-4 < b_2

    1. Initial program 51.2

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

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

      [Start]51.2

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

      +-commutative [=>]51.2

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

      unsub-neg [=>]51.2

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

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

    if 3.80000000000000012e-16 < b_2 < 1.9000000000000001e-4

    1. Initial program 45.3

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

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

      [Start]45.3

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

      +-commutative [=>]45.3

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

      unsub-neg [=>]45.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.06 \cdot 10^{+153}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-138}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 3.8 \cdot 10^{-16} \lor \neg \left(b_2 \leq 0.00019\right):\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error8.7
Cost7820
\[\begin{array}{l} t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\ \mathbf{if}\;b_2 \leq -1 \cdot 10^{+152}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.26 \cdot 10^{-192}:\\ \;\;\;\;\frac{t_0 - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.75 \cdot 10^{+75}:\\ \;\;\;\;\frac{\frac{a \cdot \left(-c\right)}{b_2 + t_0}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 2
Error10.3
Cost7633
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -1 \cdot 10^{+152}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-138} \lor \neg \left(b_2 \leq 2.5 \cdot 10^{-16}\right) \land b_2 \leq 0.00017:\\ \;\;\;\;\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
Error13.6
Cost7441
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -4.8 \cdot 10^{-85}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.1 \cdot 10^{-138} \lor \neg \left(b_2 \leq 3 \cdot 10^{-16}\right) \land b_2 \leq 0.000175:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 4
Error13.9
Cost7313
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -2.8 \cdot 10^{-80}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-138} \lor \neg \left(b_2 \leq 3.7 \cdot 10^{-16}\right) \land b_2 \leq 0.0013:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 5
Error22.2
Cost452
\[\begin{array}{l} \mathbf{if}\;b_2 \leq 1.5 \cdot 10^{-214}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
Alternative 6
Error44.7
Cost320
\[-2 \cdot \frac{b_2}{a} \]
Alternative 7
Error59.2
Cost256
\[\frac{-b_2}{a} \]

Error

Reproduce?

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