Average Error: 34.9 → 10.1
Time: 10.6s
Precision: binary64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} \mathbf{if}\;b \leq -8.620998372327297 \cdot 10^{+152}:\\ \;\;\;\;\frac{2 \cdot \frac{b}{-3}}{a}\\ \mathbf{elif}\;b \leq 4.913578702369731 \cdot 10^{-99}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b \cdot -2}\\ \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
 (if (<= b -8.620998372327297e+152)
   (/ (* 2.0 (/ b -3.0)) a)
   (if (<= b 4.913578702369731e-99)
     (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
     (/ c (* b -2.0)))))
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 tmp;
	if (b <= -8.620998372327297e+152) {
		tmp = (2.0 * (b / -3.0)) / a;
	} else if (b <= 4.913578702369731e-99) {
		tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	} else {
		tmp = c / (b * -2.0);
	}
	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) :: tmp
    if (b <= (-8.620998372327297d+152)) then
        tmp = (2.0d0 * (b / (-3.0d0))) / a
    else if (b <= 4.913578702369731d-99) then
        tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
    else
        tmp = c / (b * (-2.0d0))
    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 tmp;
	if (b <= -8.620998372327297e+152) {
		tmp = (2.0 * (b / -3.0)) / a;
	} else if (b <= 4.913578702369731e-99) {
		tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	} else {
		tmp = c / (b * -2.0);
	}
	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):
	tmp = 0
	if b <= -8.620998372327297e+152:
		tmp = (2.0 * (b / -3.0)) / a
	elif b <= 4.913578702369731e-99:
		tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0)
	else:
		tmp = c / (b * -2.0)
	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)
	tmp = 0.0
	if (b <= -8.620998372327297e+152)
		tmp = Float64(Float64(2.0 * Float64(b / -3.0)) / a);
	elseif (b <= 4.913578702369731e-99)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(c / Float64(b * -2.0));
	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)
	tmp = 0.0;
	if (b <= -8.620998372327297e+152)
		tmp = (2.0 * (b / -3.0)) / a;
	elseif (b <= 4.913578702369731e-99)
		tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
	else
		tmp = c / (b * -2.0);
	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_] := If[LessEqual[b, -8.620998372327297e+152], N[(N[(2.0 * N[(b / -3.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 4.913578702369731e-99], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(c / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -8.620998372327297 \cdot 10^{+152}:\\
\;\;\;\;\frac{2 \cdot \frac{b}{-3}}{a}\\

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

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


\end{array}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -8.62099837232729742e152

    1. Initial program 63.3

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

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

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

      \[\leadsto \frac{\frac{3 \cdot \left(c \cdot a\right)}{\color{blue}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}}{3 \cdot a} \]
    5. Applied *-un-lft-identity_binary6464.0

      \[\leadsto \frac{\frac{3 \cdot \left(c \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)\right)}}}{3 \cdot a} \]
    6. Applied times-frac_binary6464.0

      \[\leadsto \frac{\color{blue}{\frac{3}{1} \cdot \frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}}{3 \cdot a} \]
    7. Applied times-frac_binary6464.0

      \[\leadsto \color{blue}{\frac{\frac{3}{1}}{3} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{a}} \]
    8. Simplified64.0

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{a} \]
    9. Simplified64.0

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}{a}} \]
    10. Taylor expanded in b around -inf 56.1

      \[\leadsto 1 \cdot \frac{\color{blue}{2 \cdot \frac{c \cdot \left(a \cdot b\right)}{{\left(\sqrt{-3 \cdot \left(c \cdot a\right)}\right)}^{2}}}}{a} \]
    11. Simplified3.1

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

    if -8.62099837232729742e152 < b < 4.9135787023697313e-99

    1. Initial program 12.2

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

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

    if 4.9135787023697313e-99 < b

    1. Initial program 52.9

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

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

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

      \[\leadsto \frac{\frac{3 \cdot \left(c \cdot a\right)}{\color{blue}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}}{3 \cdot a} \]
    5. Applied *-un-lft-identity_binary6433.9

      \[\leadsto \frac{\frac{3 \cdot \left(c \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)\right)}}}{3 \cdot a} \]
    6. Applied times-frac_binary6433.8

      \[\leadsto \frac{\color{blue}{\frac{3}{1} \cdot \frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}}{3 \cdot a} \]
    7. Applied times-frac_binary6433.8

      \[\leadsto \color{blue}{\frac{\frac{3}{1}}{3} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{a}} \]
    8. Simplified33.8

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{c \cdot \left(a \cdot -3\right)}, b\right)}}{a} \]
    9. Simplified33.8

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}{a}} \]
    10. Applied *-un-lft-identity_binary6433.8

      \[\leadsto 1 \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}{\color{blue}{1 \cdot a}} \]
    11. Applied *-un-lft-identity_binary6433.8

      \[\leadsto 1 \cdot \frac{\color{blue}{1 \cdot \frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}}{1 \cdot a} \]
    12. Applied times-frac_binary6433.8

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{1} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}{a}\right)} \]
    13. Simplified33.8

      \[\leadsto 1 \cdot \left(\color{blue}{1} \cdot \frac{\frac{c \cdot a}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}{a}\right) \]
    14. Simplified27.5

      \[\leadsto 1 \cdot \left(1 \cdot \color{blue}{\frac{c}{\left(-b\right) - \mathsf{hypot}\left(\sqrt{\left(c \cdot a\right) \cdot -3}, b\right)}}\right) \]
    15. Taylor expanded in b around inf 9.5

      \[\leadsto 1 \cdot \left(1 \cdot \frac{c}{\color{blue}{-2 \cdot b}}\right) \]
    16. Simplified9.5

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

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

Reproduce

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