Cubic critical, narrow range

Percentage Accurate: 55.4% → 91.3%
Time: 15.4s
Alternatives: 14
Speedup: 23.2×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\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 14 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: 55.4% 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: 91.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{a \cdot {b}^{7}}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma a (* c -3.0) (pow b 2.0))))
   (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
     (/ (/ (- (pow b 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
     (+
      (* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
      (+
       (* -0.5 (/ c b))
       (+
        (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))
        (/ (* -1.0546875 (pow (* a c) 4.0)) (* a (pow b 7.0)))))))))
double code(double a, double b, double c) {
	double t_0 = fma(a, (c * -3.0), pow(b, 2.0));
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
		tmp = ((pow(b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
	} else {
		tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + ((-1.0546875 * pow((a * c), 4.0)) / (a * pow(b, 7.0)))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(a, Float64(c * -3.0), (b ^ 2.0))
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15)
		tmp = Float64(Float64(Float64((b ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(Float64(-1.0546875 * (Float64(a * c) ^ 4.0)) / Float64(a * (b ^ 7.0))))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], -0.15], N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0546875 * N[Power[N[(a * c), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{a \cdot {b}^{7}}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994

    1. Initial program 84.2%

      \[\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 a around 0 84.3%

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

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

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      4. cancel-sign-sub-inv85.6%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      6. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. cancel-sign-sub-inv85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      8. fma-def85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}}}{3 \cdot a} \]
      9. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
    5. Applied egg-rr85.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{{b}^{2}} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      4. fma-udef85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \color{blue}{\left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      5. unpow285.6%

        \[\leadsto \frac{\frac{{b}^{2} - \left(\color{blue}{{b}^{2}} + -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      6. *-commutative85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \left({b}^{2} + \color{blue}{\left(a \cdot c\right) \cdot -3}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      7. associate-*r*85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \left({b}^{2} + \color{blue}{a \cdot \left(c \cdot -3\right)}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      8. +-commutative85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \color{blue}{\left(a \cdot \left(c \cdot -3\right) + {b}^{2}\right)}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      9. fma-def85.7%

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

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      11. unpow285.7%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{2}} + -3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      12. *-commutative85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{{b}^{2} + \color{blue}{\left(a \cdot c\right) \cdot -3}}}}{3 \cdot a} \]
      13. associate-*r*85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{{b}^{2} + \color{blue}{a \cdot \left(c \cdot -3\right)}}}}{3 \cdot a} \]
      14. +-commutative85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{a \cdot \left(c \cdot -3\right) + {b}^{2}}}}}{3 \cdot a} \]
      15. fma-def85.6%

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

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

    if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 54.0%

      \[\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 93.9%

      \[\leadsto \color{blue}{-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{5.0625 \cdot \left({a}^{4} \cdot {c}^{4}\right) + {\left(-1.125 \cdot \left({a}^{2} \cdot {c}^{2}\right)\right)}^{2}}{a \cdot {b}^{7}}\right)\right)} \]
    4. Taylor expanded in c around 0 93.9%

      \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{-0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}}\right)\right) \]
    5. Step-by-step derivation
      1. distribute-rgt-out93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{{c}^{4} \cdot \color{blue}{\left({a}^{4} \cdot \left(1.265625 + 5.0625\right)\right)}}{a \cdot {b}^{7}}\right)\right) \]
      2. associate-*r*93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{\color{blue}{\left({c}^{4} \cdot {a}^{4}\right) \cdot \left(1.265625 + 5.0625\right)}}{a \cdot {b}^{7}}\right)\right) \]
      3. *-commutative93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{\color{blue}{\left({a}^{4} \cdot {c}^{4}\right)} \cdot \left(1.265625 + 5.0625\right)}{a \cdot {b}^{7}}\right)\right) \]
      4. *-commutative93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \frac{\left({a}^{4} \cdot {c}^{4}\right) \cdot \left(1.265625 + 5.0625\right)}{\color{blue}{{b}^{7} \cdot a}}\right)\right) \]
      5. times-frac93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.16666666666666666 \cdot \color{blue}{\left(\frac{{a}^{4} \cdot {c}^{4}}{{b}^{7}} \cdot \frac{1.265625 + 5.0625}{a}\right)}\right)\right) \]
    6. Simplified93.9%

      \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{-0.16666666666666666 \cdot \left(\frac{{\left(a \cdot c\right)}^{4}}{{b}^{7}} \cdot \frac{6.328125}{a}\right)}\right)\right) \]
    7. Step-by-step derivation
      1. expm1-log1p-u93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.16666666666666666 \cdot \left(\frac{{\left(a \cdot c\right)}^{4}}{{b}^{7}} \cdot \frac{6.328125}{a}\right)\right)\right)}\right)\right) \]
      2. expm1-udef92.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\left(e^{\mathsf{log1p}\left(-0.16666666666666666 \cdot \left(\frac{{\left(a \cdot c\right)}^{4}}{{b}^{7}} \cdot \frac{6.328125}{a}\right)\right)} - 1\right)}\right)\right) \]
      3. frac-times92.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \left(e^{\mathsf{log1p}\left(-0.16666666666666666 \cdot \color{blue}{\frac{{\left(a \cdot c\right)}^{4} \cdot 6.328125}{{b}^{7} \cdot a}}\right)} - 1\right)\right)\right) \]
    8. Applied egg-rr92.9%

      \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\left(e^{\mathsf{log1p}\left(-0.16666666666666666 \cdot \frac{{\left(a \cdot c\right)}^{4} \cdot 6.328125}{{b}^{7} \cdot a}\right)} - 1\right)}\right)\right) \]
    9. Step-by-step derivation
      1. expm1-def93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.16666666666666666 \cdot \frac{{\left(a \cdot c\right)}^{4} \cdot 6.328125}{{b}^{7} \cdot a}\right)\right)}\right)\right) \]
      2. expm1-log1p93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{-0.16666666666666666 \cdot \frac{{\left(a \cdot c\right)}^{4} \cdot 6.328125}{{b}^{7} \cdot a}}\right)\right) \]
      3. associate-*r/93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\frac{-0.16666666666666666 \cdot \left({\left(a \cdot c\right)}^{4} \cdot 6.328125\right)}{{b}^{7} \cdot a}}\right)\right) \]
      4. *-commutative93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-0.16666666666666666 \cdot \color{blue}{\left(6.328125 \cdot {\left(a \cdot c\right)}^{4}\right)}}{{b}^{7} \cdot a}\right)\right) \]
      5. associate-*r*93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{\color{blue}{\left(-0.16666666666666666 \cdot 6.328125\right) \cdot {\left(a \cdot c\right)}^{4}}}{{b}^{7} \cdot a}\right)\right) \]
      6. metadata-eval93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{\color{blue}{-1.0546875} \cdot {\left(a \cdot c\right)}^{4}}{{b}^{7} \cdot a}\right)\right) \]
      7. *-commutative93.9%

        \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{\color{blue}{a \cdot {b}^{7}}}\right)\right) \]
    10. Simplified93.9%

      \[\leadsto -0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \color{blue}{\frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{a \cdot {b}^{7}}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{a \cdot {b}^{7}}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma a (* c -3.0) (pow b 2.0))))
   (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
     (/ (/ (- (pow b 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
     (+
      (* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
      (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))))))))
