The quadratic formula (r2)

Percentage Accurate: 52.6% → 85.1%
Time: 4.1s
Alternatives: 12
Speedup: 2.6×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 85.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \leq 3.2 \cdot 10^{+89}:\\ \;\;\;\;\frac{b}{a} \cdot -0.5 - \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} + \frac{-b}{a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.8e-17)
   (- (/ c b))
   (if (<= b 3.2e+89)
     (- (* (/ b a) -0.5) (/ (sqrt (fma (* -4.0 a) c (* b b))) (+ a a)))
     (+ (/ c b) (/ (- b) a)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.8e-17) {
		tmp = -(c / b);
	} else if (b <= 3.2e+89) {
		tmp = ((b / a) * -0.5) - (sqrt(fma((-4.0 * a), c, (b * b))) / (a + a));
	} else {
		tmp = (c / b) + (-b / a);
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.8e-17)
		tmp = Float64(-Float64(c / b));
	elseif (b <= 3.2e+89)
		tmp = Float64(Float64(Float64(b / a) * -0.5) - Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) / Float64(a + a)));
	else
		tmp = Float64(Float64(c / b) + Float64(Float64(-b) / a));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -2.8e-17], (-N[(c / b), $MachinePrecision]), If[LessEqual[b, 3.2e+89], 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[(a + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] + N[((-b) / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6489.6

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

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

    if -2.7999999999999999e-17 < b < 3.19999999999999987e89

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-b}{a + a} - \frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{a + 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)}}{a + 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)}}{a + 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)}}{a + a} \]
      3. lift-/.f6476.9

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

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

    if 3.19999999999999987e89 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6495.3

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites95.3%

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

Alternative 2: 85.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6489.6

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

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

    if -2.7999999999999999e-17 < b < 3.19999999999999987e89

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}}{2 \cdot a} \]
      13. lift-*.f6476.9

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{\color{blue}{a + a}} \]
      16. lower-+.f6476.9

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

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

    if 3.19999999999999987e89 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6495.3

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites95.3%

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

Alternative 3: 85.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6489.6

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

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

    if -2.7999999999999999e-17 < b < 3.19999999999999987e89

    1. Initial program 76.9%

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

    if 3.19999999999999987e89 < b

    1. Initial program 55.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6495.3

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites95.3%

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

Alternative 4: 80.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{-91}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 19.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6484.4

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

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

    if -1.89999999999999989e-91 < b < 1.5e-98

    1. Initial program 75.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}}{2 \cdot a} \]
      13. lift-*.f6475.0

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{\color{blue}{a + a}} \]
      16. lower-+.f6475.0

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\left(a \cdot -4\right) \cdot c}}{a + a} \]
    6. Applied rewrites70.8%

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

    if 1.5e-98 < b

    1. Initial program 69.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6483.2

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites83.2%

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

Alternative 5: 79.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6489.6

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

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

    if -2.7999999999999999e-17 < b < 6.1999999999999999e-109

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}}{2 \cdot a} \]
      13. lift-*.f6469.3

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\sqrt{a \cdot c} \cdot \sqrt{-4}\right)}{a + a} \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{-1 \cdot \left(\sqrt{a \cdot c} \cdot \sqrt{-4}\right)}{a + a} \]
      6. pow2N/A

        \[\leadsto \frac{-1 \cdot \left(\sqrt{a \cdot c} \cdot \sqrt{-4}\right)}{a + a} \]
      7. mul-1-negN/A

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

        \[\leadsto \frac{-\sqrt{a \cdot c} \cdot \sqrt{-4}}{a + a} \]
      9. sqrt-unprodN/A

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

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(a \cdot -4\right) \cdot c}}{a + a} \]
      15. lower-*.f6465.0

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

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

    if 6.1999999999999999e-109 < b

    1. Initial program 70.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6482.5

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites82.5%

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

Alternative 6: 79.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-17}:\\
\;\;\;\;-\frac{c}{b}\\

\mathbf{elif}\;b \leq 6.2 \cdot 10^{-109}:\\
\;\;\;\;\sqrt{\frac{-1}{c \cdot a}} \cdot c\\

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


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

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6489.6

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

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

    if -2.7999999999999999e-17 < b < 6.1999999999999999e-109

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{-1}{c \cdot a}} \cdot c \]
      9. lift-*.f6464.3

        \[\leadsto \sqrt{\frac{-1}{c \cdot a}} \cdot c \]
    10. Applied rewrites64.3%

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

    if 6.1999999999999999e-109 < b

    1. Initial program 70.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6482.5

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites82.5%

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

Alternative 7: 71.0% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-158}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 24.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6479.1

        \[\leadsto -\frac{c}{b} \]
    4. Applied rewrites79.1%

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

    if -2.2999999999999999e-158 < b < 1.85000000000000005e-196

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1}\right)} \]
    6. 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-prodN/A

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

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

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

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

        \[\leadsto -\sqrt{-\frac{c}{a}} \]
      8. lift-/.f6435.6

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

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

    if 1.85000000000000005e-196 < b

    1. Initial program 71.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6475.3

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites75.3%

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

