?

Average Error: 34.1 → 10.1
Time: 12.9s
Precision: binary64
Cost: 7624

?

\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := \frac{b \cdot -2}{3 \cdot a}\\ \mathbf{if}\;b \leq -6 \cdot 10^{+152}:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot \frac{1}{t_0}\right)\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (* b -2.0) (* 3.0 a))))
   (if (<= b -6e+152)
     (* t_0 (* t_0 (/ 1.0 t_0)))
     (if (<= b 9.2e-51)
       (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
       (* -0.5 (/ c b))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
	double t_0 = (b * -2.0) / (3.0 * a);
	double tmp;
	if (b <= -6e+152) {
		tmp = t_0 * (t_0 * (1.0 / t_0));
	} else if (b <= 9.2e-51) {
		tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (b * (-2.0d0)) / (3.0d0 * a)
    if (b <= (-6d+152)) then
        tmp = t_0 * (t_0 * (1.0d0 / t_0))
    else if (b <= 9.2d-51) then
        tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
    else
        tmp = (-0.5d0) * (c / b)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
public static double code(double a, double b, double c) {
	double t_0 = (b * -2.0) / (3.0 * a);
	double tmp;
	if (b <= -6e+152) {
		tmp = t_0 * (t_0 * (1.0 / t_0));
	} else if (b <= 9.2e-51) {
		tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c):
	t_0 = (b * -2.0) / (3.0 * a)
	tmp = 0
	if b <= -6e+152:
		tmp = t_0 * (t_0 * (1.0 / t_0))
	elif b <= 9.2e-51:
		tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)
	else:
		tmp = -0.5 * (c / b)
	return tmp
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function code(a, b, c)
	t_0 = Float64(Float64(b * -2.0) / Float64(3.0 * a))
	tmp = 0.0
	if (b <= -6e+152)
		tmp = Float64(t_0 * Float64(t_0 * Float64(1.0 / t_0)));
	elseif (b <= 9.2e-51)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(-0.5 * Float64(c / b));
	end
	return tmp
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
function tmp_2 = code(a, b, c)
	t_0 = (b * -2.0) / (3.0 * a);
	tmp = 0.0;
	if (b <= -6e+152)
		tmp = t_0 * (t_0 * (1.0 / t_0));
	elseif (b <= 9.2e-51)
		tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	else
		tmp = -0.5 * (c / b);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -6e+152], N[(t$95$0 * N[(t$95$0 * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2e-51], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := \frac{b \cdot -2}{3 \cdot a}\\
\mathbf{if}\;b \leq -6 \cdot 10^{+152}:\\
\;\;\;\;t_0 \cdot \left(t_0 \cdot \frac{1}{t_0}\right)\\

\mathbf{elif}\;b \leq 9.2 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\

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


\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 b < -5.99999999999999981e152

    1. Initial program 63.2

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

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

      [Start]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-97 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-108 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-85 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]63.2

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]63.2

      \[ \frac{\sqrt{b \cdot b - 3 \cdot \color{blue}{\left(a \cdot c\right)}} - b}{3 \cdot a} \]
    3. Taylor expanded in b around -inf 3.4

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Simplified3.4

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

      [Start]3.4

      \[ \frac{-2 \cdot b}{3 \cdot a} \]

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]3.4

      \[ \frac{\color{blue}{b \cdot -2}}{3 \cdot a} \]
    5. Applied egg-rr3.5

      \[\leadsto \color{blue}{\frac{b \cdot -2}{3 \cdot a} \cdot \left(\frac{b \cdot -2}{3 \cdot a} \cdot \frac{1}{\frac{b \cdot -2}{3 \cdot a}}\right)} \]

    if -5.99999999999999981e152 < b < 9.20000000000000007e-51

    1. Initial program 13.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified13.1

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

      [Start]13.1

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]13.1

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

      rational_best_oopsla_all_46_json_45_simplify-97 [=>]13.1

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

      rational_best_oopsla_all_46_json_45_simplify-108 [=>]13.1

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]13.1

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

      rational_best_oopsla_all_46_json_45_simplify-85 [=>]13.1

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

    if 9.20000000000000007e-51 < b

    1. Initial program 54.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified54.4

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

      [Start]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-97 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-108 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-85 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]54.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]54.4

      \[ \frac{\sqrt{b \cdot b - 3 \cdot \color{blue}{\left(a \cdot c\right)}} - b}{3 \cdot a} \]
    3. Taylor expanded in b around inf 8.0

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6 \cdot 10^{+152}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a} \cdot \left(\frac{b \cdot -2}{3 \cdot a} \cdot \frac{1}{\frac{b \cdot -2}{3 \cdot a}}\right)\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternatives

Alternative 1
Error10.1
Cost7624
\[\begin{array}{l} t_0 := \frac{b \cdot -2}{3 \cdot a}\\ \mathbf{if}\;b \leq -1.3 \cdot 10^{+152}:\\ \;\;\;\;t_0 \cdot \left(t_0 \cdot \frac{1}{t_0}\right)\\ \mathbf{elif}\;b \leq 4.8 \cdot 10^{-52}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 2
Error13.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -2.15 \cdot 10^{-116}:\\ \;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 3.5 \cdot 10^{-50}:\\ \;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 3
Error13.7
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -2.6 \cdot 10^{-116}:\\ \;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 5.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 4
Error13.7
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -3.6 \cdot 10^{-116}:\\ \;\;\;\;\frac{b}{a} \cdot -0.6666666666666666 + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 4.9 \cdot 10^{-52}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 5
Error23.0
Cost580
\[\begin{array}{l} \mathbf{if}\;b \leq 1.02 \cdot 10^{-214}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 6
Error36.9
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 1.35 \cdot 10^{-214}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 7
Error23.0
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 1.1 \cdot 10^{-214}:\\ \;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 8
Error40.0
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))