double code(double a, double b, double c) {
	double t_0 = fma(a, (c * -3.0), pow(b, 2.0));
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
		tmp = ((pow(b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
	} else {
		tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(a, Float64(c * -3.0), (b ^ 2.0))
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15)
		tmp = Float64(Float64(Float64((b ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], -0.15], N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994

    1. Initial program 84.2%

      \[\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 a around 0 84.3%

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

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

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      4. cancel-sign-sub-inv85.6%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      6. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. cancel-sign-sub-inv85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      8. fma-def85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}}}{3 \cdot a} \]
      9. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
    5. Applied egg-rr85.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{{b}^{2}} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      4. fma-udef85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \color{blue}{\left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      5. unpow285.6%

        \[\leadsto \frac{\frac{{b}^{2} - \left(\color{blue}{{b}^{2}} + -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      6. *-commutative85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \left({b}^{2} + \color{blue}{\left(a \cdot c\right) \cdot -3}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      7. associate-*r*85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \left({b}^{2} + \color{blue}{a \cdot \left(c \cdot -3\right)}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      8. +-commutative85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \color{blue}{\left(a \cdot \left(c \cdot -3\right) + {b}^{2}\right)}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      9. fma-def85.7%

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

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      11. unpow285.7%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{{b}^{2}} + -3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      12. *-commutative85.7%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{{b}^{2} + \color{blue}{\left(a \cdot c\right) \cdot -3}}}}{3 \cdot a} \]
      13. associate-*r*85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{{b}^{2} + \color{blue}{a \cdot \left(c \cdot -3\right)}}}}{3 \cdot a} \]
      14. +-commutative85.6%

        \[\leadsto \frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\color{blue}{a \cdot \left(c \cdot -3\right) + {b}^{2}}}}}{3 \cdot a} \]
      15. fma-def85.6%

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

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

    if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 54.0%

      \[\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 91.2%

      \[\leadsto \color{blue}{-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{b}^{2} - \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma b b (* -3.0 (* a c)))))
   (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
     (/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
     (+
      (* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
      (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))))))))
