Quadratic roots, narrow range

Percentage Accurate: 55.4% → 99.4%
Time: 6.6s
Alternatives: 12
Speedup: 4.3×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
(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]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 55.4% accurate, 1.0× speedup?

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

Alternative 1: 99.4% accurate, 0.7× speedup?

\[\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{-0.5}{a}, \sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, \frac{b}{a \cdot -2}\right)} \]
(FPCore (a b c)
  :precision binary64
  (/
 (/ c a)
 (fma (/ -0.5 a) (sqrt (fma (* -4.0 c) a (* b b))) (/ b (* a -2.0)))))
double code(double a, double b, double c) {
	return (c / a) / fma((-0.5 / a), sqrt(fma((-4.0 * c), a, (b * b))), (b / (a * -2.0)));
}
function code(a, b, c)
	return Float64(Float64(c / a) / fma(Float64(-0.5 / a), sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))), Float64(b / Float64(a * -2.0))))
end
code[a_, b_, c_] := N[(N[(c / a), $MachinePrecision] / N[(N[(-0.5 / a), $MachinePrecision] * N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(b / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{-0.5}{a}, \sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, \frac{b}{a \cdot -2}\right)}
Derivation
  1. Initial program 55.4%

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

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

    \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\frac{b}{-2 \cdot a} + \sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} \cdot \frac{-0.5}{a}} \]
  4. Step-by-step derivation
    1. lower-/.f6499.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.3% accurate, 0.7× speedup?

\[\frac{\frac{c}{a}}{\frac{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, -0.5, -0.5 \cdot b\right)}{a}} \]
(FPCore (a b c)
  :precision binary64
  (/
 (/ c a)
 (/ (fma (sqrt (fma (* -4.0 c) a (* b b))) -0.5 (* -0.5 b)) a)))
double code(double a, double b, double c) {
	return (c / a) / (fma(sqrt(fma((-4.0 * c), a, (b * b))), -0.5, (-0.5 * b)) / a);
}
function code(a, b, c)
	return Float64(Float64(c / a) / Float64(fma(sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))), -0.5, Float64(-0.5 * b)) / a))
end
code[a_, b_, c_] := N[(N[(c / a), $MachinePrecision] / N[(N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\frac{\frac{c}{a}}{\frac{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, -0.5, -0.5 \cdot b\right)}{a}}
Derivation
  1. Initial program 55.4%

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

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

    \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\frac{b}{-2 \cdot a} + \sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} \cdot \frac{-0.5}{a}} \]
  4. Step-by-step derivation
    1. lower-/.f6499.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.3% accurate, 0.8× speedup?

\[\frac{a \cdot -2}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, 1, b\right)} \cdot \frac{c}{a} \]
(FPCore (a b c)
  :precision binary64
  (*
 (/ (* a -2.0) (fma (sqrt (fma (* -4.0 c) a (* b b))) 1.0 b))
 (/ c a)))
double code(double a, double b, double c) {
	return ((a * -2.0) / fma(sqrt(fma((-4.0 * c), a, (b * b))), 1.0, b)) * (c / a);
}
function code(a, b, c)
	return Float64(Float64(Float64(a * -2.0) / fma(sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))), 1.0, b)) * Float64(c / a))
end
code[a_, b_, c_] := N[(N[(N[(a * -2.0), $MachinePrecision] / N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0 + b), $MachinePrecision]), $MachinePrecision] * N[(c / a), $MachinePrecision]), $MachinePrecision]
\frac{a \cdot -2}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, 1, b\right)} \cdot \frac{c}{a}
Derivation
  1. Initial program 55.4%

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

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

    \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\frac{b}{-2 \cdot a} + \sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} \cdot \frac{-0.5}{a}} \]
  4. Step-by-step derivation
    1. lower-/.f6499.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.3% accurate, 0.8× speedup?

\[\frac{\frac{c}{a}}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, 1, b\right)} \cdot \left(a \cdot -2\right) \]
(FPCore (a b c)
  :precision binary64
  (*
 (/ (/ c a) (fma (sqrt (fma (* -4.0 c) a (* b b))) 1.0 b))
 (* a -2.0)))
double code(double a, double b, double c) {
	return ((c / a) / fma(sqrt(fma((-4.0 * c), a, (b * b))), 1.0, b)) * (a * -2.0);
}
function code(a, b, c)
	return Float64(Float64(Float64(c / a) / fma(sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))), 1.0, b)) * Float64(a * -2.0))
