Complex division, real part

Percentage Accurate: 61.8% → 83.0%
Time: 7.4s
Alternatives: 10
Speedup: 1.6×

Specification

?
\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 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: 61.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}

Alternative 1: 83.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{if}\;d \leq -2.8 \cdot 10^{+74}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-154}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-157}:\\ \;\;\;\;\frac{a - \frac{\mathsf{fma}\left(-b, d, \frac{\left(d \cdot d\right) \cdot a}{c}\right)}{c}}{c}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{+94}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c)))))
   (if (<= d -2.8e+74)
     (/ (fma (/ a d) c b) d)
     (if (<= d -5e-154)
       t_0
       (if (<= d 1.4e-157)
         (/ (- a (/ (fma (- b) d (/ (* (* d d) a) c)) c)) c)
         (if (<= d 5.4e+94) t_0 (/ (fma (/ c d) a b) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
	double tmp;
	if (d <= -2.8e+74) {
		tmp = fma((a / d), c, b) / d;
	} else if (d <= -5e-154) {
		tmp = t_0;
	} else if (d <= 1.4e-157) {
		tmp = (a - (fma(-b, d, (((d * d) * a) / c)) / c)) / c;
	} else if (d <= 5.4e+94) {
		tmp = t_0;
	} else {
		tmp = fma((c / d), a, b) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
	tmp = 0.0
	if (d <= -2.8e+74)
		tmp = Float64(fma(Float64(a / d), c, b) / d);
	elseif (d <= -5e-154)
		tmp = t_0;
	elseif (d <= 1.4e-157)
		tmp = Float64(Float64(a - Float64(fma(Float64(-b), d, Float64(Float64(Float64(d * d) * a) / c)) / c)) / c);
	elseif (d <= 5.4e+94)
		tmp = t_0;
	else
		tmp = Float64(fma(Float64(c / d), a, b) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.8e+74], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -5e-154], t$95$0, If[LessEqual[d, 1.4e-157], N[(N[(a - N[(N[((-b) * d + N[(N[(N[(d * d), $MachinePrecision] * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.4e+94], t$95$0, N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+74}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 1.4 \cdot 10^{-157}:\\
\;\;\;\;\frac{a - \frac{\mathsf{fma}\left(-b, d, \frac{\left(d \cdot d\right) \cdot a}{c}\right)}{c}}{c}\\

\mathbf{elif}\;d \leq 5.4 \cdot 10^{+94}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.80000000000000002e74

    1. Initial program 40.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{d}} + b}{d} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}}{d} \]
      7. lower-/.f6478.9

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{a}{d}}, c, b\right)}{d} \]
    5. Applied rewrites78.9%

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

    if -2.80000000000000002e74 < d < -5.0000000000000002e-154 or 1.40000000000000005e-157 < d < 5.4000000000000003e94

    1. Initial program 82.3%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6482.3

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

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

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

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

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

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

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

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

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

    if -5.0000000000000002e-154 < d < 1.40000000000000005e-157

    1. Initial program 72.2%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

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

        \[\leadsto \frac{a + \left(\frac{b \cdot d}{c} + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot {d}^{2}}{{c}^{2}}\right)\right)}\right)}{c} \]
      3. unsub-negN/A

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

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

        \[\leadsto \frac{a + \left(\frac{b \cdot d}{c} - \color{blue}{\frac{\frac{a \cdot {d}^{2}}{c}}{c}}\right)}{c} \]
      6. div-subN/A

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

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

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

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

        \[\leadsto \color{blue}{\frac{a + \frac{-1 \cdot \frac{a \cdot {d}^{2}}{c} + b \cdot d}{c}}{c}} \]
    5. Applied rewrites92.8%

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

    if 5.4000000000000003e94 < d

    1. Initial program 31.6%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6431.6

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6431.6

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6431.6

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

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}} + b}{d} \]
      4. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}}{d} \]
      6. lower-/.f6486.5

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{c}{d}}, a, b\right)}{d} \]
    7. Applied rewrites86.5%

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