double code(double a, double b, double c) {
	double t_0 = fma(b, b, (-3.0 * (a * c)));
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
		tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
	} else {
		tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(b, b, Float64(-3.0 * Float64(a * c)))
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15)
		tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], -0.15], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994

    1. Initial program 84.2%

      \[\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 a around 0 84.3%

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

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

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      4. cancel-sign-sub-inv85.6%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      6. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. cancel-sign-sub-inv85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      8. fma-def85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}}}{3 \cdot a} \]
      9. metadata-eval85.1%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
    5. Applied egg-rr85.1%

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

    if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 54.0%

      \[\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 91.2%

      \[\leadsto \color{blue}{-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot -2}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma b b (* -3.0 (* a c)))))
   (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034)
     (/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
     (fma
      (* (* a (pow c 2.0)) (pow b -3.0))
      -0.375
      (log1p (expm1 (/ c (* b -2.0))))))))
double code(double a, double b, double c) {
	double t_0 = fma(b, b, (-3.0 * (a * c)));
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
		tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
	} else {
		tmp = fma(((a * pow(c, 2.0)) * pow(b, -3.0)), -0.375, log1p(expm1((c / (b * -2.0)))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(b, b, Float64(-3.0 * Float64(a * c)))
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0034)
		tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a));
	else
		tmp = fma(Float64(Float64(a * (c ^ 2.0)) * (b ^ -3.0)), -0.375, log1p(expm1(Float64(c / Float64(b * -2.0)))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], -0.0034], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision] * -0.375 + N[Log[1 + N[(Exp[N[(c / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot -2}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981

    1. Initial program 80.6%

      \[\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 a around 0 80.6%

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

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

        \[\leadsto \frac{\frac{\color{blue}{{\left(-b\right)}^{2}} - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      3. add-sqr-sqrt81.8%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      4. cancel-sign-sub-inv81.8%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      6. metadata-eval81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. cancel-sign-sub-inv81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      8. fma-def81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}}}{3 \cdot a} \]
      9. metadata-eval81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
    5. Applied egg-rr81.3%

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

    if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 48.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 88.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}} \]
    4. Step-by-step derivation
      1. +-commutative88.7%

        \[\leadsto \color{blue}{-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + -0.5 \cdot \frac{c}{b}} \]
      2. *-commutative88.7%

        \[\leadsto \color{blue}{\frac{a \cdot {c}^{2}}{{b}^{3}} \cdot -0.375} + -0.5 \cdot \frac{c}{b} \]
      3. fma-def88.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}, -0.375, -0.5 \cdot \frac{c}{b}\right)} \]
      4. div-inv88.7%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(a \cdot {c}^{2}\right) \cdot \frac{1}{{b}^{3}}}, -0.375, -0.5 \cdot \frac{c}{b}\right) \]
      5. pow-flip88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot \color{blue}{{b}^{\left(-3\right)}}, -0.375, -0.5 \cdot \frac{c}{b}\right) \]
      6. metadata-eval88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{\color{blue}{-3}}, -0.375, -0.5 \cdot \frac{c}{b}\right) \]
      7. associate-*r/88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \color{blue}{\frac{-0.5 \cdot c}{b}}\right) \]
      8. associate-*l/88.5%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \color{blue}{\frac{-0.5}{b} \cdot c}\right) \]
      9. *-commutative88.5%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \color{blue}{c \cdot \frac{-0.5}{b}}\right) \]
    5. Applied egg-rr88.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, c \cdot \frac{-0.5}{b}\right)} \]
    6. Step-by-step derivation
      1. log1p-expm1-u88.5%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(c \cdot \frac{-0.5}{b}\right)\right)}\right) \]
      2. clear-num88.5%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(c \cdot \color{blue}{\frac{1}{\frac{b}{-0.5}}}\right)\right)\right) \]
      3. un-div-inv88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{c}{\frac{b}{-0.5}}}\right)\right)\right) \]
      4. div-inv88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{\color{blue}{b \cdot \frac{1}{-0.5}}}\right)\right)\right) \]
      5. metadata-eval88.7%

        \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot \color{blue}{-2}}\right)\right)\right) \]
    7. Applied egg-rr88.7%

      \[\leadsto \mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot -2}\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot -2}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma b b (* -3.0 (* a c)))))
   (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034)
     (/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
     (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))))))
