?

Average Accuracy: 46.8% → 83.5%
Time: 24.2s
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} \mathbf{if}\;b \leq -7.2 \cdot 10^{+79}:\\ \;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{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
 (if (<= b -7.2e+79)
   (/ (/ (* b 2.0) -3.0) a)
   (if (<= b 3.8e-6)
     (/ (- (sqrt (+ (* b b) (* c (* -3.0 a)))) b) (* a 3.0))
     (/ (* c -0.5) 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 tmp;
	if (b <= -7.2e+79) {
		tmp = ((b * 2.0) / -3.0) / a;
	} else if (b <= 3.8e-6) {
		tmp = (sqrt(((b * b) + (c * (-3.0 * a)))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / 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) :: tmp
    if (b <= (-7.2d+79)) then
        tmp = ((b * 2.0d0) / (-3.0d0)) / a
    else if (b <= 3.8d-6) then
        tmp = (sqrt(((b * b) + (c * ((-3.0d0) * a)))) - b) / (a * 3.0d0)
    else
        tmp = (c * (-0.5d0)) / 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 tmp;
	if (b <= -7.2e+79) {
		tmp = ((b * 2.0) / -3.0) / a;
	} else if (b <= 3.8e-6) {
		tmp = (Math.sqrt(((b * b) + (c * (-3.0 * a)))) - b) / (a * 3.0);
	} else {
		tmp = (c * -0.5) / 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):
	tmp = 0
	if b <= -7.2e+79:
		tmp = ((b * 2.0) / -3.0) / a
	elif b <= 3.8e-6:
		tmp = (math.sqrt(((b * b) + (c * (-3.0 * a)))) - b) / (a * 3.0)
	else:
		tmp = (c * -0.5) / 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)
	tmp = 0.0
	if (b <= -7.2e+79)
		tmp = Float64(Float64(Float64(b * 2.0) / -3.0) / a);
	elseif (b <= 3.8e-6)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(c * Float64(-3.0 * a)))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(Float64(c * -0.5) / 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)
	tmp = 0.0;
	if (b <= -7.2e+79)
		tmp = ((b * 2.0) / -3.0) / a;
	elseif (b <= 3.8e-6)
		tmp = (sqrt(((b * b) + (c * (-3.0 * a)))) - b) / (a * 3.0);
	else
		tmp = (c * -0.5) / 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_] := If[LessEqual[b, -7.2e+79], N[(N[(N[(b * 2.0), $MachinePrecision] / -3.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3.8e-6], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $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 -7.2 \cdot 10^{+79}:\\
\;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{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 < -7.1999999999999999e79

    1. Initial program 32.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Applied egg-rr32.6%

      \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}{-3} \cdot \frac{1}{a}} \]
    3. Simplified32.7%

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

      [Start]32.6

      \[ \frac{b - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}{-3} \cdot \frac{1}{a} \]

      *-commutative [=>]32.6

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

      associate-*l/ [=>]32.7

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

      *-lft-identity [=>]32.7

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

      fma-def [<=]32.7

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

      +-commutative [<=]32.7

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

      fma-def [=>]32.7

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

      *-commutative [=>]32.7

      \[ \frac{\frac{b - \sqrt{\mathsf{fma}\left(-3, \color{blue}{c \cdot a}, b \cdot b\right)}}{-3}}{a} \]
    4. Taylor expanded in b around -inf 92.9%

      \[\leadsto \frac{\frac{\color{blue}{2 \cdot b}}{-3}}{a} \]
    5. Simplified92.9%

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

      [Start]92.9

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

      *-commutative [=>]92.9

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

    if -7.1999999999999999e79 < b < 3.8e-6

    1. Initial program 75.2%

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

    if 3.8e-6 < b

    1. Initial program 13.5%

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

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

      [Start]13.5

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

      remove-double-neg [<=]13.5

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

      sub-neg [<=]13.5

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

      div-sub [=>]12.1

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

      neg-mul-1 [=>]12.1

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

      associate-*l/ [<=]10.9

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

      distribute-frac-neg [=>]10.9

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

      fma-neg [=>]6.5

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

      /-rgt-identity [<=]6.5

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

      metadata-eval [<=]6.5

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

      associate-/l* [<=]6.5

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

      *-commutative [<=]6.5

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

      neg-mul-1 [<=]6.5

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

      fma-neg [<=]10.9

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

      neg-mul-1 [=>]10.9

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Applied egg-rr90.4%

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

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

Alternatives

Alternative 1
Accuracy83.4%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -6.2 \cdot 10^{+79}:\\ \;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\ \mathbf{elif}\;b \leq 3 \cdot 10^{-5}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(-3 \cdot c\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 2
Accuracy83.6%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -2.3 \cdot 10^{+107}:\\ \;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\ \mathbf{elif}\;b \leq 3.6 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{b - \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}{-3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 3
Accuracy78.8%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -6.6 \cdot 10^{-17}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 5.8 \cdot 10^{-58}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 4
Accuracy78.9%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -6.8 \cdot 10^{-23}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-57}:\\ \;\;\;\;\left(\sqrt{a \cdot \left(-3 \cdot c\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 5
Accuracy78.9%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-20}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 4 \cdot 10^{-57}:\\ \;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 6
Accuracy78.9%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{-19}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{-57}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(-3 \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 7
Accuracy64.0%
Cost580
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-171}:\\ \;\;\;\;\frac{\frac{b \cdot 2}{-3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 8
Accuracy42.1%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-171}:\\ \;\;\;\;\frac{b}{a} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 9
Accuracy63.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 3.1 \cdot 10^{-171}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 10
Accuracy63.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-171}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 11
Accuracy63.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-171}:\\ \;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 12
Accuracy63.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.2 \cdot 10^{-171}:\\ \;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 13
Accuracy37.4%
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

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