end
code[a_, b_, c_] := N[(N[(N[(c / a), $MachinePrecision] / N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0 + b), $MachinePrecision]), $MachinePrecision] * N[(a * -2.0), $MachinePrecision]), $MachinePrecision]
\frac{\frac{c}{a}}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}, 1, b\right)} \cdot \left(a \cdot -2\right)
Derivation
  1. Initial program 55.4%

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

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

    \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\frac{b}{-2 \cdot a} + \sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} \cdot \frac{-0.5}{a}} \]
  4. Step-by-step derivation
    1. lower-/.f6499.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.0% accurate, 0.4× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 55.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

        \[\leadsto \mathsf{neg}\left(\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right) \]
      5. div-addN/A

        \[\leadsto \mathsf{neg}\left(\left(\frac{c}{b} + \frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      6. distribute-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{c}{b}\right)\right) + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      7. distribute-neg-frac2N/A

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      8. remove-double-negN/A

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(-c\right)\right)}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      10. mult-flipN/A

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

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      12. remove-double-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto c \cdot \frac{-1}{b} + \left(\mathsf{neg}\left(\frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b}\right)\right) \]
      4. sub-flip-reverseN/A

        \[\leadsto c \cdot \frac{-1}{b} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right) \cdot b}} \]
      5. lower--.f6481.3%

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

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

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

        \[\leadsto c \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot \color{blue}{b}\right) \cdot b} \]
      9. metadata-evalN/A

        \[\leadsto c \cdot \frac{1}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      10. mult-flip-revN/A

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

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right)} \cdot b} \]
      12. lower-neg.f6481.4%

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

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

        \[\leadsto \frac{c}{-b} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      15. associate-/l*N/A

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

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

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot \color{blue}{c}\right) \]
      18. lower-/.f6481.4%

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot c\right) \]
    11. Applied rewrites81.4%

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

Alternative 6: 85.0% accurate, 0.5× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 55.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c\right)}}{2 \cdot a} \]
      18. metadata-eval55.5%

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

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

    if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

        \[\leadsto \mathsf{neg}\left(\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right) \]
      5. div-addN/A

        \[\leadsto \mathsf{neg}\left(\left(\frac{c}{b} + \frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      6. distribute-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{c}{b}\right)\right) + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      7. distribute-neg-frac2N/A

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      8. remove-double-negN/A

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(-c\right)\right)}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      10. mult-flipN/A

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

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      12. remove-double-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto c \cdot \frac{-1}{b} + \left(\mathsf{neg}\left(\frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b}\right)\right) \]
      4. sub-flip-reverseN/A

        \[\leadsto c \cdot \frac{-1}{b} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right) \cdot b}} \]
      5. lower--.f6481.3%

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

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

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

        \[\leadsto c \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot \color{blue}{b}\right) \cdot b} \]
      9. metadata-evalN/A

        \[\leadsto c \cdot \frac{1}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      10. mult-flip-revN/A

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

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right)} \cdot b} \]
      12. lower-neg.f6481.4%

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

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

        \[\leadsto \frac{c}{-b} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      15. associate-/l*N/A

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

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

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot \color{blue}{c}\right) \]
      18. lower-/.f6481.4%

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot c\right) \]
    11. Applied rewrites81.4%

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

Alternative 7: 85.0% accurate, 0.5× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 55.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

        \[\leadsto \mathsf{neg}\left(\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right) \]
      5. div-addN/A

        \[\leadsto \mathsf{neg}\left(\left(\frac{c}{b} + \frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      6. distribute-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{c}{b}\right)\right) + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      7. distribute-neg-frac2N/A

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      8. remove-double-negN/A

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(-c\right)\right)}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      10. mult-flipN/A

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

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(b\right)} + \left(\mathsf{neg}\left(\frac{\frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right)\right) \]
      12. remove-double-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto c \cdot \frac{-1}{b} + \left(\mathsf{neg}\left(\frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b}\right)\right) \]
      4. sub-flip-reverseN/A

        \[\leadsto c \cdot \frac{-1}{b} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right) \cdot b}} \]
      5. lower--.f6481.3%

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

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

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

        \[\leadsto c \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot \color{blue}{b}\right) \cdot b} \]
      9. metadata-evalN/A

        \[\leadsto c \cdot \frac{1}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      10. mult-flip-revN/A

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

        \[\leadsto \frac{c}{\mathsf{neg}\left(b\right)} - \frac{\left(c \cdot c\right) \cdot a}{\color{blue}{\left(b \cdot b\right)} \cdot b} \]
      12. lower-neg.f6481.4%

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

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

        \[\leadsto \frac{c}{-b} - \frac{\left(c \cdot c\right) \cdot a}{\left(b \cdot b\right) \cdot b} \]
      15. associate-/l*N/A

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

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

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot \color{blue}{c}\right) \]
      18. lower-/.f6481.4%

        \[\leadsto \frac{c}{-b} - \frac{a}{\left(b \cdot b\right) \cdot b} \cdot \left(c \cdot c\right) \]
    11. Applied rewrites81.4%

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

