Quadratic roots, full range

Percentage Accurate: 52.4% → 85.4%
Time: 3.5s
Alternatives: 12
Speedup: 2.1×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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 12 alternatives:

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

Initial Program: 52.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 85.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

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

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


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

    1. Initial program 41.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6496.9

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6497.4

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites97.4%

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

    if -1.6500000000000001e152 < b < 3.00000000000000002e-51

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{a} \cdot -0.5 + \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{2 \cdot a} \]
    6. Applied rewrites79.6%

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 2: 85.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

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

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


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

    1. Initial program 41.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6496.9

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6497.4

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites97.4%

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

    if -1.6500000000000001e152 < b < 3.00000000000000002e-51

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{{b}^{2} - \color{blue}{4 \cdot \left(a \cdot c\right)}}\right)}{2 \cdot a} \]
      14. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}\right)}{2 \cdot a} \]
      21. lift-*.f6479.6

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

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 3: 80.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

\mathbf{elif}\;b \leq 3 \cdot 10^{-51}:\\
\;\;\;\;\frac{b}{a} \cdot -0.5 + \frac{\sqrt{\left(-4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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


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

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6489.6

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites89.6%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6489.9

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites89.9%

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

    if -1.26e-21 < b < 3.00000000000000002e-51

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{a} \cdot -0.5 + \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{2 \cdot a} \]
    6. Applied rewrites73.7%

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

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

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

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

        \[\leadsto \frac{b}{a} \cdot -0.5 + \frac{\sqrt{\left(-4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    9. Applied rewrites63.3%

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 4: 80.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

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

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


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

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6489.6

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites89.6%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6489.9

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites89.9%

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

    if -1.26e-21 < b < 3.00000000000000002e-51

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{{b}^{2} - \color{blue}{4 \cdot \left(a \cdot c\right)}}\right)}{2 \cdot a} \]
      14. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}\right)}{2 \cdot a} \]
      21. lift-*.f6473.7

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{\left(a \cdot -4\right) \cdot c}\right)}{2 \cdot a} \]
    6. Applied rewrites63.3%

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 5: 80.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

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

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


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

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6489.6

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites89.6%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6489.9

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites89.9%

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

    if -1.26e-21 < b < 3.00000000000000002e-51

    1. Initial program 73.7%

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

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

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

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

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

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 6: 79.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

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

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


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

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6488.1

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites88.1%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6488.4

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites88.4%

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

    if -1.3999999999999999e-43 < b < 3.00000000000000002e-51

    1. Initial program 72.8%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{-4 \cdot \left(c \cdot a\right)}}{2 \cdot a} \]
    4. Applied rewrites63.0%

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

    if 3.00000000000000002e-51 < b

    1. Initial program 16.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6488.0

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites88.0%

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

Alternative 7: 73.1% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\

\mathbf{elif}\;b \leq 2.7 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\

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


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

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f6488.1

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites88.1%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
      4. lower-/.f6488.4

        \[\leadsto \mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right) \]
    7. Applied rewrites88.4%

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

    if -1.3999999999999999e-43 < b < 2.69999999999999996e-90

    1. Initial program 75.5%

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

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

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

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

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

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

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
      6. lower-/.f6430.5

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
    4. Applied rewrites30.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{c}{a} \cdot -1}} \]
    5. Taylor expanded in c around -inf

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

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

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

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

        \[\leadsto \sqrt{\frac{-1 \cdot c}{a}} \]
      5. mul-1-negN/A

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

        \[\leadsto \sqrt{\frac{\mathsf{neg}\left(c\right)}{a}} \]
      7. lower-neg.f6432.9

        \[\leadsto \sqrt{\frac{-c}{a}} \]
    7. Applied rewrites32.9%

      \[\leadsto \sqrt{\frac{-c}{a}} \]
    8. Step-by-step derivation
      1. lift-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\mathsf{neg}\left(c\right)}{a}} \]
      4. sqrt-divN/A

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

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

        \[\leadsto \frac{\sqrt{\mathsf{neg}\left(c\right)}}{\sqrt{a}} \]
      7. lift-neg.f64N/A

        \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]
      8. lower-sqrt.f6441.8

        \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]
    9. Applied rewrites41.8%

      \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]

    if 2.69999999999999996e-90 < b

    1. Initial program 19.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6484.6

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites84.6%

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