Alternative 2: 62.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{if}\;d \leq -1.65 \cdot 10^{+153}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -2.65 \cdot 10^{-86}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5.5 \cdot 10^{-163}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{-113}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+98}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma d b (* c a)) (* d d))))
   (if (<= d -1.65e+153)
     (/ b d)
     (if (<= d -2.65e-86)
       t_0
       (if (<= d -5.5e-163)
         (* (/ c (fma c c (* d d))) a)
         (if (<= d 7.2e-113)
           (/ (fma a c (* b d)) (* c c))
           (if (<= d 3.4e+98) t_0 (/ b d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a)) / (d * d);
	double tmp;
	if (d <= -1.65e+153) {
		tmp = b / d;
	} else if (d <= -2.65e-86) {
		tmp = t_0;
	} else if (d <= -5.5e-163) {
		tmp = (c / fma(c, c, (d * d))) * a;
	} else if (d <= 7.2e-113) {
		tmp = fma(a, c, (b * d)) / (c * c);
	} else if (d <= 3.4e+98) {
		tmp = t_0;
	} else {
		tmp = b / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(d, b, Float64(c * a)) / Float64(d * d))
	tmp = 0.0
	if (d <= -1.65e+153)
		tmp = Float64(b / d);
	elseif (d <= -2.65e-86)
		tmp = t_0;
	elseif (d <= -5.5e-163)
		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * a);
	elseif (d <= 7.2e-113)
		tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c));
	elseif (d <= 3.4e+98)
		tmp = t_0;
	else
		tmp = Float64(b / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.65e+153], N[(b / d), $MachinePrecision], If[LessEqual[d, -2.65e-86], t$95$0, If[LessEqual[d, -5.5e-163], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, 7.2e-113], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+98], t$95$0, N[(b / d), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -2.65 \cdot 10^{-86}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq -5.5 \cdot 10^{-163}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\

\mathbf{elif}\;d \leq 7.2 \cdot 10^{-113}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\

\mathbf{elif}\;d \leq 3.4 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.64999999999999997e153 or 3.39999999999999972e98 < d

    1. Initial program 27.0%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. lower-/.f6466.3

        \[\leadsto \color{blue}{\frac{b}{d}} \]
    5. Applied rewrites66.3%

      \[\leadsto \color{blue}{\frac{b}{d}} \]

    if -1.64999999999999997e153 < d < -2.6499999999999998e-86 or 7.1999999999999995e-113 < d < 3.39999999999999972e98

    1. Initial program 80.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6480.5

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6480.5

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6480.5

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Applied rewrites80.5%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d}} \]
    7. Applied rewrites63.4%

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

    if -2.6499999999999998e-86 < d < -5.4999999999999998e-163

    1. Initial program 72.3%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6472.3

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6472.3

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{{c}^{2} + {d}^{2}} \]
      2. associate-*l/N/A

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

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

        \[\leadsto \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \cdot a \]
      5. unpow2N/A

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

        \[\leadsto \frac{c}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \cdot a \]
      7. unpow2N/A

        \[\leadsto \frac{c}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot a \]
      8. lower-*.f6478.8

        \[\leadsto \frac{c}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot a \]
    7. Applied rewrites78.8%

      \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a} \]

    if -5.4999999999999998e-163 < d < 7.1999999999999995e-113

    1. Initial program 74.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

        \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{c \cdot c}} \]
      2. lower-*.f6472.2

        \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{c \cdot c}} \]
    5. Applied rewrites72.2%

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

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

        \[\leadsto \frac{\color{blue}{a \cdot c} + b \cdot d}{c \cdot c} \]
      3. lower-fma.f6472.2

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c} \]
    7. Applied rewrites72.2%

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

