Cubic critical

Percentage Accurate: 51.5% → 84.8%
Time: 5.7s
Alternatives: 16
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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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 16 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: 51.5% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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: 84.8% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 37.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6495.6

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

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

    if -3.49999999999999987e167 < b < 2.05e-45

    1. Initial program 81.4%

      \[\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 \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{3 \cdot a}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.05e-45 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 2: 84.8% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 37.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6495.6

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

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

    if -3.49999999999999987e167 < b < 2.05e-45

    1. Initial program 81.4%

      \[\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 \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a} \]
      7. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

    if 2.05e-45 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 3: 84.8% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 37.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6495.6

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

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

    if -3.49999999999999987e167 < b < 2.05e-45

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

    if 2.05e-45 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

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

Alternative 4: 80.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-83}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 64.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}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6485.0

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

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

    if -5.6000000000000002e-83 < b < 2.6e-47

    1. Initial program 75.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 a around inf

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a} \]
      7. lower-*.f6472.4

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(a \cdot -3\right) \cdot c}}{3 \cdot a} \]
    7. Applied rewrites72.4%

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

    if 2.6e-47 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 5: 80.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-83}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 64.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}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6485.0

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

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

    if -5.6000000000000002e-83 < b < 2.6e-47

    1. Initial program 75.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 a around inf

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

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

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

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

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

    if 2.6e-47 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 6: 71.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.45 \cdot 10^{-178}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\

\mathbf{elif}\;b \leq 2.25 \cdot 10^{-160}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\

\mathbf{elif}\;b \leq 1.9 \cdot 10^{-105}:\\
\;\;\;\;\sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -2.4500000000000001e-178

    1. Initial program 66.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-neg.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(\mathsf{neg}\left(b\right)\right)}}{3 \cdot a} \]
    4. Applied rewrites66.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}\right)}{3}}{a}} \]
    7. 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)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6476.6

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

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

      \[\leadsto \frac{-2}{3} \cdot \frac{b}{a} + \color{blue}{\frac{1}{2} \cdot \frac{c}{b}} \]
    11. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \frac{c}{b}, \frac{-2}{3} \cdot \frac{b}{a}\right) \]
      4. *-commutativeN/A

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

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

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

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

    if -2.4500000000000001e-178 < b < 2.25000000000000013e-160

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \left(\sqrt{-1} \cdot \sqrt{3}\right)\right) \cdot \color{blue}{\frac{-1}{3}} \]
      3. sqrt-unprodN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{-1}{3} \]
      4. metadata-evalN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{-1}{3} \]
      5. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      6. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      8. lower-/.f6443.8

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333 \]
    5. Applied rewrites43.8%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333} \]

    if 2.25000000000000013e-160 < b < 1.8999999999999999e-105

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{1}{3} \]
      3. sqrt-unprodN/A

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{1}{3} \]
      7. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      8. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      10. lower-/.f6470.4

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333 \]
    5. Applied rewrites70.4%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      2. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{-3 \cdot \frac{c}{a}} \cdot \frac{1}{3} \]
      4. associate-*r/N/A

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot \frac{1}{3} \]
      5. lower-/.f64N/A

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot \frac{1}{3} \]
      6. lower-*.f6470.6

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333 \]
    7. Applied rewrites70.6%

      \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333 \]

    if 1.8999999999999999e-105 < b

    1. Initial program 24.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6479.4

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites79.4%

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

