The quadratic formula (r1)

Percentage Accurate: 52.2% → 86.0%
Time: 8.5s
Alternatives: 7
Speedup: 2.5×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 52.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 86.0% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 46.0%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites95.8%

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

    if -1.14999999999999993e158 < b < 2.35e-60

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.35e-60 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{+158}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-60}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} - b}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 81.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.4 \cdot 10^{-91}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-60}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -3.4e-91)
   (/ (- b) a)
   (if (<= b 2.35e-60)
     (/ (+ (- b) (sqrt (* -4.0 (* c a)))) (+ a a))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.4e-91) {
		tmp = -b / a;
	} else if (b <= 2.35e-60) {
		tmp = (-b + sqrt((-4.0 * (c * a)))) / (a + a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-3.4d-91)) then
        tmp = -b / a
    else if (b <= 2.35d-60) then
        tmp = (-b + sqrt(((-4.0d0) * (c * a)))) / (a + a)
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.4e-91) {
		tmp = -b / a;
	} else if (b <= 2.35e-60) {
		tmp = (-b + Math.sqrt((-4.0 * (c * a)))) / (a + a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -3.4e-91:
		tmp = -b / a
	elif b <= 2.35e-60:
		tmp = (-b + math.sqrt((-4.0 * (c * a)))) / (a + a)
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -3.4e-91)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 2.35e-60)
		tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-4.0 * Float64(c * a)))) / Float64(a + a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -3.4e-91)
		tmp = -b / a;
	elseif (b <= 2.35e-60)
		tmp = (-b + sqrt((-4.0 * (c * a)))) / (a + a);
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -3.4e-91], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.35e-60], N[(N[((-b) + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.1%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites86.0%

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

    if -3.40000000000000027e-91 < b < 2.35e-60

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

    if 2.35e-60 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

Alternative 3: 80.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.25 \cdot 10^{-117}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.35 \cdot 10^{-60}:\\ \;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.25e-117)
   (/ (- b) a)
   (if (<= b 2.35e-60) (/ (sqrt (* (* c a) -4.0)) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.25e-117) {
		tmp = -b / a;
	} else if (b <= 2.35e-60) {
		tmp = sqrt(((c * a) * -4.0)) / (a + a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-2.25d-117)) then
        tmp = -b / a
    else if (b <= 2.35d-60) then
        tmp = sqrt(((c * a) * (-4.0d0))) / (a + a)
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.25e-117) {
		tmp = -b / a;
	} else if (b <= 2.35e-60) {
		tmp = Math.sqrt(((c * a) * -4.0)) / (a + a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2.25e-117:
		tmp = -b / a
	elif b <= 2.35e-60:
		tmp = math.sqrt(((c * a) * -4.0)) / (a + a)
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.25e-117)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 2.35e-60)
		tmp = Float64(sqrt(Float64(Float64(c * a) * -4.0)) / Float64(a + a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -2.25e-117)
		tmp = -b / a;
	elseif (b <= 2.35e-60)
		tmp = sqrt(((c * a) * -4.0)) / (a + a);
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2.25e-117], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.35e-60], N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.4%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites83.9%

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

    if -2.24999999999999985e-117 < b < 2.35e-60

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.35e-60 < b

    1. Initial program 13.4%

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

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

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

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

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

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

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

Alternative 4: 74.3% accurate, 1.1× speedup?

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

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-3.35d-130)) then
        tmp = -b / a
    else if (b <= 5.5d-175) then
        tmp = sqrt(-c) / sqrt(a)
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.35e-130) {
		tmp = -b / a;
	} else if (b <= 5.5e-175) {
		tmp = Math.sqrt(-c) / Math.sqrt(a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -3.35e-130:
		tmp = -b / a
	elif b <= 5.5e-175:
		tmp = math.sqrt(-c) / math.sqrt(a)
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -3.35e-130)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 5.5e-175)
		tmp = Float64(sqrt(Float64(-c)) / sqrt(a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -3.35e-130)
		tmp = -b / a;
	elseif (b <= 5.5e-175)
		tmp = sqrt(-c) / sqrt(a);
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -3.35e-130], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.5e-175], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.6%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites83.2%

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

    if -3.34999999999999993e-130 < b < 5.50000000000000054e-175

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{-c}}{\sqrt{a}} \]
    10. Applied rewrites67.2%

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

    if 5.50000000000000054e-175 < b

    1. Initial program 20.1%

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

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

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

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

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

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

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

Alternative 5: 72.6% accurate, 1.4× speedup?

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

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

real(8) function code(a, b, c)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-3.35d-130)) then
        tmp = -b / a
    else if (b <= 2.65d-175) then
        tmp = sqrt((-c / a))
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -3.35e-130) {
		tmp = -b / a;
	} else if (b <= 2.65e-175) {
		tmp = Math.sqrt((-c / a));
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -3.35e-130:
		tmp = -b / a
	elif b <= 2.65e-175:
		tmp = math.sqrt((-c / a))
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -3.35e-130)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 2.65e-175)
		tmp = sqrt(Float64(Float64(-c) / a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -3.35e-130)
		tmp = -b / a;
	elseif (b <= 2.65e-175)
		tmp = sqrt((-c / a));
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -3.35e-130], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.65e-175], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 74.6%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites83.2%

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

    if -3.34999999999999993e-130 < b < 2.6500000000000003e-175

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6500000000000003e-175 < b

    1. Initial program 20.1%

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

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

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

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

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

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

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

Alternative 6: 68.1% accurate, 2.5× speedup?

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

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

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

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

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


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

    1. Initial program 75.5%

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

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

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

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

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

        \[\leadsto \frac{-b}{a} \]
    5. Applied rewrites70.1%

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

    if -4.999999999999985e-310 < b

    1. Initial program 26.7%

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

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

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

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

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

        \[\leadsto \frac{-c}{b} \]
    5. Applied rewrites67.5%

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

Alternative 7: 36.2% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \frac{-b}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (/ (- b) a))
double code(double a, double b, double c) {
	return -b / a;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

\\
\frac{-b}{a}
\end{array}
Derivation
  1. Initial program 52.6%

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

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

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

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

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

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\ \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \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)
     (/ (+ (- b) t_0) (* 2.0 a))
     (/ c (* 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 = (-b + t_0) / (2.0 * a);
	} else {
		tmp = c / (a * ((-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 = (-b + t_0) / (2.0d0 * a)
    else
        tmp = c / (a * ((-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 = (-b + t_0) / (2.0 * a);
	} else {
		tmp = c / (a * ((-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 = (-b + t_0) / (2.0 * a)
	else:
		tmp = c / (a * ((-b - t_0) / (2.0 * a)))
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))
	tmp = 0.0
	if (b < 0.0)
		tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a));
	else
		tmp = Float64(c / Float64(a * 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 = (-b + t_0) / (2.0 * a);
	else
		tmp = c / (a * ((-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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(c / N[(a * N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - t\_0}{2 \cdot a}}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2025043 
(FPCore (a b c)
  :name "The quadratic formula (r1)"
  :precision binary64

  :alt
  (! :herbie-platform default (let ((d (- (* b b) (* (* 4 a) c)))) (let ((r1 (/ (+ (- b) (sqrt d)) (* 2 a)))) (let ((r2 (/ (- (- b) (sqrt d)) (* 2 a)))) (if (< b 0) r1 (/ c (* a r2)))))))

  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))