double code(double a, double b, double c) {
	double t_0 = fma(b, b, (-3.0 * (a * c)));
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
		tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
	} else {
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0)));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(b, b, Float64(-3.0 * Float64(a * c)))
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0034)
		tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], -0.0034], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981

    1. Initial program 80.6%

      \[\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 a around 0 80.6%

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

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

        \[\leadsto \frac{\frac{\color{blue}{{\left(-b\right)}^{2}} - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      3. add-sqr-sqrt81.8%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      4. cancel-sign-sub-inv81.8%

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

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      6. metadata-eval81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. cancel-sign-sub-inv81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{3 \cdot a} \]
      8. fma-def81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}}}{3 \cdot a} \]
      9. metadata-eval81.3%

        \[\leadsto \frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
    5. Applied egg-rr81.3%

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

    if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 48.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 88.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(3 \cdot a\right) \cdot c\\ t_1 := \sqrt{t_0}\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - t_0} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\sqrt{\left(b + t_1\right) \cdot \left(b - t_1\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* (* 3.0 a) c)) (t_1 (sqrt t_0)))
   (if (<= (/ (- (sqrt (- (* b b) t_0)) b) (* 3.0 a)) -0.0034)
     (/ (- (sqrt (* (+ b t_1) (- b t_1))) b) (* 3.0 a))
     (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))))))
double code(double a, double b, double c) {
	double t_0 = (3.0 * a) * c;
	double t_1 = sqrt(t_0);
	double tmp;
	if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034) {
		tmp = (sqrt(((b + t_1) * (b - t_1))) - b) / (3.0 * a);
	} else {
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (3.0d0 * a) * c
    t_1 = sqrt(t_0)
    if (((sqrt(((b * b) - t_0)) - b) / (3.0d0 * a)) <= (-0.0034d0)) then
        tmp = (sqrt(((b + t_1) * (b - t_1))) - b) / (3.0d0 * a)
    else
        tmp = ((-0.5d0) * (c / b)) + ((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = (3.0 * a) * c;
	double t_1 = Math.sqrt(t_0);
	double tmp;
	if (((Math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034) {
		tmp = (Math.sqrt(((b + t_1) * (b - t_1))) - b) / (3.0 * a);
	} else {
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0)));
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (3.0 * a) * c
	t_1 = math.sqrt(t_0)
	tmp = 0
	if ((math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034:
		tmp = (math.sqrt(((b + t_1) * (b - t_1))) - b) / (3.0 * a)
	else:
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0)))
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(3.0 * a) * c)
	t_1 = sqrt(t_0)
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - t_0)) - b) / Float64(3.0 * a)) <= -0.0034)
		tmp = Float64(Float64(sqrt(Float64(Float64(b + t_1) * Float64(b - t_1))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (3.0 * a) * c;
	t_1 = sqrt(t_0);
	tmp = 0.0;
	if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034)
		tmp = (sqrt(((b + t_1) * (b - t_1))) - b) / (3.0 * a);
	else
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.0034], N[(N[(N[Sqrt[N[(N[(b + t$95$1), $MachinePrecision] * N[(b - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(3 \cdot a\right) \cdot c\\
t_1 := \sqrt{t_0}\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t_0} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\sqrt{\left(b + t_1\right) \cdot \left(b - t_1\right)} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981

    1. Initial program 80.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt80.6%

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
    4. Applied egg-rr80.6%

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

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

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

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

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

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

    if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 48.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 88.7%

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

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

Alternative 7: 84.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034)
   (/ (- (sqrt (fma a (* c -3.0) (pow b 2.0))) b) (* 3.0 a))
   (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))))))
double code(double a, double b, double c) {
	double tmp;
	if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
		tmp = (sqrt(fma(a, (c * -3.0), pow(b, 2.0))) - b) / (3.0 * a);
	} else {
		tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0034)
		tmp = Float64(Float64(sqrt(fma(a, Float64(c * -3.0), (b ^ 2.0))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[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], -0.0034], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981

    1. Initial program 80.6%

      \[\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 a around 0 80.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. expm1-log1p-u59.5%

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

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)} - 1}}{3 \cdot a} \]
      3. neg-mul-156.2%

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\color{blue}{-1 \cdot b} + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)} - 1}{3 \cdot a} \]
      4. fma-def56.2%

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(-1, b, \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)}\right)} - 1}{3 \cdot a} \]
      5. cancel-sign-sub-inv56.2%

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\mathsf{fma}\left(-1, b, \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}\right)\right)} - 1}{3 \cdot a} \]
      6. fma-def56.1%

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

        \[\leadsto \frac{e^{\mathsf{log1p}\left(\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}\right)\right)} - 1}{3 \cdot a} \]
    5. Applied egg-rr56.1%

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

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}\right)\right)\right)}}{3 \cdot a} \]
      2. expm1-log1p80.6%

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

        \[\leadsto \frac{\color{blue}{-1 \cdot b + \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}}}{3 \cdot a} \]
      4. neg-mul-180.6%

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

        \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)} + \left(-b\right)}}{3 \cdot a} \]
      6. unsub-neg80.6%

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

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

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

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

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

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

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

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

    if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 48.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 88.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 84.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981

    1. Initial program 80.6%

      \[\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 a around 0 80.6%

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

    if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 48.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 88.7%

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

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

Alternative 9: 76.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -3.9999999999999998e-7

    1. Initial program 74.9%

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

    if -3.9999999999999998e-7 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 34.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 82.3%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/82.3%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified82.3%

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

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

Alternative 10: 73.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 155 \lor \neg \left(b \leq 718\right) \land b \leq 3000:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (or (<= b 155.0) (and (not (<= b 718.0)) (<= b 3000.0)))
   (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
   (/ (* c -0.5) b)))