Alternative 7: 71.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 2.25 \cdot 10^{-160}:\\ \;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{-105}:\\ \;\;\;\;\sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5.6e-181)
   (/ (* -2.0 b) (* 3.0 a))
   (if (<= b 2.25e-160)
     (* (sqrt (* (/ c a) -3.0)) -0.3333333333333333)
     (if (<= b 1.9e-105)
       (* (sqrt (/ (* -3.0 c) a)) 0.3333333333333333)
       (/ (* -0.5 c) b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 2.25e-160) {
		tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	} else if (b <= 1.9e-105) {
		tmp = sqrt(((-3.0 * c) / a)) * 0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-5.6d-181)) then
        tmp = ((-2.0d0) * b) / (3.0d0 * a)
    else if (b <= 2.25d-160) then
        tmp = sqrt(((c / a) * (-3.0d0))) * (-0.3333333333333333d0)
    else if (b <= 1.9d-105) then
        tmp = sqrt((((-3.0d0) * c) / a)) * 0.3333333333333333d0
    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 <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 2.25e-160) {
		tmp = Math.sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	} else if (b <= 1.9e-105) {
		tmp = Math.sqrt(((-3.0 * c) / a)) * 0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5.6e-181:
		tmp = (-2.0 * b) / (3.0 * a)
	elif b <= 2.25e-160:
		tmp = math.sqrt(((c / a) * -3.0)) * -0.3333333333333333
	elif b <= 1.9e-105:
		tmp = math.sqrt(((-3.0 * c) / a)) * 0.3333333333333333
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5.6e-181)
		tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a));
	elseif (b <= 2.25e-160)
		tmp = Float64(sqrt(Float64(Float64(c / a) * -3.0)) * -0.3333333333333333);
	elseif (b <= 1.9e-105)
		tmp = Float64(sqrt(Float64(Float64(-3.0 * c) / a)) * 0.3333333333333333);
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5.6e-181)
		tmp = (-2.0 * b) / (3.0 * a);
	elseif (b <= 2.25e-160)
		tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	elseif (b <= 1.9e-105)
		tmp = sqrt(((-3.0 * c) / a)) * 0.3333333333333333;
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5.6e-181], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-160], N[(N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] * -0.3333333333333333), $MachinePrecision], If[LessEqual[b, 1.9e-105], N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \leq 2.25 \cdot 10^{-160}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\

\mathbf{elif}\;b \leq 1.9 \cdot 10^{-105}:\\
\;\;\;\;\sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -5.59999999999999973e-181

    1. Initial program 67.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6477.1

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

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

    if -5.59999999999999973e-181 < b < 2.25000000000000013e-160

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \left(\sqrt{-1} \cdot \sqrt{3}\right)\right) \cdot \color{blue}{\frac{-1}{3}} \]
      3. sqrt-unprodN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{-1}{3} \]
      4. metadata-evalN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{-1}{3} \]
      5. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      6. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      8. lower-/.f6444.6

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333 \]
    5. Applied rewrites44.6%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333} \]

    if 2.25000000000000013e-160 < b < 1.8999999999999999e-105

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{1}{3} \]
      3. sqrt-unprodN/A

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{1}{3} \]
      7. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      8. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      10. lower-/.f6470.4

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333 \]
    5. Applied rewrites70.4%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      2. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{-3 \cdot \frac{c}{a}} \cdot \frac{1}{3} \]
      4. associate-*r/N/A

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot \frac{1}{3} \]
      5. lower-/.f64N/A

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot \frac{1}{3} \]
      6. lower-*.f6470.6

        \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333 \]
    7. Applied rewrites70.6%

      \[\leadsto \sqrt{\frac{-3 \cdot c}{a}} \cdot 0.3333333333333333 \]

    if 1.8999999999999999e-105 < b

    1. Initial program 24.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6479.4

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites79.4%

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