Alternative 8: 70.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-158}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 24.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6479.1

        \[\leadsto -\frac{c}{b} \]
    4. Applied rewrites79.1%

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

    if -2.2999999999999999e-158 < b < 1.85000000000000005e-196

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{\frac{c}{a}} \cdot \sqrt{-1}\right)} \]
    6. 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-prodN/A

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

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

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

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

        \[\leadsto -\sqrt{-\frac{c}{a}} \]
      8. lift-/.f6435.6

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

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

    if 1.85000000000000005e-196 < b

    1. Initial program 71.7%

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

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

        \[\leadsto \frac{-b}{a} \]
      4. lower-/.f6474.8

        \[\leadsto \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites74.8%

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

Alternative 9: 70.3% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-91}:\\
\;\;\;\;-\frac{c}{b}\\

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

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


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

    1. Initial program 19.5%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6484.4

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

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

    if -1.24999999999999999e-91 < b < 1.19999999999999993e-223

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, \color{blue}{b \cdot b}\right)}}{2 \cdot a} \]
      13. lift-*.f6471.8

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}{\color{blue}{a + a}} \]
      16. lower-+.f6471.8

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{c}{a}} \cdot \sqrt{-1}} \]
    5. Step-by-step derivation
      1. Applied rewrites34.3%

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

      if 1.19999999999999993e-223 < b

      1. Initial program 72.0%

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

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

          \[\leadsto \frac{-b}{a} \]
        4. lower-/.f6472.3

          \[\leadsto \frac{-b}{\color{blue}{a}} \]
      4. Applied rewrites72.3%

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

    Alternative 10: 67.1% accurate, 2.6× speedup?

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

      1. Initial program 31.8%

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

        \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
      3. Step-by-step derivation
        1. mul-1-negN/A

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

          \[\leadsto -\frac{c}{b} \]
        3. lower-/.f6468.8

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

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

      if -1.3e-296 < b

      1. Initial program 72.2%

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

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

          \[\leadsto \frac{-b}{a} \]
        4. lower-/.f6465.6

          \[\leadsto \frac{-b}{\color{blue}{a}} \]
      4. Applied rewrites65.6%

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

    Alternative 11: 34.6% accurate, 4.5× 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(-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.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto -\frac{c}{b} \]
      3. lower-/.f6434.6

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

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

    Alternative 12: 10.8% accurate, 5.5× 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.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{c}{b} + \frac{-b}{a} \]
      7. lower-/.f6435.0

        \[\leadsto \frac{c}{b} + \frac{-b}{\color{blue}{a}} \]
    4. Applied rewrites35.0%

      \[\leadsto \color{blue}{\frac{c}{b} + \frac{-b}{a}} \]
    5. Taylor expanded in a around inf

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

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

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

    Developer Target 1: 70.5% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\ \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
       (if (< b 0.0)
         (/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
         (/ (- (- b) t_0) (* 2.0 a)))))
    double code(double a, double b, double c) {
    	double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
    	double tmp;
    	if (b < 0.0) {
    		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
    	} else {
    		tmp = (-b - t_0) / (2.0 * a);
    	}
    	return tmp;
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(a, b, c)
    use fmin_fmax_functions
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        real(8) :: t_0
        real(8) :: tmp
        t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
        if (b < 0.0d0) then
            tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
        else
            tmp = (-b - t_0) / (2.0d0 * a)
        end if
        code = tmp
    end function
    
    public static double code(double a, double b, double c) {
    	double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
    	double tmp;
    	if (b < 0.0) {
    		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
    	} else {
    		tmp = (-b - t_0) / (2.0 * a);
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	t_0 = math.sqrt(((b * b) - (4.0 * (a * c))))
    	tmp = 0
    	if b < 0.0:
    		tmp = c / (a * ((-b + t_0) / (2.0 * a)))
    	else:
    		tmp = (-b - t_0) / (2.0 * a)
    	return tmp
    
    function code(a, b, c)
    	t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))
    	tmp = 0.0
    	if (b < 0.0)
    		tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a))));
    	else
    		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, b, c)
    	t_0 = sqrt(((b * b) - (4.0 * (a * c))));
    	tmp = 0.0;
    	if (b < 0.0)
    		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
    	else
    		tmp = (-b - t_0) / (2.0 * a);
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
    \mathbf{if}\;b < 0:\\
    \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
    
    
    \end{array}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2025117 
    (FPCore (a b c)
      :name "The quadratic formula (r2)"
      :precision binary64
    
      :alt
      (! :herbie-platform c (let ((d (sqrt (- (* b b) (* 4 (* a c)))))) (let ((r1 (/ (+ (- b) d) (* 2 a)))) (let ((r2 (/ (- (- b) d) (* 2 a)))) (if (< b 0) (/ c (* a r1)) r2)))))
    
      (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))