double code(double a, double b, double c) {
	double tmp;
	if ((b <= 155.0) || (!(b <= 718.0) && (b <= 3000.0))) {
		tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
	} 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
    real(8) :: tmp
    if ((b <= 155.0d0) .or. (.not. (b <= 718.0d0)) .and. (b <= 3000.0d0)) then
        tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * a)
    else
        tmp = (c * (-0.5d0)) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if ((b <= 155.0) || (!(b <= 718.0) && (b <= 3000.0))) {
		tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if (b <= 155.0) or (not (b <= 718.0) and (b <= 3000.0)):
		tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a)
	else:
		tmp = (c * -0.5) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if ((b <= 155.0) || (!(b <= 718.0) && (b <= 3000.0)))
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if ((b <= 155.0) || (~((b <= 718.0)) && (b <= 3000.0)))
		tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
	else
		tmp = (c * -0.5) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[Or[LessEqual[b, 155.0], And[N[Not[LessEqual[b, 718.0]], $MachinePrecision], LessEqual[b, 3000.0]]], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 155 \lor \neg \left(b \leq 718\right) \land b \leq 3000:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 155 or 718 < b < 3e3

    1. Initial program 77.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 a around 0 77.7%

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

    if 155 < b < 718 or 3e3 < b

    1. Initial program 47.5%

      \[\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 72.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    4. Step-by-step derivation
      1. associate-*r/72.1%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    5. Simplified72.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 155 \lor \neg \left(b \leq 718\right) \land b \leq 3000:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 64.3% accurate, 23.2× speedup?

\[\begin{array}{l} \\ c \cdot \frac{-0.5}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
	return c * (-0.5 / b);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
	return c * (-0.5 / b);
}
def code(a, b, c):
	return c * (-0.5 / b)
function code(a, b, c)
	return Float64(c * Float64(-0.5 / b))
end
function tmp = code(a, b, c)
	tmp = c * (-0.5 / b);
end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c \cdot \frac{-0.5}{b}
\end{array}
Derivation
  1. Initial program 60.5%

    \[\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 60.3%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/60.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    2. associate-/l*60.3%

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
  5. Simplified60.3%

    \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
  6. Step-by-step derivation
    1. associate-/r/60.3%

      \[\leadsto \color{blue}{\frac{-0.5}{b} \cdot c} \]
  7. Applied egg-rr60.3%

    \[\leadsto \color{blue}{\frac{-0.5}{b} \cdot c} \]
  8. Final simplification60.3%

    \[\leadsto c \cdot \frac{-0.5}{b} \]
  9. Add Preprocessing

Alternative 12: 64.3% accurate, 23.2× speedup?

\[\begin{array}{l} \\ \frac{-0.5}{\frac{b}{c}} \end{array} \]
(FPCore (a b c) :precision binary64 (/ -0.5 (/ b c)))
double code(double a, double b, double c) {
	return -0.5 / (b / c);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-0.5d0) / (b / c)
end function
public static double code(double a, double b, double c) {
	return -0.5 / (b / c);
}
def code(a, b, c):
	return -0.5 / (b / c)
function code(a, b, c)
	return Float64(-0.5 / Float64(b / c))
end
function tmp = code(a, b, c)
	tmp = -0.5 / (b / c);
end
code[a_, b_, c_] := N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-0.5}{\frac{b}{c}}
\end{array}
Derivation
  1. Initial program 60.5%

    \[\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 60.3%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/60.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    2. associate-/l*60.3%

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
  5. Simplified60.3%

    \[\leadsto \color{blue}{\frac{-0.5}{\frac{b}{c}}} \]
  6. Final simplification60.3%

    \[\leadsto \frac{-0.5}{\frac{b}{c}} \]
  7. Add Preprocessing

Alternative 13: 64.4% accurate, 23.2× speedup?

\[\begin{array}{l} \\ \frac{c \cdot -0.5}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (/ (* c -0.5) b))
double code(double a, double b, double c) {
	return (c * -0.5) / b;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (c * (-0.5d0)) / b
end function
public static double code(double a, double b, double c) {
	return (c * -0.5) / b;
}
def code(a, b, c):
	return (c * -0.5) / b
function code(a, b, c)
	return Float64(Float64(c * -0.5) / b)
end
function tmp = code(a, b, c)
	tmp = (c * -0.5) / b;
end
code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}

\\
\frac{c \cdot -0.5}{b}
\end{array}
Derivation
  1. Initial program 60.5%

    \[\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 60.3%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/60.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
  5. Simplified60.3%

    \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
  6. Final simplification60.3%

    \[\leadsto \frac{c \cdot -0.5}{b} \]
  7. Add Preprocessing

Alternative 14: 3.2% accurate, 38.7× speedup?

\[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
	return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
	return 0.0 / a;
}
def code(a, b, c):
	return 0.0 / a
function code(a, b, c)
	return Float64(0.0 / a)
end
function tmp = code(a, b, c)
	tmp = 0.0 / a;
end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 60.5%

    \[\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 a around 0 60.5%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
  4. Step-by-step derivation
    1. add-log-exp55.8%

      \[\leadsto \frac{\color{blue}{\log \left(e^{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
    2. neg-mul-155.8%

      \[\leadsto \frac{\log \left(e^{\color{blue}{-1 \cdot b} + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}\right)}{3 \cdot a} \]
    3. fma-def55.8%

      \[\leadsto \frac{\log \left(e^{\color{blue}{\mathsf{fma}\left(-1, b, \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)}}\right)}{3 \cdot a} \]
    4. cancel-sign-sub-inv55.8%

      \[\leadsto \frac{\log \left(e^{\mathsf{fma}\left(-1, b, \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}\right)}\right)}{3 \cdot a} \]
    5. fma-def55.7%

      \[\leadsto \frac{\log \left(e^{\mathsf{fma}\left(-1, b, \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(a \cdot c\right)\right)}}\right)}\right)}{3 \cdot a} \]
    6. metadata-eval55.7%

      \[\leadsto \frac{\log \left(e^{\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}\right)}\right)}{3 \cdot a} \]
  5. Applied egg-rr55.7%

    \[\leadsto \frac{\color{blue}{\log \left(e^{\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)}\right)}\right)}}{3 \cdot a} \]
  6. Taylor expanded in a around 0 3.2%

    \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{b + -1 \cdot b}{a}} \]
  7. Step-by-step derivation
    1. associate-*r/3.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(b + -1 \cdot b\right)}{a}} \]
    2. distribute-rgt1-in3.2%

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

      \[\leadsto \frac{0.3333333333333333 \cdot \left(\color{blue}{0} \cdot b\right)}{a} \]
    4. mul0-lft3.2%

      \[\leadsto \frac{0.3333333333333333 \cdot \color{blue}{0}}{a} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  8. Simplified3.2%

    \[\leadsto \color{blue}{\frac{0}{a}} \]
  9. Final simplification3.2%

    \[\leadsto \frac{0}{a} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024017 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))