Alternative 8: 71.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{c}{a} \cdot -3}\\ \mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 2.25 \cdot 10^{-160}:\\ \;\;\;\;t\_0 \cdot -0.3333333333333333\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{-105}:\\ \;\;\;\;t\_0 \cdot 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (* (/ c a) -3.0))))
   (if (<= b -5.6e-181)
     (/ (* -2.0 b) (* 3.0 a))
     (if (<= b 2.25e-160)
       (* t_0 -0.3333333333333333)
       (if (<= b 1.9e-105) (* t_0 0.3333333333333333) (/ (* -0.5 c) b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((c / a) * -3.0));
	double tmp;
	if (b <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 2.25e-160) {
		tmp = t_0 * -0.3333333333333333;
	} else if (b <= 1.9e-105) {
		tmp = t_0 * 0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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(((c / a) * (-3.0d0)))
    if (b <= (-5.6d-181)) then
        tmp = ((-2.0d0) * b) / (3.0d0 * a)
    else if (b <= 2.25d-160) then
        tmp = t_0 * (-0.3333333333333333d0)
    else if (b <= 1.9d-105) then
        tmp = t_0 * 0.3333333333333333d0
    else
        tmp = ((-0.5d0) * c) / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((c / a) * -3.0));
	double tmp;
	if (b <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 2.25e-160) {
		tmp = t_0 * -0.3333333333333333;
	} else if (b <= 1.9e-105) {
		tmp = t_0 * 0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((c / a) * -3.0))
	tmp = 0
	if b <= -5.6e-181:
		tmp = (-2.0 * b) / (3.0 * a)
	elif b <= 2.25e-160:
		tmp = t_0 * -0.3333333333333333
	elif b <= 1.9e-105:
		tmp = t_0 * 0.3333333333333333
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(c / a) * -3.0))
	tmp = 0.0
	if (b <= -5.6e-181)
		tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a));
	elseif (b <= 2.25e-160)
		tmp = Float64(t_0 * -0.3333333333333333);
	elseif (b <= 1.9e-105)
		tmp = Float64(t_0 * 0.3333333333333333);
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = sqrt(((c / a) * -3.0));
	tmp = 0.0;
	if (b <= -5.6e-181)
		tmp = (-2.0 * b) / (3.0 * a);
	elseif (b <= 2.25e-160)
		tmp = t_0 * -0.3333333333333333;
	elseif (b <= 1.9e-105)
		tmp = t_0 * 0.3333333333333333;
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5.6e-181], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.25e-160], N[(t$95$0 * -0.3333333333333333), $MachinePrecision], If[LessEqual[b, 1.9e-105], N[(t$95$0 * 0.3333333333333333), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{c}{a} \cdot -3}\\
\mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \leq 2.25 \cdot 10^{-160}:\\
\;\;\;\;t\_0 \cdot -0.3333333333333333\\

\mathbf{elif}\;b \leq 1.9 \cdot 10^{-105}:\\
\;\;\;\;t\_0 \cdot 0.3333333333333333\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -5.59999999999999973e-181

    1. Initial program 67.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6477.1

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

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

    if -5.59999999999999973e-181 < b < 2.25000000000000013e-160

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \left(\sqrt{-1} \cdot \sqrt{3}\right)\right) \cdot \color{blue}{\frac{-1}{3}} \]
      3. sqrt-unprodN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{-1}{3} \]
      4. metadata-evalN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{-1}{3} \]
      5. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      6. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      8. lower-/.f6444.6

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333 \]
    5. Applied rewrites44.6%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333} \]

    if 2.25000000000000013e-160 < b < 1.8999999999999999e-105

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{1}{3} \]
      3. sqrt-unprodN/A

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{1}{3} \]
      7. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      8. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{1}{3} \]
      10. lower-/.f6470.4

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333 \]
    5. Applied rewrites70.4%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot 0.3333333333333333} \]

    if 1.8999999999999999e-105 < b

    1. Initial program 24.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6479.4

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites79.4%

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