Alternative 8: 85.0% accurate, 0.5× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 55.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      2. +-commutativeN/A

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

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
      4. lift-pow.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
      5. pow2N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      6. lift-*.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      8. associate-/l*N/A

        \[\leadsto -1 \cdot \frac{a \cdot \frac{{c}^{2}}{b \cdot b} + c}{b} \]
      9. *-commutativeN/A

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

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

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

        \[\leadsto -1 \cdot \frac{\mathsf{fma}\left(\frac{c \cdot c}{b \cdot b}, a, c\right)}{b} \]
      13. associate-/l*N/A

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

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

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

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

Alternative 9: 85.0% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -0.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} - b}{a + a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{\mathsf{fma}\left(c \cdot \frac{c}{b \cdot b}, a, c\right)}{b}\\ \end{array} \]
(FPCore (a b c)
  :precision binary64
  (if (<=
     (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))
     -0.4)
  (/ (- (sqrt (fma (* c -4.0) a (* b b))) b) (+ a a))
  (* -1.0 (/ (fma (* c (/ c (* b b))) a c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)) <= -0.4) {
		tmp = (sqrt(fma((c * -4.0), a, (b * b))) - b) / (a + a);
	} else {
		tmp = -1.0 * (fma((c * (c / (b * b))), a, c) / b);
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) <= -0.4)
		tmp = Float64(Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) - b) / Float64(a + a));
	else
		tmp = Float64(-1.0 * Float64(fma(Float64(c * Float64(c / Float64(b * b))), a, c) / b));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[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], -0.4], N[(N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(N[(c * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -0.4:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} - b}{a + a}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.40000000000000002

    1. Initial program 55.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Step-by-step derivation
      1. Applied rewrites55.4%

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

      if -0.40000000000000002 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

      1. Initial program 55.4%

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

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

          \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
      4. Applied rewrites90.8%

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

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

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

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

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

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

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

          \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
        7. lower-pow.f6481.4%

          \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. Applied rewrites81.4%

        \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
      8. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
        2. +-commutativeN/A

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

          \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
        4. lift-pow.f64N/A

          \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
        5. pow2N/A

          \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
        6. lift-*.f64N/A

          \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
        7. lift-*.f64N/A

          \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
        8. associate-/l*N/A

          \[\leadsto -1 \cdot \frac{a \cdot \frac{{c}^{2}}{b \cdot b} + c}{b} \]
        9. *-commutativeN/A

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

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

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

          \[\leadsto -1 \cdot \frac{\mathsf{fma}\left(\frac{c \cdot c}{b \cdot b}, a, c\right)}{b} \]
        13. associate-/l*N/A

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

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

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

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

    Alternative 10: 81.4% accurate, 1.1× speedup?

    \[-1 \cdot \frac{\mathsf{fma}\left(c \cdot \frac{c}{b \cdot b}, a, c\right)}{b} \]
    (FPCore (a b c)
      :precision binary64
      (* -1.0 (/ (fma (* c (/ c (* b b))) a c) b)))
    double code(double a, double b, double c) {
    	return -1.0 * (fma((c * (c / (b * b))), a, c) / b);
    }
    
    function code(a, b, c)
    	return Float64(-1.0 * Float64(fma(Float64(c * Float64(c / Float64(b * b))), a, c) / b))
    end
    
    code[a_, b_, c_] := N[(-1.0 * N[(N[(N[(c * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
    
    -1 \cdot \frac{\mathsf{fma}\left(c \cdot \frac{c}{b \cdot b}, a, c\right)}{b}
    
    Derivation
    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      2. +-commutativeN/A

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

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
      4. lift-pow.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{{b}^{2}} + c}{b} \]
      5. pow2N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      6. lift-*.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      7. lift-*.f64N/A

        \[\leadsto -1 \cdot \frac{\frac{a \cdot {c}^{2}}{b \cdot b} + c}{b} \]
      8. associate-/l*N/A

        \[\leadsto -1 \cdot \frac{a \cdot \frac{{c}^{2}}{b \cdot b} + c}{b} \]
      9. *-commutativeN/A

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

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

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

        \[\leadsto -1 \cdot \frac{\mathsf{fma}\left(\frac{c \cdot c}{b \cdot b}, a, c\right)}{b} \]
      13. associate-/l*N/A

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

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

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

      \[\leadsto -1 \cdot \frac{\mathsf{fma}\left(c \cdot \frac{c}{b \cdot b}, a, c\right)}{b} \]
    10. Add Preprocessing

    Alternative 11: 81.4% accurate, 1.2× speedup?

    \[\frac{\mathsf{fma}\left(c \cdot c, \frac{a}{b \cdot b}, c\right)}{-b} \]
    (FPCore (a b c)
      :precision binary64
      (/ (fma (* c c) (/ a (* b b)) c) (- b)))
    double code(double a, double b, double c) {
    	return fma((c * c), (a / (b * b)), c) / -b;
    }
    
    function code(a, b, c)
    	return Float64(fma(Float64(c * c), Float64(a / Float64(b * b)), c) / Float64(-b))
    end
    
    code[a_, b_, c_] := N[(N[(N[(c * c), $MachinePrecision] * N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision] / (-b)), $MachinePrecision]
    
    \frac{\mathsf{fma}\left(c \cdot c, \frac{a}{b \cdot b}, c\right)}{-b}
    
    Derivation
    1. Initial program 55.4%

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

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

        \[\leadsto \frac{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(-1 \cdot c + \left(-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{4} \cdot \frac{4 \cdot \left({a}^{4} \cdot {c}^{4}\right) + 16 \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{\color{blue}{b}} \]
    4. Applied rewrites90.8%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
      7. lower-pow.f6481.4%

        \[\leadsto -1 \cdot \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b} \]
    7. Applied rewrites81.4%

      \[\leadsto -1 \cdot \color{blue}{\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{b}\right) \]
      4. distribute-neg-frac2N/A

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

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

        \[\leadsto \frac{c + \frac{a \cdot {c}^{2}}{{b}^{2}}}{\mathsf{neg}\left(b\right)} \]
      7. +-commutativeN/A

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

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

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

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

        \[\leadsto \frac{\frac{{c}^{2} \cdot a}{{b}^{2}} + c}{\mathsf{neg}\left(b\right)} \]
      12. pow2N/A

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

        \[\leadsto \frac{\frac{{c}^{2} \cdot a}{b \cdot b} + c}{\mathsf{neg}\left(b\right)} \]
      14. associate-/l*N/A

        \[\leadsto \frac{{c}^{2} \cdot \frac{a}{b \cdot b} + c}{\mathsf{neg}\left(b\right)} \]
      15. lower-fma.f64N/A

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

        \[\leadsto \frac{\mathsf{fma}\left({c}^{2}, \frac{a}{b \cdot b}, c\right)}{\mathsf{neg}\left(b\right)} \]
      17. unpow2N/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left(c \cdot c, \frac{a}{b \cdot b}, c\right)}{\mathsf{neg}\left(b\right)} \]
      20. lower-neg.f6481.4%

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

      \[\leadsto \frac{\mathsf{fma}\left(c \cdot c, \frac{a}{b \cdot b}, c\right)}{-b} \]
    10. Add Preprocessing

    Alternative 12: 64.4% accurate, 4.3× speedup?

    \[\frac{-c}{b} \]
    (FPCore (a b c)
      :precision binary64
      (/ (- c) b))
    double code(double a, double b, double c) {
    	return -c / b;
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(a, b, c)
    use fmin_fmax_functions
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        code = -c / b
    end function
    
    public static double code(double a, double b, double c) {
    	return -c / b;
    }
    
    def code(a, b, c):
    	return -c / b
    
    function code(a, b, c)
    	return Float64(Float64(-c) / b)
    end
    
    function tmp = code(a, b, c)
    	tmp = -c / b;
    end
    
    code[a_, b_, c_] := N[((-c) / b), $MachinePrecision]
    
    \frac{-c}{b}
    
    Derivation
    1. Initial program 55.4%

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

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

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

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

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

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

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

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

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

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

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

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

    Reproduce

    ?
    herbie shell --seed 2025212 
    (FPCore (a b c)
      :name "Quadratic roots, narrow range"
      :precision binary64
      :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
      (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))