Alternative 3: 80.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{if}\;c \leq -5.5 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{-132}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{+93}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma (/ b c) d a) c)))
   (if (<= c -5.5e-23)
     t_0
     (if (<= c 2.65e-132)
       (/ (fma (/ c d) a b) d)
       (if (<= c 1.25e+93) (/ (fma d b (* c a)) (fma d d (* c c))) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((b / c), d, a) / c;
	double tmp;
	if (c <= -5.5e-23) {
		tmp = t_0;
	} else if (c <= 2.65e-132) {
		tmp = fma((c / d), a, b) / d;
	} else if (c <= 1.25e+93) {
		tmp = fma(d, b, (c * a)) / fma(d, d, (c * c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(Float64(b / c), d, a) / c)
	tmp = 0.0
	if (c <= -5.5e-23)
		tmp = t_0;
	elseif (c <= 2.65e-132)
		tmp = Float64(fma(Float64(c / d), a, b) / d);
	elseif (c <= 1.25e+93)
		tmp = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -5.5e-23], t$95$0, If[LessEqual[c, 2.65e-132], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.25e+93], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
\mathbf{if}\;c \leq -5.5 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 2.65 \cdot 10^{-132}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\

\mathbf{elif}\;c \leq 1.25 \cdot 10^{+93}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.5000000000000001e-23 or 1.25e93 < c

    1. Initial program 42.6%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}}{c} \]
      7. lower-/.f6474.7

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{b}{c}}, d, a\right)}{c} \]
    5. Applied rewrites74.7%

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

    if -5.5000000000000001e-23 < c < 2.65000000000000015e-132

    1. Initial program 69.9%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6469.9

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6469.9

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6469.9

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

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}} + b}{d} \]
      4. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}}{d} \]
      6. lower-/.f6490.5

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{c}{d}}, a, b\right)}{d} \]
    7. Applied rewrites90.5%

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

    if 2.65000000000000015e-132 < c < 1.25e93

    1. Initial program 84.6%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6484.6

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6484.6

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6484.6

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

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

Alternative 4: 78.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{if}\;c \leq -5.5 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 8500:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma (/ b c) d a) c)))
   (if (<= c -5.5e-23) t_0 (if (<= c 8500.0) (/ (fma (/ c d) a b) d) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((b / c), d, a) / c;
	double tmp;
	if (c <= -5.5e-23) {
		tmp = t_0;
	} else if (c <= 8500.0) {
		tmp = fma((c / d), a, b) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(Float64(b / c), d, a) / c)
	tmp = 0.0
	if (c <= -5.5e-23)
		tmp = t_0;
	elseif (c <= 8500.0)
		tmp = Float64(fma(Float64(c / d), a, b) / d);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -5.5e-23], t$95$0, If[LessEqual[c, 8500.0], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
\mathbf{if}\;c \leq -5.5 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 8500:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.5000000000000001e-23 or 8500 < c

    1. Initial program 49.3%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}}{c} \]
      7. lower-/.f6473.5

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{b}{c}}, d, a\right)}{c} \]
    5. Applied rewrites73.5%

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

    if -5.5000000000000001e-23 < c < 8500

    1. Initial program 73.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6473.7

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6473.7

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6473.7

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

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}} + b}{d} \]
      4. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}}{d} \]
      6. lower-/.f6484.2

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{c}{d}}, a, b\right)}{d} \]
    7. Applied rewrites84.2%

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

Alternative 5: 77.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{if}\;d \leq -2.6 \cdot 10^{-34}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+62}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma (/ a d) c b) d)))
   (if (<= d -2.6e-34) t_0 (if (<= d 1.45e+62) (/ (fma (/ b c) d a) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((a / d), c, b) / d;
	double tmp;
	if (d <= -2.6e-34) {
		tmp = t_0;
	} else if (d <= 1.45e+62) {
		tmp = fma((b / c), d, a) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(Float64(a / d), c, b) / d)
	tmp = 0.0
	if (d <= -2.6e-34)
		tmp = t_0;
	elseif (d <= 1.45e+62)
		tmp = Float64(fma(Float64(b / c), d, a) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.6e-34], t$95$0, If[LessEqual[d, 1.45e+62], N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 1.45 \cdot 10^{+62}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5999999999999999e-34 or 1.44999999999999992e62 < d

    1. Initial program 49.4%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{d}} + b}{d} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}}{d} \]
      7. lower-/.f6479.6

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{a}{d}}, c, b\right)}{d} \]
    5. Applied rewrites79.6%

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

    if -2.5999999999999999e-34 < d < 1.44999999999999992e62

    1. Initial program 74.9%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}}{c} \]
      7. lower-/.f6474.5

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{b}{c}}, d, a\right)}{c} \]
    5. Applied rewrites74.5%

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

