Cubic critical

Percentage Accurate: 52.7% → 85.1%
Time: 8.5s
Alternatives: 7
Speedup: 2.2×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 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: 52.7% 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: 85.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{\frac{b}{-1.5}}{a}\\ \mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3.5e+91)
   (/ (/ b -1.5) a)
   (if (<= b 9e-101)
     (/ (- (sqrt (fma (* a -3.0) c (* b b))) b) (* a 3.0))
     (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.5e+91) {
		tmp = (b / -1.5) / a;
	} else if (b <= 9e-101) {
		tmp = (sqrt(fma((a * -3.0), c, (b * b))) - b) / (a * 3.0);
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -3.5e+91)
		tmp = Float64(Float64(b / -1.5) / a);
	elseif (b <= 9e-101)
		tmp = Float64(Float64(sqrt(fma(Float64(a * -3.0), c, Float64(b * b))) - b) / Float64(a * 3.0));
	else
		tmp = Float64(-0.5 * Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -3.5e+91], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9e-101], N[(N[(N[Sqrt[N[(N[(a * -3.0), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{\frac{b}{-1.5}}{a}\\

\mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a \cdot -3, c, b \cdot b\right)} - b}{a \cdot 3}\\

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


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

    1. Initial program 52.9%

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

      \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
      2. lower-/.f6498.0

        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{b}{a}} \]
    5. Applied rewrites98.0%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    6. Step-by-step derivation
      1. Applied rewrites97.8%

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

          \[\leadsto \frac{b}{\color{blue}{a \cdot -1.5}} \]
        2. Step-by-step derivation
          1. Applied rewrites98.0%

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

          if -3.50000000000000001e91 < b < 8.9999999999999997e-101

          1. Initial program 81.3%

            \[\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. Applied rewrites81.1%

              \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}} \]
            2. Step-by-step derivation
              1. lift-fma.f64N/A

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

                \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c\right)} + b \cdot b} - b}{a \cdot 3} \]
              3. lift-*.f64N/A

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

                \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot -3\right) \cdot c} + b \cdot b} - b}{a \cdot 3} \]
              5. *-commutativeN/A

                \[\leadsto \frac{\sqrt{\color{blue}{\left(-3 \cdot a\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
              6. metadata-evalN/A

                \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right)} \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
              7. distribute-lft-neg-inN/A

                \[\leadsto \frac{\sqrt{\color{blue}{\left(\mathsf{neg}\left(3 \cdot a\right)\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
              8. lift-*.f64N/A

                \[\leadsto \frac{\sqrt{\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right)\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
              9. lower-fma.f64N/A

                \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(3 \cdot a\right), c, b \cdot b\right)}} - b}{a \cdot 3} \]
              10. lift-*.f64N/A

                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right), c, b \cdot b\right)} - b}{a \cdot 3} \]
              11. distribute-lft-neg-inN/A

                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right) \cdot a}, c, b \cdot b\right)} - b}{a \cdot 3} \]
              12. metadata-evalN/A

                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{-3} \cdot a, c, b \cdot b\right)} - b}{a \cdot 3} \]
              13. *-commutativeN/A

                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{a \cdot -3}, c, b \cdot b\right)} - b}{a \cdot 3} \]
              14. lower-*.f6481.3

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

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

            if 8.9999999999999997e-101 < b

            1. Initial program 17.4%

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

              \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
              2. lower-/.f6487.5

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

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

          Alternative 2: 85.0% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{\frac{b}{-1.5}}{a}\\ \mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -3\right) \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
          (FPCore (a b c)
           :precision binary64
           (if (<= b -3.5e+91)
             (/ (/ b -1.5) a)
             (if (<= b 9e-101)
               (/ (- (sqrt (fma b b (* (* c -3.0) a))) b) (* a 3.0))
               (* -0.5 (/ c b)))))
          double code(double a, double b, double c) {
          	double tmp;
          	if (b <= -3.5e+91) {
          		tmp = (b / -1.5) / a;
          	} else if (b <= 9e-101) {
          		tmp = (sqrt(fma(b, b, ((c * -3.0) * a))) - b) / (a * 3.0);
          	} else {
          		tmp = -0.5 * (c / b);
          	}
          	return tmp;
          }
          
          function code(a, b, c)
          	tmp = 0.0
          	if (b <= -3.5e+91)
          		tmp = Float64(Float64(b / -1.5) / a);
          	elseif (b <= 9e-101)
          		tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(c * -3.0) * a))) - b) / Float64(a * 3.0));
          	else
          		tmp = Float64(-0.5 * Float64(c / b));
          	end
          	return tmp
          end
          
          code[a_, b_, c_] := If[LessEqual[b, -3.5e+91], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9e-101], N[(N[(N[Sqrt[N[(b * b + N[(N[(c * -3.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;b \leq -3.5 \cdot 10^{+91}:\\
          \;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
          
          \mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\
          \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot -3\right) \cdot a\right)} - b}{a \cdot 3}\\
          
          \mathbf{else}:\\
          \;\;\;\;-0.5 \cdot \frac{c}{b}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if b < -3.50000000000000001e91

            1. Initial program 52.9%

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

              \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
              2. lower-/.f6498.0

                \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{b}{a}} \]
            5. Applied rewrites98.0%

              \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
            6. Step-by-step derivation
              1. Applied rewrites97.8%

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

                  \[\leadsto \frac{b}{\color{blue}{a \cdot -1.5}} \]
                2. Step-by-step derivation
                  1. Applied rewrites98.0%

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

                  if -3.50000000000000001e91 < b < 8.9999999999999997e-101

                  1. Initial program 81.3%

                    \[\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. Applied rewrites81.1%

                      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}} \]
                    2. Step-by-step derivation
                      1. lift-fma.f64N/A

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

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

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

                        \[\leadsto \frac{\sqrt{\color{blue}{c \cdot \left(-3 \cdot a\right)} + b \cdot b} - b}{a \cdot 3} \]
                      5. metadata-evalN/A

                        \[\leadsto \frac{\sqrt{c \cdot \left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right)} \cdot a\right) + b \cdot b} - b}{a \cdot 3} \]
                      6. distribute-lft-neg-inN/A

                        \[\leadsto \frac{\sqrt{c \cdot \color{blue}{\left(\mathsf{neg}\left(3 \cdot a\right)\right)} + b \cdot b} - b}{a \cdot 3} \]
                      7. lift-*.f64N/A

                        \[\leadsto \frac{\sqrt{c \cdot \left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right)\right) + b \cdot b} - b}{a \cdot 3} \]
                      8. *-commutativeN/A

                        \[\leadsto \frac{\sqrt{\color{blue}{\left(\mathsf{neg}\left(3 \cdot a\right)\right) \cdot c} + b \cdot b} - b}{a \cdot 3} \]
                      9. lift-*.f64N/A

                        \[\leadsto \frac{\sqrt{\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right)\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                      10. distribute-lft-neg-inN/A

                        \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(3\right)\right) \cdot a\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
                      11. metadata-evalN/A

                        \[\leadsto \frac{\sqrt{\left(\color{blue}{-3} \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                      12. lift-*.f64N/A

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

                        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(-3 \cdot a\right) \cdot c}} - b}{a \cdot 3} \]
                      14. lift-*.f64N/A

                        \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b} + \left(-3 \cdot a\right) \cdot c} - b}{a \cdot 3} \]
                      15. lower-fma.f64N/A

                        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)}} - b}{a \cdot 3} \]
                      16. lift-*.f64N/A

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-3 \cdot a\right)} \cdot c\right)} - b}{a \cdot 3} \]
                      17. associate-*l*N/A

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3 \cdot \left(a \cdot c\right)}\right)} - b}{a \cdot 3} \]
                      18. *-commutativeN/A

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \color{blue}{\left(c \cdot a\right)}\right)} - b}{a \cdot 3} \]
                      19. associate-*l*N/A

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-3 \cdot c\right) \cdot a}\right)} - b}{a \cdot 3} \]
                      20. lift-*.f64N/A

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

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-3 \cdot c\right) \cdot a}\right)} - b}{a \cdot 3} \]
                      22. lift-*.f64N/A

                        \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-3 \cdot c\right)} \cdot a\right)} - b}{a \cdot 3} \]
                      23. *-commutativeN/A

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

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

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

                    if 8.9999999999999997e-101 < b

                    1. Initial program 17.4%

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

                      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                    4. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                      2. lower-/.f6487.5

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

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

                  Alternative 3: 84.8% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -7 \cdot 10^{+64}:\\ \;\;\;\;\frac{\frac{b}{-1.5}}{a}\\ \mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
                  (FPCore (a b c)
                   :precision binary64
                   (if (<= b -7e+64)
                     (/ (/ b -1.5) a)
                     (if (<= b 9e-101)
                       (* (/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) a) 0.3333333333333333)
                       (* -0.5 (/ c b)))))
                  double code(double a, double b, double c) {
                  	double tmp;
                  	if (b <= -7e+64) {
                  		tmp = (b / -1.5) / a;
                  	} else if (b <= 9e-101) {
                  		tmp = ((sqrt(fma((-3.0 * c), a, (b * b))) - b) / a) * 0.3333333333333333;
                  	} else {
                  		tmp = -0.5 * (c / b);
                  	}
                  	return tmp;
                  }
                  
                  function code(a, b, c)
                  	tmp = 0.0
                  	if (b <= -7e+64)
                  		tmp = Float64(Float64(b / -1.5) / a);
                  	elseif (b <= 9e-101)
                  		tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / a) * 0.3333333333333333);
                  	else
                  		tmp = Float64(-0.5 * Float64(c / b));
                  	end
                  	return tmp
                  end
                  
                  code[a_, b_, c_] := If[LessEqual[b, -7e+64], N[(N[(b / -1.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 9e-101], N[(N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;b \leq -7 \cdot 10^{+64}:\\
                  \;\;\;\;\frac{\frac{b}{-1.5}}{a}\\
                  
                  \mathbf{elif}\;b \leq 9 \cdot 10^{-101}:\\
                  \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;-0.5 \cdot \frac{c}{b}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if b < -6.9999999999999997e64

                    1. Initial program 58.1%

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

                      \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                    4. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                      2. lower-/.f6498.1

                        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{b}{a}} \]
                    5. Applied rewrites98.1%

                      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
                    6. Step-by-step derivation
                      1. Applied rewrites98.0%

                        \[\leadsto b \cdot \color{blue}{\frac{-0.6666666666666666}{a}} \]
                      2. Step-by-step derivation
                        1. Applied rewrites98.1%

                          \[\leadsto \frac{b}{\color{blue}{a \cdot -1.5}} \]
                        2. Step-by-step derivation
                          1. Applied rewrites98.2%

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

                          if -6.9999999999999997e64 < b < 8.9999999999999997e-101

                          1. Initial program 80.2%

                            \[\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. lift-/.f64N/A

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

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

                              \[\leadsto \color{blue}{\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}{3}} \]
                            4. div-invN/A

                              \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a} \cdot \frac{1}{3}} \]
                            5. lower-*.f64N/A

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

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

                          if 8.9999999999999997e-101 < b

                          1. Initial program 17.4%

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

                            \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                          4. Step-by-step derivation
                            1. lower-*.f64N/A

                              \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                            2. lower-/.f6487.5

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

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

                        Alternative 4: 79.7% accurate, 1.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.02 \cdot 10^{-38}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{-141}:\\ \;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
                        (FPCore (a b c)
                         :precision binary64
                         (if (<= b -1.02e-38)
                           (fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666))
                           (if (<= b 5.2e-141)
                             (/ (- (sqrt (* -3.0 (* c a))) b) (* a 3.0))
                             (* -0.5 (/ c b)))))
                        double code(double a, double b, double c) {
                        	double tmp;
                        	if (b <= -1.02e-38) {
                        		tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
                        	} else if (b <= 5.2e-141) {
                        		tmp = (sqrt((-3.0 * (c * a))) - b) / (a * 3.0);
                        	} else {
                        		tmp = -0.5 * (c / b);
                        	}
                        	return tmp;
                        }
                        
                        function code(a, b, c)
                        	tmp = 0.0
                        	if (b <= -1.02e-38)
                        		tmp = fma(0.5, Float64(c / b), Float64(Float64(b / a) * -0.6666666666666666));
                        	elseif (b <= 5.2e-141)
                        		tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(c * a))) - b) / Float64(a * 3.0));
                        	else
                        		tmp = Float64(-0.5 * Float64(c / b));
                        	end
                        	return tmp
                        end
                        
                        code[a_, b_, c_] := If[LessEqual[b, -1.02e-38], N[(0.5 * N[(c / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-141], N[(N[(N[Sqrt[N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;b \leq -1.02 \cdot 10^{-38}:\\
                        \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
                        
                        \mathbf{elif}\;b \leq 5.2 \cdot 10^{-141}:\\
                        \;\;\;\;\frac{\sqrt{-3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;-0.5 \cdot \frac{c}{b}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if b < -1.01999999999999998e-38

                          1. Initial program 68.8%

                            \[\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. Applied rewrites68.8%

                              \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}} \]
                            2. Step-by-step derivation
                              1. lift-fma.f64N/A

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

                                \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c\right)} + b \cdot b} - b}{a \cdot 3} \]
                              3. lift-*.f64N/A

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

                                \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot -3\right) \cdot c} + b \cdot b} - b}{a \cdot 3} \]
                              5. *-commutativeN/A

                                \[\leadsto \frac{\sqrt{\color{blue}{\left(-3 \cdot a\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
                              6. metadata-evalN/A

                                \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right)} \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                              7. distribute-lft-neg-inN/A

                                \[\leadsto \frac{\sqrt{\color{blue}{\left(\mathsf{neg}\left(3 \cdot a\right)\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
                              8. lift-*.f64N/A

                                \[\leadsto \frac{\sqrt{\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right)\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                              9. lower-fma.f64N/A

                                \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(3 \cdot a\right), c, b \cdot b\right)}} - b}{a \cdot 3} \]
                              10. lift-*.f64N/A

                                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right), c, b \cdot b\right)} - b}{a \cdot 3} \]
                              11. distribute-lft-neg-inN/A

                                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right) \cdot a}, c, b \cdot b\right)} - b}{a \cdot 3} \]
                              12. metadata-evalN/A

                                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{-3} \cdot a, c, b \cdot b\right)} - b}{a \cdot 3} \]
                              13. *-commutativeN/A

                                \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{a \cdot -3}, c, b \cdot b\right)} - b}{a \cdot 3} \]
                              14. lower-*.f6468.8

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

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

                              \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
                            5. Step-by-step derivation
                              1. associate-*r*N/A

                                \[\leadsto \color{blue}{\left(-1 \cdot b\right) \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                              2. mul-1-negN/A

                                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(b\right)\right)} \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              3. lower-*.f64N/A

                                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                              4. lower-neg.f64N/A

                                \[\leadsto \color{blue}{\left(-b\right)} \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              5. *-commutativeN/A

                                \[\leadsto \left(-b\right) \cdot \left(\color{blue}{\frac{c}{{b}^{2}} \cdot \frac{-1}{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              6. lower-fma.f64N/A

                                \[\leadsto \left(-b\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{c}{{b}^{2}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                              7. lower-/.f64N/A

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\color{blue}{\frac{c}{{b}^{2}}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              8. unpow2N/A

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{\color{blue}{b \cdot b}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              9. lower-*.f64N/A

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{\color{blue}{b \cdot b}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                              10. associate-*r/N/A

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, \frac{-1}{2}, \color{blue}{\frac{\frac{2}{3} \cdot 1}{a}}\right) \]
                              11. metadata-evalN/A

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, \frac{-1}{2}, \frac{\color{blue}{\frac{2}{3}}}{a}\right) \]
                              12. lower-/.f6492.4

                                \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \color{blue}{\frac{0.6666666666666666}{a}}\right) \]
                            6. Applied rewrites92.4%

                              \[\leadsto \color{blue}{\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)} \]
                            7. Taylor expanded in a around inf

                              \[\leadsto \frac{-2}{3} \cdot \frac{b}{a} + \color{blue}{\frac{1}{2} \cdot \frac{c}{b}} \]
                            8. Step-by-step derivation
                              1. Applied rewrites92.6%

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

                              if -1.01999999999999998e-38 < b < 5.20000000000000022e-141

                              1. Initial program 77.1%

                                \[\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. Applied rewrites76.9%

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

                                  \[\leadsto \frac{\sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right)}} - b}{a \cdot 3} \]
                                3. Step-by-step derivation
                                  1. lower-*.f64N/A

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

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

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

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

                                if 5.20000000000000022e-141 < b

                                1. Initial program 19.9%

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

                                  \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                4. Step-by-step derivation
                                  1. lower-*.f64N/A

                                    \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                  2. lower-/.f6485.4

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

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

                              Alternative 5: 67.6% accurate, 1.2× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
                              (FPCore (a b c)
                               :precision binary64
                               (if (<= b -5e-311)
                                 (fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666))
                                 (* -0.5 (/ c b))))
                              double code(double a, double b, double c) {
                              	double tmp;
                              	if (b <= -5e-311) {
                              		tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
                              	} else {
                              		tmp = -0.5 * (c / b);
                              	}
                              	return tmp;
                              }
                              
                              function code(a, b, c)
                              	tmp = 0.0
                              	if (b <= -5e-311)
                              		tmp = fma(0.5, Float64(c / b), Float64(Float64(b / a) * -0.6666666666666666));
                              	else
                              		tmp = Float64(-0.5 * Float64(c / b));
                              	end
                              	return tmp
                              end
                              
                              code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(0.5 * N[(c / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
                              \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;-0.5 \cdot \frac{c}{b}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if b < -5.00000000000023e-311

                                1. Initial program 72.3%

                                  \[\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. Applied rewrites72.2%

                                    \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a \cdot 3}} \]
                                  2. Step-by-step derivation
                                    1. lift-fma.f64N/A

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

                                      \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c\right)} + b \cdot b} - b}{a \cdot 3} \]
                                    3. lift-*.f64N/A

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

                                      \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot -3\right) \cdot c} + b \cdot b} - b}{a \cdot 3} \]
                                    5. *-commutativeN/A

                                      \[\leadsto \frac{\sqrt{\color{blue}{\left(-3 \cdot a\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
                                    6. metadata-evalN/A

                                      \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right)} \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                                    7. distribute-lft-neg-inN/A

                                      \[\leadsto \frac{\sqrt{\color{blue}{\left(\mathsf{neg}\left(3 \cdot a\right)\right)} \cdot c + b \cdot b} - b}{a \cdot 3} \]
                                    8. lift-*.f64N/A

                                      \[\leadsto \frac{\sqrt{\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right)\right) \cdot c + b \cdot b} - b}{a \cdot 3} \]
                                    9. lower-fma.f64N/A

                                      \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(3 \cdot a\right), c, b \cdot b\right)}} - b}{a \cdot 3} \]
                                    10. lift-*.f64N/A

                                      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{3 \cdot a}\right), c, b \cdot b\right)} - b}{a \cdot 3} \]
                                    11. distribute-lft-neg-inN/A

                                      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(3\right)\right) \cdot a}, c, b \cdot b\right)} - b}{a \cdot 3} \]
                                    12. metadata-evalN/A

                                      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{-3} \cdot a, c, b \cdot b\right)} - b}{a \cdot 3} \]
                                    13. *-commutativeN/A

                                      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(\color{blue}{a \cdot -3}, c, b \cdot b\right)} - b}{a \cdot 3} \]
                                    14. lower-*.f6472.3

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

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

                                    \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
                                  5. Step-by-step derivation
                                    1. associate-*r*N/A

                                      \[\leadsto \color{blue}{\left(-1 \cdot b\right) \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                                    2. mul-1-negN/A

                                      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(b\right)\right)} \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    3. lower-*.f64N/A

                                      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                                    4. lower-neg.f64N/A

                                      \[\leadsto \color{blue}{\left(-b\right)} \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    5. *-commutativeN/A

                                      \[\leadsto \left(-b\right) \cdot \left(\color{blue}{\frac{c}{{b}^{2}} \cdot \frac{-1}{2}} + \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    6. lower-fma.f64N/A

                                      \[\leadsto \left(-b\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{c}{{b}^{2}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right)} \]
                                    7. lower-/.f64N/A

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\color{blue}{\frac{c}{{b}^{2}}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    8. unpow2N/A

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{\color{blue}{b \cdot b}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    9. lower-*.f64N/A

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{\color{blue}{b \cdot b}}, \frac{-1}{2}, \frac{2}{3} \cdot \frac{1}{a}\right) \]
                                    10. associate-*r/N/A

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, \frac{-1}{2}, \color{blue}{\frac{\frac{2}{3} \cdot 1}{a}}\right) \]
                                    11. metadata-evalN/A

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, \frac{-1}{2}, \frac{\color{blue}{\frac{2}{3}}}{a}\right) \]
                                    12. lower-/.f6466.5

                                      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \color{blue}{\frac{0.6666666666666666}{a}}\right) \]
                                  6. Applied rewrites66.5%

                                    \[\leadsto \color{blue}{\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)} \]
                                  7. Taylor expanded in a around inf

                                    \[\leadsto \frac{-2}{3} \cdot \frac{b}{a} + \color{blue}{\frac{1}{2} \cdot \frac{c}{b}} \]
                                  8. Step-by-step derivation
                                    1. Applied rewrites66.8%

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

                                    if -5.00000000000023e-311 < b

                                    1. Initial program 32.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

                                      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                    4. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                      2. lower-/.f6468.7

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

                                      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
                                  9. Recombined 2 regimes into one program.
                                  10. Add Preprocessing

                                  Alternative 6: 67.3% accurate, 2.2× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.1 \cdot 10^{-273}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
                                  (FPCore (a b c)
                                   :precision binary64
                                   (if (<= b 3.1e-273) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
                                  double code(double a, double b, double c) {
                                  	double tmp;
                                  	if (b <= 3.1e-273) {
                                  		tmp = -0.6666666666666666 * (b / a);
                                  	} else {
                                  		tmp = -0.5 * (c / b);
                                  	}
                                  	return tmp;
                                  }
                                  
                                  real(8) function code(a, b, c)
                                      real(8), intent (in) :: a
                                      real(8), intent (in) :: b
                                      real(8), intent (in) :: c
                                      real(8) :: tmp
                                      if (b <= 3.1d-273) then
                                          tmp = (-0.6666666666666666d0) * (b / a)
                                      else
                                          tmp = (-0.5d0) * (c / b)
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double a, double b, double c) {
                                  	double tmp;
                                  	if (b <= 3.1e-273) {
                                  		tmp = -0.6666666666666666 * (b / a);
                                  	} else {
                                  		tmp = -0.5 * (c / b);
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(a, b, c):
                                  	tmp = 0
                                  	if b <= 3.1e-273:
                                  		tmp = -0.6666666666666666 * (b / a)
                                  	else:
                                  		tmp = -0.5 * (c / b)
                                  	return tmp
                                  
                                  function code(a, b, c)
                                  	tmp = 0.0
                                  	if (b <= 3.1e-273)
                                  		tmp = Float64(-0.6666666666666666 * Float64(b / a));
                                  	else
                                  		tmp = Float64(-0.5 * Float64(c / b));
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(a, b, c)
                                  	tmp = 0.0;
                                  	if (b <= 3.1e-273)
                                  		tmp = -0.6666666666666666 * (b / a);
                                  	else
                                  		tmp = -0.5 * (c / b);
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[a_, b_, c_] := If[LessEqual[b, 3.1e-273], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;b \leq 3.1 \cdot 10^{-273}:\\
                                  \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;-0.5 \cdot \frac{c}{b}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if b < 3.09999999999999988e-273

                                    1. Initial program 72.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

                                      \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                                    4. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                                      2. lower-/.f6462.6

                                        \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{b}{a}} \]
                                    5. Applied rewrites62.6%

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

                                    if 3.09999999999999988e-273 < b

                                    1. Initial program 29.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

                                      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                    4. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
                                      2. lower-/.f6472.6

                                        \[\leadsto -0.5 \cdot \color{blue}{\frac{c}{b}} \]
                                    5. Applied rewrites72.6%

                                      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
                                  3. Recombined 2 regimes into one program.
                                  4. Add Preprocessing

                                  Alternative 7: 35.3% accurate, 2.9× speedup?

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

                                    \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                                  4. Step-by-step derivation
                                    1. lower-*.f64N/A

                                      \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}} \]
                                    2. lower-/.f6432.0

                                      \[\leadsto -0.6666666666666666 \cdot \color{blue}{\frac{b}{a}} \]
                                  5. Applied rewrites32.0%

                                    \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
                                  6. Add Preprocessing

                                  Reproduce

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