quadm (p42, negative)

Percentage Accurate: 53.6% → 86.9%
Time: 4.9s
Alternatives: 7
Speedup: N/A×

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 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: 53.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: 86.9% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\left|b\right|\right)}^{1}\\ \mathbf{if}\;b \leq -16500000000000:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \mathbf{elif}\;b \leq -4.6 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -0.5, \frac{{\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.5}}{a \cdot 2}\right)}\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+129}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (fabs b) 1.0)))
   (if (<= b -16500000000000.0)
     (* (/ c b) -1.0)
     (if (<= b -4.6e-142)
       (/
        (/ c a)
        (fma
         (/ b a)
         -0.5
         (/ (pow (fma t_0 t_0 (* (* c a) -4.0)) 0.5) (* a 2.0))))
       (if (<= b 2e+129)
         (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a))
         (fma (/ b a) -1.0 (/ c b)))))))
double code(double a, double b, double c) {
	double t_0 = pow(fabs(b), 1.0);
	double tmp;
	if (b <= -16500000000000.0) {
		tmp = (c / b) * -1.0;
	} else if (b <= -4.6e-142) {
		tmp = (c / a) / fma((b / a), -0.5, (pow(fma(t_0, t_0, ((c * a) * -4.0)), 0.5) / (a * 2.0)));
	} else if (b <= 2e+129) {
		tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
	} else {
		tmp = fma((b / a), -1.0, (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = abs(b) ^ 1.0
	tmp = 0.0
	if (b <= -16500000000000.0)
		tmp = Float64(Float64(c / b) * -1.0);
	elseif (b <= -4.6e-142)
		tmp = Float64(Float64(c / a) / fma(Float64(b / a), -0.5, Float64((fma(t_0, t_0, Float64(Float64(c * a) * -4.0)) ^ 0.5) / Float64(a * 2.0))));
	elseif (b <= 2e+129)
		tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a));
	else
		tmp = fma(Float64(b / a), -1.0, Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[Abs[b], $MachinePrecision], 1.0], $MachinePrecision]}, If[LessEqual[b, -16500000000000.0], N[(N[(c / b), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[b, -4.6e-142], N[(N[(c / a), $MachinePrecision] / N[(N[(b / a), $MachinePrecision] * -0.5 + N[(N[Power[N[(t$95$0 * t$95$0 + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+129], 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[(b / a), $MachinePrecision] * -1.0 + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\left|b\right|\right)}^{1}\\
\mathbf{if}\;b \leq -16500000000000:\\
\;\;\;\;\frac{c}{b} \cdot -1\\

\mathbf{elif}\;b \leq -4.6 \cdot 10^{-142}:\\
\;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -0.5, \frac{{\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.5}}{a \cdot 2}\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -1.65e13

    1. Initial program 14.0%

      \[\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. *-commutativeN/A

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

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

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

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

    if -1.65e13 < b < -4.60000000000000005e-142

    1. Initial program 46.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\mathsf{fma}\left(\frac{b}{a}, \frac{-1}{2}, \frac{{\left(\mathsf{fma}\left({\left(\left|b\right|\right)}^{1}, {\left(\left|b\right|\right)}^{1}, \left(c \cdot a\right) \cdot -4\right)\right)}^{\frac{1}{2}}}{a \cdot 2}\right)} \]
    6. Step-by-step derivation
      1. lower-/.f6469.7

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

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

    if -4.60000000000000005e-142 < b < 2e129

    1. Initial program 84.4%

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

    if 2e129 < b

    1. Initial program 48.1%

      \[\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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 2: 86.9% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\left|b\right|\right)}^{1}\\ \mathbf{if}\;b \leq -16500000000000:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \mathbf{elif}\;b \leq -4.6 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -0.5, \frac{{\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.5}}{a \cdot 2}\right)}\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+129}:\\ \;\;\;\;\frac{-1 \cdot b}{2 \cdot a} - \frac{{\left(\mathsf{fma}\left({b}^{1}, {b}^{1}, -4 \cdot \left(c \cdot a\right)\right)\right)}^{0.5}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (fabs b) 1.0)))
   (if (<= b -16500000000000.0)
     (* (/ c b) -1.0)
     (if (<= b -4.6e-142)
       (/
        (/ c a)
        (fma
         (/ b a)
         -0.5
         (/ (pow (fma t_0 t_0 (* (* c a) -4.0)) 0.5) (* a 2.0))))
       (if (<= b 2e+129)
         (-
          (/ (* -1.0 b) (* 2.0 a))
          (/
           (pow (fma (pow b 1.0) (pow b 1.0) (* -4.0 (* c a))) 0.5)
           (* 2.0 a)))
         (fma (/ b a) -1.0 (/ c b)))))))
double code(double a, double b, double c) {
	double t_0 = pow(fabs(b), 1.0);
	double tmp;
	if (b <= -16500000000000.0) {
		tmp = (c / b) * -1.0;
	} else if (b <= -4.6e-142) {
		tmp = (c / a) / fma((b / a), -0.5, (pow(fma(t_0, t_0, ((c * a) * -4.0)), 0.5) / (a * 2.0)));
	} else if (b <= 2e+129) {
		tmp = ((-1.0 * b) / (2.0 * a)) - (pow(fma(pow(b, 1.0), pow(b, 1.0), (-4.0 * (c * a))), 0.5) / (2.0 * a));
	} else {
		tmp = fma((b / a), -1.0, (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = abs(b) ^ 1.0
	tmp = 0.0
	if (b <= -16500000000000.0)
		tmp = Float64(Float64(c / b) * -1.0);
	elseif (b <= -4.6e-142)
		tmp = Float64(Float64(c / a) / fma(Float64(b / a), -0.5, Float64((fma(t_0, t_0, Float64(Float64(c * a) * -4.0)) ^ 0.5) / Float64(a * 2.0))));
	elseif (b <= 2e+129)
		tmp = Float64(Float64(Float64(-1.0 * b) / Float64(2.0 * a)) - Float64((fma((b ^ 1.0), (b ^ 1.0), Float64(-4.0 * Float64(c * a))) ^ 0.5) / Float64(2.0 * a)));
	else
		tmp = fma(Float64(b / a), -1.0, Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[Abs[b], $MachinePrecision], 1.0], $MachinePrecision]}, If[LessEqual[b, -16500000000000.0], N[(N[(c / b), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[b, -4.6e-142], N[(N[(c / a), $MachinePrecision] / N[(N[(b / a), $MachinePrecision] * -0.5 + N[(N[Power[N[(t$95$0 * t$95$0 + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+129], N[(N[(N[(-1.0 * b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[(N[Power[b, 1.0], $MachinePrecision] * N[Power[b, 1.0], $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / a), $MachinePrecision] * -1.0 + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\left|b\right|\right)}^{1}\\
\mathbf{if}\;b \leq -16500000000000:\\
\;\;\;\;\frac{c}{b} \cdot -1\\

\mathbf{elif}\;b \leq -4.6 \cdot 10^{-142}:\\
\;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -0.5, \frac{{\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.5}}{a \cdot 2}\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -1.65e13

    1. Initial program 14.0%

      \[\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. *-commutativeN/A

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

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

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

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

    if -1.65e13 < b < -4.60000000000000005e-142

    1. Initial program 46.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\mathsf{fma}\left(\frac{b}{a}, \frac{-1}{2}, \frac{{\left(\mathsf{fma}\left({\left(\left|b\right|\right)}^{1}, {\left(\left|b\right|\right)}^{1}, \left(c \cdot a\right) \cdot -4\right)\right)}^{\frac{1}{2}}}{a \cdot 2}\right)} \]
    6. Step-by-step derivation
      1. lower-/.f6469.7

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

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

    if -4.60000000000000005e-142 < b < 2e129

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

    if 2e129 < b

    1. Initial program 48.1%

      \[\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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 84.9% accurate, N/A× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-120}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


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

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

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

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

        \[\leadsto \frac{c}{b} \cdot -1 \]
    4. Applied rewrites80.6%

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

    if -5.5000000000000001e-120 < b < 2e129

    1. Initial program 83.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

    if 2e129 < b

    1. Initial program 48.1%

      \[\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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 84.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\left|b\right|\right)}^{1}\\ t_1 := {\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.25}\\ \mathbf{if}\;b \leq -5.5 \cdot 10^{-120}:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+129}:\\ \;\;\;\;\frac{-1 \cdot b}{2 \cdot a} - \frac{t\_1 \cdot t\_1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (fabs b) 1.0))
        (t_1 (pow (fma t_0 t_0 (* (* c a) -4.0)) 0.25)))
   (if (<= b -5.5e-120)
     (* (/ c b) -1.0)
     (if (<= b 1.8e+129)
       (- (/ (* -1.0 b) (* 2.0 a)) (/ (* t_1 t_1) (* 2.0 a)))
       (fma (/ b a) -1.0 (/ c b))))))
double code(double a, double b, double c) {
	double t_0 = pow(fabs(b), 1.0);
	double t_1 = pow(fma(t_0, t_0, ((c * a) * -4.0)), 0.25);
	double tmp;
	if (b <= -5.5e-120) {
		tmp = (c / b) * -1.0;
	} else if (b <= 1.8e+129) {
		tmp = ((-1.0 * b) / (2.0 * a)) - ((t_1 * t_1) / (2.0 * a));
	} else {
		tmp = fma((b / a), -1.0, (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = abs(b) ^ 1.0
	t_1 = fma(t_0, t_0, Float64(Float64(c * a) * -4.0)) ^ 0.25
	tmp = 0.0
	if (b <= -5.5e-120)
		tmp = Float64(Float64(c / b) * -1.0);
	elseif (b <= 1.8e+129)
		tmp = Float64(Float64(Float64(-1.0 * b) / Float64(2.0 * a)) - Float64(Float64(t_1 * t_1) / Float64(2.0 * a)));
	else
		tmp = fma(Float64(b / a), -1.0, Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[Abs[b], $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(t$95$0 * t$95$0 + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[b, -5.5e-120], N[(N[(c / b), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[b, 1.8e+129], N[(N[(N[(-1.0 * b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$1 * t$95$1), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / a), $MachinePrecision] * -1.0 + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\left|b\right|\right)}^{1}\\
t_1 := {\left(\mathsf{fma}\left(t\_0, t\_0, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.25}\\
\mathbf{if}\;b \leq -5.5 \cdot 10^{-120}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\

\mathbf{elif}\;b \leq 1.8 \cdot 10^{+129}:\\
\;\;\;\;\frac{-1 \cdot b}{2 \cdot a} - \frac{t\_1 \cdot t\_1}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


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

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

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

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

        \[\leadsto \frac{c}{b} \cdot -1 \]
    4. Applied rewrites80.6%

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

    if -5.5000000000000001e-120 < b < 1.8000000000000001e129

    1. Initial program 83.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8000000000000001e129 < b

    1. Initial program 48.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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 84.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.25}\\ \mathbf{if}\;b \leq -5.5 \cdot 10^{-120}:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+129}:\\ \;\;\;\;\frac{-1 \cdot b}{2 \cdot a} - \frac{t\_0}{2} \cdot \frac{t\_0}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (fma b b (* (* c a) -4.0)) 0.25)))
   (if (<= b -5.5e-120)
     (* (/ c b) -1.0)
     (if (<= b 1.8e+129)
       (- (/ (* -1.0 b) (* 2.0 a)) (* (/ t_0 2.0) (/ t_0 a)))
       (fma (/ b a) -1.0 (/ c b))))))
double code(double a, double b, double c) {
	double t_0 = pow(fma(b, b, ((c * a) * -4.0)), 0.25);
	double tmp;
	if (b <= -5.5e-120) {
		tmp = (c / b) * -1.0;
	} else if (b <= 1.8e+129) {
		tmp = ((-1.0 * b) / (2.0 * a)) - ((t_0 / 2.0) * (t_0 / a));
	} else {
		tmp = fma((b / a), -1.0, (c / b));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(b, b, Float64(Float64(c * a) * -4.0)) ^ 0.25
	tmp = 0.0
	if (b <= -5.5e-120)
		tmp = Float64(Float64(c / b) * -1.0);
	elseif (b <= 1.8e+129)
		tmp = Float64(Float64(Float64(-1.0 * b) / Float64(2.0 * a)) - Float64(Float64(t_0 / 2.0) * Float64(t_0 / a)));
	else
		tmp = fma(Float64(b / a), -1.0, Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(b * b + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[b, -5.5e-120], N[(N[(c / b), $MachinePrecision] * -1.0), $MachinePrecision], If[LessEqual[b, 1.8e+129], N[(N[(N[(-1.0 * b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 / 2.0), $MachinePrecision] * N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / a), $MachinePrecision] * -1.0 + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}^{0.25}\\
\mathbf{if}\;b \leq -5.5 \cdot 10^{-120}:\\
\;\;\;\;\frac{c}{b} \cdot -1\\

\mathbf{elif}\;b \leq 1.8 \cdot 10^{+129}:\\
\;\;\;\;\frac{-1 \cdot b}{2 \cdot a} - \frac{t\_0}{2} \cdot \frac{t\_0}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


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

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

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

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

        \[\leadsto \frac{c}{b} \cdot -1 \]
    4. Applied rewrites80.6%

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

    if -5.5000000000000001e-120 < b < 1.8000000000000001e129

    1. Initial program 83.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(b\right)}{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{\mathsf{neg}\left(b\right)}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
      12. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8000000000000001e129 < b

    1. Initial program 48.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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 66.4% accurate, N/A× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)\\


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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 73.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{b}{a} \cdot -1 + \frac{\color{blue}{c}}{b} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 33.3% accurate, N/A× speedup?

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

\\
\frac{c}{b} \cdot -1
\end{array}
Derivation
  1. Initial program 53.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. *-commutativeN/A

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

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

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

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

Reproduce

?
herbie shell --seed 2025093 
(FPCore (a b c)
  :name "quadm (p42, negative)"
  :precision binary64
  :herbie-expected 10
  (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))