Cubic critical

Percentage Accurate: 60.8% → 82.8%
Time: 16.8s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
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]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 60.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
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
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
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]
\begin{array}{l}

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

Alternative 1: 82.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -24000000:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 6.5 \cdot 10^{+86}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -24000000.0)
   (/ (* b -2.0) (* 3.0 a))
   (if (<= b 6.5e+86)
     (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
     (* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -24000000.0) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= 6.5e+86) {
		tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= (-24000000.0d0)) then
        tmp = (b * (-2.0d0)) / (3.0d0 * a)
    else if (b <= 6.5d+86) then
        tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -24000000.0) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= 6.5e+86) {
		tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -24000000.0:
		tmp = (b * -2.0) / (3.0 * a)
	elif b <= 6.5e+86:
		tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -24000000.0)
		tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a));
	elseif (b <= 6.5e+86)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -24000000.0)
		tmp = (b * -2.0) / (3.0 * a);
	elseif (b <= 6.5e+86)
		tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -24000000.0], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+86], 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[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -24000000:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -2.4e7

    1. Initial program 64.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around -inf 94.2%

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. *-commutative94.2%

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

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

    if -2.4e7 < b < 6.49999999999999996e86

    1. Initial program 74.3%

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

    if 6.49999999999999996e86 < b

    1. Initial program 24.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 67.5%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*73.6%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/76.1%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified76.1%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative76.1%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative76.1%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac76.2%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative76.2%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval76.2%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr76.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -24000000:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq 6.5 \cdot 10^{+86}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 74.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-55}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-18}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3e-55)
   (* b (/ -0.6666666666666666 a))
   (if (<= b 8e-18)
     (* 0.3333333333333333 (/ (+ b (sqrt (* c (* a -3.0)))) a))
     (* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3e-55) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 8e-18) {
		tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= (-3d-55)) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else if (b <= 8d-18) then
        tmp = 0.3333333333333333d0 * ((b + sqrt((c * (a * (-3.0d0))))) / a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -3e-55) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 8e-18) {
		tmp = 0.3333333333333333 * ((b + Math.sqrt((c * (a * -3.0)))) / a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -3e-55:
		tmp = b * (-0.6666666666666666 / a)
	elif b <= 8e-18:
		tmp = 0.3333333333333333 * ((b + math.sqrt((c * (a * -3.0)))) / a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -3e-55)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	elseif (b <= 8e-18)
		tmp = Float64(0.3333333333333333 * Float64(Float64(b + sqrt(Float64(c * Float64(a * -3.0)))) / a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -3e-55)
		tmp = b * (-0.6666666666666666 / a);
	elseif (b <= 8e-18)
		tmp = 0.3333333333333333 * ((b + sqrt((c * (a * -3.0)))) / a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -3e-55], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-18], N[(0.3333333333333333 * N[(N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-55}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -3.00000000000000016e-55

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg57.6%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--57.6%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    5. Simplified57.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u38.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr38.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 91.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval91.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in91.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity91.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/91.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*91.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative91.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in91.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/91.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval91.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac91.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval91.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified91.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if -3.00000000000000016e-55 < b < 8.0000000000000006e-18

    1. Initial program 71.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0 63.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.2%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-un-lft-identity63.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{c \cdot \left(a \cdot -3\right)}\right)}}{3 \cdot a} \]
      2. times-frac63.2%

        \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\left(-b\right) + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}} \]
      3. metadata-eval63.2%

        \[\leadsto \color{blue}{0.3333333333333333} \cdot \frac{\left(-b\right) + \sqrt{c \cdot \left(a \cdot -3\right)}}{a} \]
      4. +-commutative63.2%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} + \left(-b\right)}}{a} \]
      5. add-sqr-sqrt35.5%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} + \color{blue}{\sqrt{-b} \cdot \sqrt{-b}}}{a} \]
      6. sqrt-unprod62.9%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} + \color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}}{a} \]
      7. sqr-neg62.9%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} + \sqrt{\color{blue}{b \cdot b}}}{a} \]
      8. sqrt-unprod28.1%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} + \color{blue}{\sqrt{b} \cdot \sqrt{b}}}{a} \]
      9. add-sqr-sqrt62.1%

        \[\leadsto 0.3333333333333333 \cdot \frac{\sqrt{c \cdot \left(a \cdot -3\right)} + \color{blue}{b}}{a} \]
    7. Applied egg-rr62.1%

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

    if 8.0000000000000006e-18 < b

    1. Initial program 39.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 61.6%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*65.7%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/67.4%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified67.4%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative67.4%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative67.4%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac67.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative67.5%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval67.5%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr67.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{-55}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-18}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{b + \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.1 \cdot 10^{-57}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.1e-57)
   (* b (/ -0.6666666666666666 a))
   (if (<= b 7.6e-20)
     (/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
     (* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.1e-57) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 7.6e-20) {
		tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= (-2.1d-57)) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else if (b <= 7.6d-20) then
        tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (3.0d0 * a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.1e-57) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 7.6e-20) {
		tmp = (Math.sqrt((a * (c * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2.1e-57:
		tmp = b * (-0.6666666666666666 / a)
	elif b <= 7.6e-20:
		tmp = (math.sqrt((a * (c * -3.0))) - b) / (3.0 * a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.1e-57)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	elseif (b <= 7.6e-20)
		tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -2.1e-57)
		tmp = b * (-0.6666666666666666 / a);
	elseif (b <= 7.6e-20)
		tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-57], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-20], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-57}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -2.0999999999999999e-57

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg57.6%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--57.6%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    5. Simplified57.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u38.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr38.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 91.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval91.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in91.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity91.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/91.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*91.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative91.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in91.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/91.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval91.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac91.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval91.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified91.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if -2.0999999999999999e-57 < b < 7.5999999999999995e-20

    1. Initial program 71.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0 63.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.2%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. +-commutative63.2%

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

        \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} - b}}{3 \cdot a} \]
    7. Applied egg-rr63.2%

      \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} - b}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. associate-*r*63.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(c \cdot a\right) \cdot -3}} - b}{3 \cdot a} \]
      2. *-commutative63.2%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot c\right)} \cdot -3} - b}{3 \cdot a} \]
      3. rem-square-sqrt0.0%

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

        \[\leadsto \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{{\left(\sqrt{-3}\right)}^{2}}} - b}{3 \cdot a} \]
      5. associate-*r*0.0%

        \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(c \cdot {\left(\sqrt{-3}\right)}^{2}\right)}} - b}{3 \cdot a} \]
      6. unpow20.0%

        \[\leadsto \frac{\sqrt{a \cdot \left(c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}\right)} - b}{3 \cdot a} \]
      7. rem-square-sqrt63.1%

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

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

    if 7.5999999999999995e-20 < b

    1. Initial program 39.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 61.6%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*65.7%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/67.4%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified67.4%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative67.4%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative67.4%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac67.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative67.5%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval67.5%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr67.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.1 \cdot 10^{-57}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-54}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 5.3 \cdot 10^{-23}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -6.5e-54)
   (* b (/ -0.6666666666666666 a))
   (if (<= b 5.3e-23)
     (/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
     (* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -6.5e-54) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 5.3e-23) {
		tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= (-6.5d-54)) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else if (b <= 5.3d-23) then
        tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -6.5e-54) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 5.3e-23) {
		tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -6.5e-54:
		tmp = b * (-0.6666666666666666 / a)
	elif b <= 5.3e-23:
		tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -6.5e-54)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	elseif (b <= 5.3e-23)
		tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -6.5e-54)
		tmp = b * (-0.6666666666666666 / a);
	elseif (b <= 5.3e-23)
		tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-54], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.3e-23], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-54}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -6.49999999999999991e-54

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg57.6%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--57.6%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    5. Simplified57.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u38.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr38.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 91.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval91.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in91.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity91.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/91.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*91.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative91.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in91.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/91.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval91.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac91.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval91.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified91.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if -6.49999999999999991e-54 < b < 5.30000000000000042e-23

    1. Initial program 71.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0 63.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-*r*63.2%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. +-commutative63.2%

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

        \[\leadsto \frac{\color{blue}{\sqrt{c \cdot \left(a \cdot -3\right)} - b}}{3 \cdot a} \]
    7. Applied egg-rr63.2%

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

    if 5.30000000000000042e-23 < b

    1. Initial program 39.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 61.6%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*65.7%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/67.4%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified67.4%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative67.4%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative67.4%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac67.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative67.5%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval67.5%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr67.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.5 \cdot 10^{-54}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 5.3 \cdot 10^{-23}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 60.2% accurate, 4.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+86}:\\ \;\;\;\;\frac{\left(b + -1.5 \cdot \frac{a \cdot c}{b}\right) - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5e-310)
   (* b (/ -0.6666666666666666 a))
   (if (<= b 1.8e+86)
     (/ (- (+ b (* -1.5 (/ (* a c) b))) b) (* 3.0 a))
     (* (/ (* c (/ a b)) a) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 1.8e+86) {
		tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= (-5d-310)) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else if (b <= 1.8d+86) then
        tmp = ((b + ((-1.5d0) * ((a * c) / b))) - b) / (3.0d0 * a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = b * (-0.6666666666666666 / a);
	} else if (b <= 1.8e+86) {
		tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5e-310:
		tmp = b * (-0.6666666666666666 / a)
	elif b <= 1.8e+86:
		tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5e-310)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	elseif (b <= 1.8e+86)
		tmp = Float64(Float64(Float64(b + Float64(-1.5 * Float64(Float64(a * c) / b))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5e-310)
		tmp = b * (-0.6666666666666666 / a);
	elseif (b <= 1.8e+86)
		tmp = ((b + (-1.5 * ((a * c) / b))) - b) / (3.0 * a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+86], N[(N[(N[(b + N[(-1.5 * N[(N[(a * c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

\mathbf{elif}\;b \leq 1.8 \cdot 10^{+86}:\\
\;\;\;\;\frac{\left(b + -1.5 \cdot \frac{a \cdot c}{b}\right) - b}{3 \cdot a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -4.999999999999985e-310

    1. Initial program 72.6%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg65.3%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--65.3%

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u46.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr46.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 66.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval66.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in66.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity66.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/66.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*66.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative66.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in66.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/66.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval66.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac66.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval66.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified66.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if -4.999999999999985e-310 < b < 1.80000000000000003e86

    1. Initial program 68.1%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 33.1%

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

    if 1.80000000000000003e86 < b

    1. Initial program 24.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 67.5%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*73.6%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/76.1%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified76.1%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative76.1%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative76.1%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac76.2%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative76.2%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval76.2%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr76.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+86}:\\ \;\;\;\;\frac{\left(b + -1.5 \cdot \frac{a \cdot c}{b}\right) - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 60.0% accurate, 8.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 2e-309)
   (* b (/ -0.6666666666666666 a))
   (* (/ (* c (/ a b)) a) -0.5)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 2e-309) {
		tmp = b * (-0.6666666666666666 / a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
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 <= 2d-309) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else
        tmp = ((c * (a / b)) / a) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= 2e-309) {
		tmp = b * (-0.6666666666666666 / a);
	} else {
		tmp = ((c * (a / b)) / a) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 2e-309:
		tmp = b * (-0.6666666666666666 / a)
	else:
		tmp = ((c * (a / b)) / a) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 2e-309)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	else
		tmp = Float64(Float64(Float64(c * Float64(a / b)) / a) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 2e-309)
		tmp = b * (-0.6666666666666666 / a);
	else
		tmp = ((c * (a / b)) / a) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 2e-309], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.9999999999999988e-309

    1. Initial program 72.6%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg65.3%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--65.3%

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u46.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr46.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 66.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval66.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in66.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity66.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/66.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*66.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative66.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in66.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/66.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval66.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac66.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval66.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified66.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if 1.9999999999999988e-309 < b

    1. Initial program 48.3%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 45.5%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. associate-/l*48.5%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{3 \cdot a} \]
      2. associate-/r/49.6%

        \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    5. Simplified49.6%

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \left(\frac{a}{b} \cdot c\right)}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. *-commutative49.6%

        \[\leadsto \frac{\color{blue}{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}}{3 \cdot a} \]
      2. *-commutative49.6%

        \[\leadsto \frac{\left(\frac{a}{b} \cdot c\right) \cdot -1.5}{\color{blue}{a \cdot 3}} \]
      3. times-frac49.6%

        \[\leadsto \color{blue}{\frac{\frac{a}{b} \cdot c}{a} \cdot \frac{-1.5}{3}} \]
      4. *-commutative49.6%

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{b}}}{a} \cdot \frac{-1.5}{3} \]
      5. metadata-eval49.6%

        \[\leadsto \frac{c \cdot \frac{a}{b}}{a} \cdot \color{blue}{-0.5} \]
    7. Applied egg-rr49.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 2 \cdot 10^{-309}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{a}{b}}{a} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 25.8% accurate, 11.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq 2.85 \cdot 10^{+25}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c) :precision binary64 (if (<= a 2.85e+25) 0.0 (* -0.5 (/ c b))))
double code(double a, double b, double c) {
	double tmp;
	if (a <= 2.85e+25) {
		tmp = 0.0;
	} 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
    real(8) :: tmp
    if (a <= 2.85d+25) then
        tmp = 0.0d0
    else
        tmp = (-0.5d0) * (c / b)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (a <= 2.85e+25) {
		tmp = 0.0;
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if a <= 2.85e+25:
		tmp = 0.0
	else:
		tmp = -0.5 * (c / b)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (a <= 2.85e+25)
		tmp = 0.0;
	else
		tmp = Float64(-0.5 * Float64(c / b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (a <= 2.85e+25)
		tmp = 0.0;
	else
		tmp = -0.5 * (c / b);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[a, 2.85e+25], 0.0, N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.85 \cdot 10^{+25}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2.8499999999999998e25

    1. Initial program 66.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Applied egg-rr15.1%

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

      \[\leadsto \color{blue}{0.6666666666666666 \cdot \frac{b}{a}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u1.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)\right)} \]
      2. expm1-udef3.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
    6. Applied egg-rr3.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
    7. Taylor expanded in b around 0 30.2%

      \[\leadsto \color{blue}{1} - 1 \]

    if 2.8499999999999998e25 < a

    1. Initial program 39.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 24.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 2.85 \cdot 10^{+25}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 56.0% accurate, 11.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5e-310) (* b (/ -0.6666666666666666 a)) 0.0))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = b * (-0.6666666666666666 / a);
	} else {
		tmp = 0.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
    real(8) :: tmp
    if (b <= (-5d-310)) then
        tmp = b * ((-0.6666666666666666d0) / a)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -5e-310) {
		tmp = b * (-0.6666666666666666 / a);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5e-310:
		tmp = b * (-0.6666666666666666 / a)
	else:
		tmp = 0.0
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5e-310)
		tmp = Float64(b * Float64(-0.6666666666666666 / a));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5e-310)
		tmp = b * (-0.6666666666666666 / a);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -4.999999999999985e-310

    1. Initial program 72.6%

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

      \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} + \left(-b \cdot \frac{0.3333333333333333}{a}\right)} \]
    4. Step-by-step derivation
      1. sub-neg65.3%

        \[\leadsto \color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) \cdot \frac{0.3333333333333333}{a} - b \cdot \frac{0.3333333333333333}{a}} \]
      2. distribute-rgt-out--65.3%

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u46.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    7. Applied egg-rr46.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.3333333333333333}{a}\right)\right)} \cdot \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right) - b\right) \]
    8. Taylor expanded in b around -inf 66.9%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    9. Step-by-step derivation
      1. metadata-eval66.9%

        \[\leadsto \color{blue}{\left(-0.6666666666666666\right)} \cdot \frac{b}{a} \]
      2. distribute-lft-neg-in66.9%

        \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
      3. *-lft-identity66.9%

        \[\leadsto -0.6666666666666666 \cdot \frac{\color{blue}{1 \cdot b}}{a} \]
      4. associate-*l/66.8%

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot b\right)} \]
      5. associate-*r*66.8%

        \[\leadsto -\color{blue}{\left(0.6666666666666666 \cdot \frac{1}{a}\right) \cdot b} \]
      6. *-commutative66.8%

        \[\leadsto -\color{blue}{b \cdot \left(0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      7. distribute-rgt-neg-in66.8%

        \[\leadsto \color{blue}{b \cdot \left(-0.6666666666666666 \cdot \frac{1}{a}\right)} \]
      8. associate-*r/66.9%

        \[\leadsto b \cdot \left(-\color{blue}{\frac{0.6666666666666666 \cdot 1}{a}}\right) \]
      9. metadata-eval66.9%

        \[\leadsto b \cdot \left(-\frac{\color{blue}{0.6666666666666666}}{a}\right) \]
      10. distribute-neg-frac66.9%

        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
      11. metadata-eval66.9%

        \[\leadsto b \cdot \frac{\color{blue}{-0.6666666666666666}}{a} \]
    10. Simplified66.9%

      \[\leadsto \color{blue}{b \cdot \frac{-0.6666666666666666}{a}} \]

    if -4.999999999999985e-310 < b

    1. Initial program 48.3%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Applied egg-rr19.8%

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

      \[\leadsto \color{blue}{0.6666666666666666 \cdot \frac{b}{a}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u2.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)\right)} \]
      2. expm1-udef6.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
    6. Applied egg-rr6.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
    7. Taylor expanded in b around 0 47.0%

      \[\leadsto \color{blue}{1} - 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\ \;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 23.7% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 60.3%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Add Preprocessing
  3. Applied egg-rr17.7%

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

    \[\leadsto \color{blue}{0.6666666666666666 \cdot \frac{b}{a}} \]
  5. Step-by-step derivation
    1. expm1-log1p-u2.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)\right)} \]
    2. expm1-udef4.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
  6. Applied egg-rr4.0%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.6666666666666666 \cdot \frac{b}{a}\right)} - 1} \]
  7. Taylor expanded in b around 0 25.1%

    \[\leadsto \color{blue}{1} - 1 \]
  8. Final simplification25.1%

    \[\leadsto 0 \]
  9. Add Preprocessing

Reproduce

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