Alternative 8: 73.0% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-43}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;b \leq 2.7 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\

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


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

    1. Initial program 67.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot b}{\color{blue}{a}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{a} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{\color{blue}{a}} \]
      4. lift-neg.f6488.1

        \[\leadsto \frac{-b}{a} \]
    4. Applied rewrites88.1%

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

    if -1.3999999999999999e-43 < b < 2.69999999999999996e-90

    1. Initial program 75.5%

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

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

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

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

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

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

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
      6. lower-/.f6430.5

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
    4. Applied rewrites30.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{c}{a} \cdot -1}} \]
    5. Taylor expanded in c around -inf

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

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

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

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

        \[\leadsto \sqrt{\frac{-1 \cdot c}{a}} \]
      5. mul-1-negN/A

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

        \[\leadsto \sqrt{\frac{\mathsf{neg}\left(c\right)}{a}} \]
      7. lower-neg.f6432.9

        \[\leadsto \sqrt{\frac{-c}{a}} \]
    7. Applied rewrites32.9%

      \[\leadsto \sqrt{\frac{-c}{a}} \]
    8. Step-by-step derivation
      1. lift-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\mathsf{neg}\left(c\right)}{a}} \]
      4. sqrt-divN/A

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

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

        \[\leadsto \frac{\sqrt{\mathsf{neg}\left(c\right)}}{\sqrt{a}} \]
      7. lift-neg.f64N/A

        \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]
      8. lower-sqrt.f6441.8

        \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]
    9. Applied rewrites41.8%

      \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]

    if 2.69999999999999996e-90 < b

    1. Initial program 19.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6484.6

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites84.6%

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

Alternative 9: 71.0% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{-202}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;b \leq 2.7 \cdot 10^{-90}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\

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


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

    1. Initial program 71.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot b}{\color{blue}{a}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{a} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{\color{blue}{a}} \]
      4. lift-neg.f6475.9

        \[\leadsto \frac{-b}{a} \]
    4. Applied rewrites75.9%

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

    if -2.6999999999999999e-202 < b < 2.69999999999999996e-90

    1. Initial program 70.7%

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

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

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

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

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

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

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
      6. lower-/.f6433.4

        \[\leadsto -\sqrt{\frac{c}{a} \cdot -1} \]
    4. Applied rewrites33.4%

      \[\leadsto \color{blue}{-\sqrt{\frac{c}{a} \cdot -1}} \]
    5. Taylor expanded in c around -inf

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

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

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

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

        \[\leadsto \sqrt{\frac{-1 \cdot c}{a}} \]
      5. mul-1-negN/A

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

        \[\leadsto \sqrt{\frac{\mathsf{neg}\left(c\right)}{a}} \]
      7. lower-neg.f6435.5

        \[\leadsto \sqrt{\frac{-c}{a}} \]
    7. Applied rewrites35.5%

      \[\leadsto \sqrt{\frac{-c}{a}} \]

    if 2.69999999999999996e-90 < b

    1. Initial program 19.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6484.6

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites84.6%

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

Alternative 10: 66.8% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{-243}:\\
\;\;\;\;\frac{-b}{a}\\

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


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

    1. Initial program 71.5%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot b}{\color{blue}{a}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{a} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{\color{blue}{a}} \]
      4. lift-neg.f6462.6

        \[\leadsto \frac{-b}{a} \]
    4. Applied rewrites62.6%

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

    if 9.00000000000000035e-243 < b

    1. Initial program 29.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{b} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(c\right)}{\color{blue}{b}} \]
      4. lower-neg.f6471.8

        \[\leadsto \frac{-c}{b} \]
    4. Applied rewrites71.8%

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

Alternative 11: 43.1% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.28 \cdot 10^{+14}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.28e14

    1. Initial program 67.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot b}{\color{blue}{a}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{a} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(b\right)}{\color{blue}{a}} \]
      4. lift-neg.f6448.5

        \[\leadsto \frac{-b}{a} \]
    4. Applied rewrites48.5%

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

    if 1.28e14 < b

    1. Initial program 13.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
      10. inv-powN/A

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
      11. lower-pow.f642.5

        \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    4. Applied rewrites2.5%

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

      \[\leadsto \frac{c}{\color{blue}{b}} \]
    6. Step-by-step derivation
      1. lower-/.f6429.7

        \[\leadsto \frac{c}{b} \]
    7. Applied rewrites29.7%

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

Alternative 12: 10.7% accurate, 5.7× speedup?

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

\\
\frac{c}{b}
\end{array}
Derivation
  1. Initial program 52.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, \frac{1}{a}\right) \]
    10. inv-powN/A

      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
    11. lower-pow.f6434.5

      \[\leadsto \left(-b\right) \cdot \mathsf{fma}\left(\frac{c}{b \cdot b}, -1, {a}^{-1}\right) \]
  4. Applied rewrites34.5%

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

    \[\leadsto \frac{c}{\color{blue}{b}} \]
  6. Step-by-step derivation
    1. lower-/.f6410.7

      \[\leadsto \frac{c}{b} \]
  7. Applied rewrites10.7%

    \[\leadsto \frac{c}{\color{blue}{b}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2025101 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))