Alternative 9: 80.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-83}:\\
\;\;\;\;\left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right)\\

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

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


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

    1. Initial program 64.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}{-1 \cdot \left(b \cdot \left(\frac{-1}{2} \cdot \frac{c}{{b}^{2}} + \frac{2}{3} \cdot \frac{1}{a}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6485.0

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

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

    if -5.6000000000000002e-83 < b < 2.6e-47

    1. Initial program 75.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 a around inf

      \[\leadsto \frac{\color{blue}{\sqrt{a \cdot c} \cdot \sqrt{-3}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. sqrt-unprodN/A

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

        \[\leadsto \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{3 \cdot a} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{3 \cdot a} \]
      4. lower-*.f64N/A

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

        \[\leadsto \frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a} \]
      6. lower-*.f6471.4

        \[\leadsto \frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a} \]
    5. Applied rewrites71.4%

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

    if 2.6e-47 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 10: 80.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-83}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}\right)}{3}}{a}} \]
    7. 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)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6485.0

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right) \]
    9. Applied rewrites85.0%

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

      \[\leadsto \frac{-2}{3} \cdot \frac{b}{a} + \color{blue}{\frac{1}{2} \cdot \frac{c}{b}} \]
    11. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \frac{c}{b}, \frac{-2}{3} \cdot \frac{b}{a}\right) \]
      4. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \frac{c}{b}, \frac{b}{a} \cdot \frac{-2}{3}\right) \]
      6. lower-/.f6485.0

        \[\leadsto \mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right) \]
    12. Applied rewrites85.0%

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

    if -5.6000000000000002e-83 < b < 2.6e-47

    1. Initial program 75.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 a around inf

      \[\leadsto \frac{\color{blue}{\sqrt{a \cdot c} \cdot \sqrt{-3}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. sqrt-unprodN/A

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

        \[\leadsto \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{3 \cdot a} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{-3 \cdot \left(a \cdot c\right)}}{3 \cdot a} \]
      4. lower-*.f64N/A

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

        \[\leadsto \frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a} \]
      6. lower-*.f6471.4

        \[\leadsto \frac{\sqrt{-3 \cdot \left(c \cdot a\right)}}{3 \cdot a} \]
    5. Applied rewrites71.4%

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

    if 2.6e-47 < b

    1. Initial program 21.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 a around 0

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites84.6%

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

Alternative 11: 72.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 3.2 \cdot 10^{-161}:\\ \;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -5.6e-181)
   (/ (* -2.0 b) (* 3.0 a))
   (if (<= b 3.2e-161)
     (* (sqrt (* (/ c a) -3.0)) -0.3333333333333333)
     (/ (* -0.5 c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 3.2e-161) {
		tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-5.6d-181)) then
        tmp = ((-2.0d0) * b) / (3.0d0 * a)
    else if (b <= 3.2d-161) then
        tmp = sqrt(((c / a) * (-3.0d0))) * (-0.3333333333333333d0)
    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 <= -5.6e-181) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else if (b <= 3.2e-161) {
		tmp = Math.sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -5.6e-181:
		tmp = (-2.0 * b) / (3.0 * a)
	elif b <= 3.2e-161:
		tmp = math.sqrt(((c / a) * -3.0)) * -0.3333333333333333
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -5.6e-181)
		tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a));
	elseif (b <= 3.2e-161)
		tmp = Float64(sqrt(Float64(Float64(c / a) * -3.0)) * -0.3333333333333333);
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -5.6e-181)
		tmp = (-2.0 * b) / (3.0 * a);
	elseif (b <= 3.2e-161)
		tmp = sqrt(((c / a) * -3.0)) * -0.3333333333333333;
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -5.6e-181], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-161], N[(N[Sqrt[N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] * -0.3333333333333333), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-181}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \leq 3.2 \cdot 10^{-161}:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333\\

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


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

    1. Initial program 67.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6477.1

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

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

    if -5.59999999999999973e-181 < b < 3.19999999999999985e-161

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

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

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

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \left(\sqrt{-1} \cdot \sqrt{3}\right)\right) \cdot \color{blue}{\frac{-1}{3}} \]
      3. sqrt-unprodN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1 \cdot 3}\right) \cdot \frac{-1}{3} \]
      4. metadata-evalN/A

        \[\leadsto \left(\sqrt{\frac{c}{a}} \cdot \sqrt{-3}\right) \cdot \frac{-1}{3} \]
      5. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      6. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot \frac{-1}{3} \]
      8. lower-/.f6444.6

        \[\leadsto \sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333 \]
    5. Applied rewrites44.6%

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a} \cdot -3} \cdot -0.3333333333333333} \]

    if 3.19999999999999985e-161 < b

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

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

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

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

        \[\leadsto \frac{c}{b} \cdot -0.5 \]
    5. Applied rewrites74.1%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

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

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites74.2%

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