Alternative 6: 67.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{if}\;d \leq -5.2 \cdot 10^{-101}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{-113}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma (/ a d) c b) d)))
   (if (<= d -5.2e-101)
     t_0
     (if (<= d 7.2e-113) (/ (fma a c (* b d)) (* c c)) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((a / d), c, b) / d;
	double tmp;
	if (d <= -5.2e-101) {
		tmp = t_0;
	} else if (d <= 7.2e-113) {
		tmp = fma(a, c, (b * d)) / (c * c);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(Float64(a / d), c, b) / d)
	tmp = 0.0
	if (d <= -5.2e-101)
		tmp = t_0;
	elseif (d <= 7.2e-113)
		tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -5.2e-101], t$95$0, If[LessEqual[d, 7.2e-113], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{-101}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 7.2 \cdot 10^{-113}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.2000000000000002e-101 or 7.1999999999999995e-113 < d

    1. Initial program 55.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in d around inf

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{d} + b}}{d} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{a}{d}} + b}{d} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}}{d} \]
      7. lower-/.f6472.0

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{a}{d}}, c, b\right)}{d} \]
    5. Applied rewrites72.0%

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

    if -5.2000000000000002e-101 < d < 7.1999999999999995e-113

    1. Initial program 75.3%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

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

        \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{c \cdot c}} \]
      2. lower-*.f6469.8

        \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{c \cdot c}} \]
    5. Applied rewrites69.8%

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

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

        \[\leadsto \frac{\color{blue}{a \cdot c} + b \cdot d}{c \cdot c} \]
      3. lower-fma.f6469.8

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c} \]
    7. Applied rewrites69.8%

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

Alternative 7: 62.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{d}{b}}\\

\mathbf{elif}\;d \leq -9 \cdot 10^{-152}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\

\mathbf{elif}\;d \leq 2.85 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.1000000000000001e-25

    1. Initial program 53.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6453.7

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6453.7

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6453.7

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Applied rewrites53.7%

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      2. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{a \cdot c + b \cdot d}}} \]
      12. lower-/.f6453.6

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

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

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{a \cdot c} + b \cdot d}} \]
      15. lower-fma.f6453.6

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}} \]
    6. Applied rewrites53.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\mathsf{fma}\left(a, c, b \cdot d\right)}}} \]
    7. Taylor expanded in c around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]
    8. Step-by-step derivation
      1. lower-/.f6460.5

        \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]
    9. Applied rewrites60.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]

    if -1.1000000000000001e-25 < d < -9.0000000000000008e-152

    1. Initial program 79.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6479.5

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6479.5

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6479.5

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Applied rewrites79.5%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{{c}^{2} + {d}^{2}} \]
      2. associate-*l/N/A

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

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

        \[\leadsto \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \cdot a \]
      5. unpow2N/A

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

        \[\leadsto \frac{c}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \cdot a \]
      7. unpow2N/A

        \[\leadsto \frac{c}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot a \]
      8. lower-*.f6474.2

        \[\leadsto \frac{c}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot a \]
    7. Applied rewrites74.2%

      \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a} \]

    if -9.0000000000000008e-152 < d < 2.85e19

    1. Initial program 75.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6462.6

        \[\leadsto \color{blue}{\frac{a}{c}} \]
    5. Applied rewrites62.6%

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

    if 2.85e19 < d

    1. Initial program 43.0%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. lower-/.f6461.0

        \[\leadsto \color{blue}{\frac{b}{d}} \]
    5. Applied rewrites61.0%

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