Alternative 12: 68.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 4.5e-289) (/ (* -2.0 b) (* 3.0 a)) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 4.5e-289) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 4.5d-289) then
        tmp = ((-2.0d0) * b) / (3.0d0 * 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 <= 4.5e-289) {
		tmp = (-2.0 * b) / (3.0 * a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 4.5e-289:
		tmp = (-2.0 * b) / (3.0 * a)
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 4.5e-289)
		tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a));
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 4.5e-289)
		tmp = (-2.0 * b) / (3.0 * a);
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-289], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\

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


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

    1. Initial program 70.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 \frac{\color{blue}{-2 \cdot b}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. lower-*.f6460.5

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

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

    if 4.5000000000000002e-289 < b

    1. Initial program 36.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. *-commutativeN/A

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

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

        \[\leadsto \frac{c}{b} \cdot -0.5 \]
    5. Applied rewrites64.3%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6464.3

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites64.3%

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

Alternative 13: 68.1% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\ \;\;\;\;\left(-b\right) \cdot \frac{0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 4.5e-289) (* (- b) (/ 0.6666666666666666 a)) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 4.5e-289) {
		tmp = -b * (0.6666666666666666 / a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 4.5d-289) then
        tmp = -b * (0.6666666666666666d0 / 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 <= 4.5e-289) {
		tmp = -b * (0.6666666666666666 / a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 4.5e-289:
		tmp = -b * (0.6666666666666666 / a)
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 4.5e-289)
		tmp = Float64(Float64(-b) * Float64(0.6666666666666666 / a));
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 4.5e-289)
		tmp = -b * (0.6666666666666666 / a);
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-289], N[((-b) * N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\
\;\;\;\;\left(-b\right) \cdot \frac{0.6666666666666666}{a}\\

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


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

    1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(-1, b, \sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}\right)}{3}}{a}} \]
    7. 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)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{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}, \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{\frac{2}{3}}{a}\right) \]
      12. lower-/.f6459.1

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -0.5, \frac{0.6666666666666666}{a}\right) \]
    9. Applied rewrites59.1%

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

      \[\leadsto \left(-b\right) \cdot \frac{\frac{2}{3}}{\color{blue}{a}} \]
    11. Step-by-step derivation
      1. lift-/.f6460.4

        \[\leadsto \left(-b\right) \cdot \frac{0.6666666666666666}{a} \]
    12. Applied rewrites60.4%

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

    if 4.5000000000000002e-289 < b

    1. Initial program 36.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. *-commutativeN/A

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

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

        \[\leadsto \frac{c}{b} \cdot -0.5 \]
    5. Applied rewrites64.3%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6464.3

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites64.3%

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

Alternative 14: 68.1% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 4.5e-289) (* -0.6666666666666666 (/ b a)) (/ (* -0.5 c) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 4.5e-289) {
		tmp = -0.6666666666666666 * (b / a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 4.5d-289) 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 <= 4.5e-289) {
		tmp = -0.6666666666666666 * (b / a);
	} else {
		tmp = (-0.5 * c) / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 4.5e-289:
		tmp = -0.6666666666666666 * (b / a)
	else:
		tmp = (-0.5 * c) / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 4.5e-289)
		tmp = Float64(-0.6666666666666666 * Float64(b / a));
	else
		tmp = Float64(Float64(-0.5 * c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 4.5e-289)
		tmp = -0.6666666666666666 * (b / a);
	else
		tmp = (-0.5 * c) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-289], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * c), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 70.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 \frac{-2}{3} \cdot \color{blue}{\frac{b}{a}} \]
      2. lower-/.f6460.4

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

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

    if 4.5000000000000002e-289 < b

    1. Initial program 36.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. *-commutativeN/A

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

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

        \[\leadsto \frac{c}{b} \cdot -0.5 \]
    5. Applied rewrites64.3%

      \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c}{b} \cdot \color{blue}{\frac{-1}{2}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c}{b} \cdot \frac{-1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{c}{b}} \]
      4. associate-*r/N/A

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

        \[\leadsto \frac{\frac{-1}{2} \cdot c}{\color{blue}{b}} \]
      6. lower-*.f6464.3

        \[\leadsto \frac{-0.5 \cdot c}{b} \]
    7. Applied rewrites64.3%

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

Alternative 15: 68.1% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.5 \cdot 10^{-289}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 4.5e-289) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 4.5e-289) {
		tmp = -0.6666666666666666 * (b / a);
	} else {
		tmp = (c / b) * -0.5;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 4.5d-289) then
        tmp = (-0.6666666666666666d0) * (b / a)
    else
        tmp = (c / b) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= 4.5e-289) {
		tmp = -0.6666666666666666 * (b / a);
	} else {
		tmp = (c / b) * -0.5;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 4.5e-289:
		tmp = -0.6666666666666666 * (b / a)
	else:
		tmp = (c / b) * -0.5
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 4.5e-289)
		tmp = Float64(-0.6666666666666666 * Float64(b / a));
	else
		tmp = Float64(Float64(c / b) * -0.5);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 4.5e-289)
		tmp = -0.6666666666666666 * (b / a);
	else
		tmp = (c / b) * -0.5;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-289], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 70.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 \frac{-2}{3} \cdot \color{blue}{\frac{b}{a}} \]
      2. lower-/.f6460.4

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

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

    if 4.5000000000000002e-289 < b

    1. Initial program 36.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. *-commutativeN/A

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

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

        \[\leadsto \frac{c}{b} \cdot -0.5 \]
    5. Applied rewrites64.3%

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

Alternative 16: 35.9% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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 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

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

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

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

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

Reproduce

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