Alternative 8: 62.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\frac{d}{b}}\\

\mathbf{elif}\;d \leq -9.5 \cdot 10^{-152}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\

\mathbf{elif}\;d \leq 2.85 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.1000000000000001e-25

    1. Initial program 53.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
      5. lower-fma.f6453.7

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
      8. lower-*.f6453.7

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6453.7

        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Applied rewrites53.7%

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      2. clear-numN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{a \cdot c + b \cdot d}}} \]
      12. lower-/.f6453.6

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

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

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{a \cdot c} + b \cdot d}} \]
      15. lower-fma.f6453.6

        \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}} \]
    6. Applied rewrites53.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\mathsf{fma}\left(a, c, b \cdot d\right)}}} \]
    7. Taylor expanded in c around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]
    8. Step-by-step derivation
      1. lower-/.f6460.5

        \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]
    9. Applied rewrites60.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{d}{b}}} \]

    if -1.1000000000000001e-25 < d < -9.49999999999999925e-152

    1. Initial program 79.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{{c}^{2} + {d}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{c \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
      3. *-commutativeN/A

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

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

        \[\leadsto \color{blue}{\frac{a}{{c}^{2} + {d}^{2}}} \cdot c \]
      6. +-commutativeN/A

        \[\leadsto \frac{a}{\color{blue}{{d}^{2} + {c}^{2}}} \cdot c \]
      7. unpow2N/A

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \cdot c \]
      9. unpow2N/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \cdot c \]
      10. lower-*.f6459.6

        \[\leadsto \frac{a}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \cdot c \]
    5. Applied rewrites59.6%

      \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c} \]

    if -9.49999999999999925e-152 < d < 2.85e19

    1. Initial program 75.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6462.6

        \[\leadsto \color{blue}{\frac{a}{c}} \]
    5. Applied rewrites62.6%

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

    if 2.85e19 < d

    1. Initial program 43.0%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. lower-/.f6461.0

        \[\leadsto \color{blue}{\frac{b}{d}} \]
    5. Applied rewrites61.0%

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

Alternative 9: 62.9% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{-32}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-41}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -2.4e-32) (/ a c) (if (<= c 1.45e-41) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -2.4e-32) {
		tmp = a / c;
	} else if (c <= 1.45e-41) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (c <= (-2.4d-32)) then
        tmp = a / c
    else if (c <= 1.45d-41) then
        tmp = b / d
    else
        tmp = a / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -2.4e-32) {
		tmp = a / c;
	} else if (c <= 1.45e-41) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -2.4e-32:
		tmp = a / c
	elif c <= 1.45e-41:
		tmp = b / d
	else:
		tmp = a / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -2.4e-32)
		tmp = Float64(a / c);
	elseif (c <= 1.45e-41)
		tmp = Float64(b / d);
	else
		tmp = Float64(a / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -2.4e-32)
		tmp = a / c;
	elseif (c <= 1.45e-41)
		tmp = b / d;
	else
		tmp = a / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.4e-32], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.45e-41], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.4 \cdot 10^{-32}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;c \leq 1.45 \cdot 10^{-41}:\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.4000000000000001e-32 or 1.44999999999999989e-41 < c

    1. Initial program 52.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6457.4

        \[\leadsto \color{blue}{\frac{a}{c}} \]
    5. Applied rewrites57.4%

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

    if -2.4000000000000001e-32 < c < 1.44999999999999989e-41

    1. Initial program 72.8%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. lower-/.f6461.7

        \[\leadsto \color{blue}{\frac{b}{d}} \]
    5. Applied rewrites61.7%

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

Alternative 10: 43.0% accurate, 3.2× speedup?

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

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 62.1%

    \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
  2. Add Preprocessing
  3. Taylor expanded in c around inf

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  4. Step-by-step derivation
    1. lower-/.f6438.4

      \[\leadsto \color{blue}{\frac{a}{c}} \]
  5. Applied rewrites38.4%

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

Developer Target 1: 99.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
   (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024332 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))