Complex division, real part

Percentage Accurate: 61.4% → 90.1%
Time: 11.3s
Alternatives: 13
Speedup: 1.1×

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 13 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.4% 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: 90.1% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;c \leq 7.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.42e-62

    1. Initial program 64.1%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define64.1%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. fma-define64.1%

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

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

      \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    6. Step-by-step derivation
      1. *-commutative63.0%

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

      \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    8. Step-by-step derivation
      1. *-commutative63.0%

        \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      2. add-sqr-sqrt62.9%

        \[\leadsto \frac{\left(a + \frac{d \cdot b}{c}\right) \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
      3. times-frac63.5%

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

        \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      5. associate-/l*63.8%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      8. hypot-define63.8%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      9. fma-undefine63.8%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      10. hypot-define95.1%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    9. Applied egg-rr95.1%

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

    if -1.42e-62 < c < 7.20000000000000019e-58

    1. Initial program 72.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define72.7%

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    6. Step-by-step derivation
      1. associate-/l*87.9%

        \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
    7. Simplified87.9%

      \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

    if 7.20000000000000019e-58 < c

    1. Initial program 57.6%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define57.6%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    6. Step-by-step derivation
      1. *-commutative57.5%

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

      \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    8. Step-by-step derivation
      1. *-commutative57.5%

        \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      2. add-sqr-sqrt57.5%

        \[\leadsto \frac{\left(a + \frac{d \cdot b}{c}\right) \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
      3. times-frac60.5%

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

        \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      5. associate-/l*62.2%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      8. hypot-define62.2%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      9. fma-undefine62.2%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      10. hypot-define95.8%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    9. Applied egg-rr95.8%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}} \]
    10. Step-by-step derivation
      1. clear-num95.8%

        \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      2. un-div-inv95.8%

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
    11. Applied egg-rr95.8%

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

Alternative 2: 83.5% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-58}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+121}:\\ \;\;\;\;c \cdot \frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -8.2e+142)
   (/
    (+ a (- (- (* b (/ d c)) (* b (pow (/ d c) 3.0))) (* a (pow (/ d c) 2.0))))
    c)
   (if (<= c -1.7e-97)
     (/ (fma a c (* d b)) (fma c c (* d d)))
     (if (<= c 7.2e-58)
       (/ (+ b (* a (/ c d))) d)
       (if (<= c 1.55e+121)
         (* c (/ (/ (fma d (/ b c) a) (hypot c d)) (hypot c d)))
         (/ (+ a (* d (/ b c))) c))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -8.2e+142) {
		tmp = (a + (((b * (d / c)) - (b * pow((d / c), 3.0))) - (a * pow((d / c), 2.0)))) / c;
	} else if (c <= -1.7e-97) {
		tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
	} else if (c <= 7.2e-58) {
		tmp = (b + (a * (c / d))) / d;
	} else if (c <= 1.55e+121) {
		tmp = c * ((fma(d, (b / c), a) / hypot(c, d)) / hypot(c, d));
	} else {
		tmp = (a + (d * (b / c))) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -8.2e+142)
		tmp = Float64(Float64(a + Float64(Float64(Float64(b * Float64(d / c)) - Float64(b * (Float64(d / c) ^ 3.0))) - Float64(a * (Float64(d / c) ^ 2.0)))) / c);
	elseif (c <= -1.7e-97)
		tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d)));
	elseif (c <= 7.2e-58)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (c <= 1.55e+121)
		tmp = Float64(c * Float64(Float64(fma(d, Float64(b / c), a) / hypot(c, d)) / hypot(c, d)));
	else
		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[c, -8.2e+142], N[(N[(a + N[(N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] - N[(b * N[Power[N[(d / c), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[Power[N[(d / c), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.7e-97], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.2e-58], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.55e+121], N[(c * N[(N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\
\;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\

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

\mathbf{elif}\;c \leq 7.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -8.19999999999999963e142

    1. Initial program 37.4%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define37.4%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    6. Step-by-step derivation
      1. *-commutative37.4%

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

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

      \[\leadsto \color{blue}{\frac{\left(a + \left(-1 \cdot \frac{b \cdot {d}^{3}}{{c}^{3}} + \frac{b \cdot d}{c}\right)\right) - \frac{a \cdot {d}^{2}}{{c}^{2}}}{c}} \]
    9. Step-by-step derivation
      1. Simplified88.6%

        \[\leadsto \color{blue}{\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}} \]

      if -8.19999999999999963e142 < c < -1.6999999999999999e-97

      1. Initial program 85.9%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define85.9%

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

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

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

      if -1.6999999999999999e-97 < c < 7.20000000000000019e-58

      1. Initial program 71.8%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define71.8%

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
        2. fma-define71.8%

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      6. Step-by-step derivation
        1. associate-/l*87.5%

          \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
      7. Simplified87.5%

        \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

      if 7.20000000000000019e-58 < c < 1.55000000000000004e121

      1. Initial program 83.1%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define83.1%

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
        2. fma-define83.1%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      6. Step-by-step derivation
        1. *-commutative82.8%

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

        \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      8. Step-by-step derivation
        1. *-commutative82.8%

          \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        2. add-sqr-sqrt82.8%

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

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

          \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
        5. associate-/l*88.4%

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
        10. hypot-define94.0%

          \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      9. Applied egg-rr94.0%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}} \]
      10. Step-by-step derivation
        1. clear-num93.9%

          \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
        2. un-div-inv94.0%

          \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      11. Applied egg-rr94.0%

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      12. Step-by-step derivation
        1. associate-/r/91.4%

          \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \cdot c} \]
      13. Applied egg-rr91.4%

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

      if 1.55000000000000004e121 < c

      1. Initial program 35.5%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define35.5%

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

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

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

        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
      6. Step-by-step derivation
        1. +-commutative73.1%

          \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
        2. associate-/l*80.7%

          \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
        3. fma-define80.7%

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
      8. Step-by-step derivation
        1. fma-undefine80.7%

          \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
        2. associate-*r/73.1%

          \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
        3. *-commutative73.1%

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

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
      9. Applied egg-rr83.1%

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]
    10. Recombined 5 regimes into one program.
    11. Final simplification87.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-58}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+121}:\\ \;\;\;\;c \cdot \frac{\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \]
    12. Add Preprocessing

    Alternative 3: 90.1% accurate, 0.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.85 \cdot 10^{-63} \lor \neg \left(c \leq 1.9 \cdot 10^{-56}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (if (or (<= c -2.85e-63) (not (<= c 1.9e-56)))
       (* (/ (fma d (/ b c) a) (hypot c d)) (/ c (hypot c d)))
       (/ (+ b (* a (/ c d))) d)))
    double code(double a, double b, double c, double d) {
    	double tmp;
    	if ((c <= -2.85e-63) || !(c <= 1.9e-56)) {
    		tmp = (fma(d, (b / c), a) / hypot(c, d)) * (c / hypot(c, d));
    	} else {
    		tmp = (b + (a * (c / d))) / d;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	tmp = 0.0
    	if ((c <= -2.85e-63) || !(c <= 1.9e-56))
    		tmp = Float64(Float64(fma(d, Float64(b / c), a) / hypot(c, d)) * Float64(c / hypot(c, d)));
    	else
    		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.85e-63], N[Not[LessEqual[c, 1.9e-56]], $MachinePrecision]], N[(N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;c \leq -2.85 \cdot 10^{-63} \lor \neg \left(c \leq 1.9 \cdot 10^{-56}\right):\\
    \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if c < -2.85000000000000026e-63 or 1.9000000000000001e-56 < c

      1. Initial program 61.1%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define61.1%

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
        2. fma-define61.1%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      6. Step-by-step derivation
        1. *-commutative60.4%

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

        \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      8. Step-by-step derivation
        1. *-commutative60.4%

          \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        2. add-sqr-sqrt60.4%

          \[\leadsto \frac{\left(a + \frac{d \cdot b}{c}\right) \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
        3. times-frac62.1%

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

          \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
        5. associate-/l*63.1%

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

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
        7. fma-undefine63.1%

          \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
        8. hypot-define63.1%

          \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
        9. fma-undefine63.1%

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

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

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

      if -2.85000000000000026e-63 < c < 1.9000000000000001e-56

      1. Initial program 72.7%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define72.7%

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

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      6. Step-by-step derivation
        1. associate-/l*87.9%

          \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
      7. Simplified87.9%

        \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification92.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.85 \cdot 10^{-63} \lor \neg \left(c \leq 1.9 \cdot 10^{-56}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 82.1% accurate, 0.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+142}:\\ \;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 6.3 \cdot 10^{-142}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{+100}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (if (<= c -9e+142)
       (/
        (+ a (- (- (* b (/ d c)) (* b (pow (/ d c) 3.0))) (* a (pow (/ d c) 2.0))))
        c)
       (if (<= c -1.6e-97)
         (/ (fma a c (* d b)) (fma c c (* d d)))
         (if (<= c 6.3e-142)
           (/ (+ b (* a (/ c d))) d)
           (if (<= c 5e+100)
             (/ (+ (* d b) (* c a)) (+ (* d d) (* c c)))
             (/ (+ a (* d (/ b c))) c))))))
    double code(double a, double b, double c, double d) {
    	double tmp;
    	if (c <= -9e+142) {
    		tmp = (a + (((b * (d / c)) - (b * pow((d / c), 3.0))) - (a * pow((d / c), 2.0)))) / c;
    	} else if (c <= -1.6e-97) {
    		tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
    	} else if (c <= 6.3e-142) {
    		tmp = (b + (a * (c / d))) / d;
    	} else if (c <= 5e+100) {
    		tmp = ((d * b) + (c * a)) / ((d * d) + (c * c));
    	} else {
    		tmp = (a + (d * (b / c))) / c;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	tmp = 0.0
    	if (c <= -9e+142)
    		tmp = Float64(Float64(a + Float64(Float64(Float64(b * Float64(d / c)) - Float64(b * (Float64(d / c) ^ 3.0))) - Float64(a * (Float64(d / c) ^ 2.0)))) / c);
    	elseif (c <= -1.6e-97)
    		tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d)));
    	elseif (c <= 6.3e-142)
    		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
    	elseif (c <= 5e+100)
    		tmp = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)));
    	else
    		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := If[LessEqual[c, -9e+142], N[(N[(a + N[(N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] - N[(b * N[Power[N[(d / c), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[Power[N[(d / c), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.6e-97], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.3e-142], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5e+100], N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;c \leq -9 \cdot 10^{+142}:\\
    \;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\
    
    \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
    
    \mathbf{elif}\;c \leq 6.3 \cdot 10^{-142}:\\
    \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
    
    \mathbf{elif}\;c \leq 5 \cdot 10^{+100}:\\
    \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 5 regimes
    2. if c < -8.9999999999999998e142

      1. Initial program 37.4%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define37.4%

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

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

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

        \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      6. Step-by-step derivation
        1. *-commutative37.4%

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

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

        \[\leadsto \color{blue}{\frac{\left(a + \left(-1 \cdot \frac{b \cdot {d}^{3}}{{c}^{3}} + \frac{b \cdot d}{c}\right)\right) - \frac{a \cdot {d}^{2}}{{c}^{2}}}{c}} \]
      9. Step-by-step derivation
        1. Simplified88.6%

          \[\leadsto \color{blue}{\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}} \]

        if -8.9999999999999998e142 < c < -1.5999999999999999e-97

        1. Initial program 85.9%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define85.9%

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

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

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

        if -1.5999999999999999e-97 < c < 6.2999999999999998e-142

        1. Initial program 69.3%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define69.3%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*88.6%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified88.6%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if 6.2999999999999998e-142 < c < 4.9999999999999999e100

        1. Initial program 85.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing

        if 4.9999999999999999e100 < c

        1. Initial program 38.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define38.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. +-commutative71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
          2. associate-/l*78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
          3. fma-define78.6%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
        8. Step-by-step derivation
          1. fma-undefine78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
          2. associate-*r/71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
          3. *-commutative71.7%

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

            \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
        9. Applied egg-rr80.8%

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]
      10. Recombined 5 regimes into one program.
      11. Final simplification86.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+142}:\\ \;\;\;\;\frac{a + \left(\left(b \cdot \frac{d}{c} - b \cdot {\left(\frac{d}{c}\right)}^{3}\right) - a \cdot {\left(\frac{d}{c}\right)}^{2}\right)}{c}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 6.3 \cdot 10^{-142}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{+100}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \]
      12. Add Preprocessing

      Alternative 5: 82.4% accurate, 0.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-140}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+99}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (<= c -8.2e+142)
         (/ (fma d (/ b c) a) (- (hypot c d)))
         (if (<= c -1.9e-97)
           (/ (fma a c (* d b)) (fma c c (* d d)))
           (if (<= c 1.35e-140)
             (/ (+ b (* a (/ c d))) d)
             (if (<= c 4.4e+99)
               (/ (+ (* d b) (* c a)) (+ (* d d) (* c c)))
               (/ (+ a (* d (/ b c))) c))))))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if (c <= -8.2e+142) {
      		tmp = fma(d, (b / c), a) / -hypot(c, d);
      	} else if (c <= -1.9e-97) {
      		tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
      	} else if (c <= 1.35e-140) {
      		tmp = (b + (a * (c / d))) / d;
      	} else if (c <= 4.4e+99) {
      		tmp = ((d * b) + (c * a)) / ((d * d) + (c * c));
      	} else {
      		tmp = (a + (d * (b / c))) / c;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if (c <= -8.2e+142)
      		tmp = Float64(fma(d, Float64(b / c), a) / Float64(-hypot(c, d)));
      	elseif (c <= -1.9e-97)
      		tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d)));
      	elseif (c <= 1.35e-140)
      		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
      	elseif (c <= 4.4e+99)
      		tmp = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)));
      	else
      		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := If[LessEqual[c, -8.2e+142], N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[c, -1.9e-97], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.35e-140], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.4e+99], N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\
      
      \mathbf{elif}\;c \leq -1.9 \cdot 10^{-97}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
      
      \mathbf{elif}\;c \leq 1.35 \cdot 10^{-140}:\\
      \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
      
      \mathbf{elif}\;c \leq 4.4 \cdot 10^{+99}:\\
      \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 5 regimes
      2. if c < -8.19999999999999963e142

        1. Initial program 37.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define37.4%

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

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

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

          \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        6. Step-by-step derivation
          1. *-commutative37.4%

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

          \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        8. Step-by-step derivation
          1. *-commutative37.4%

            \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
          2. add-sqr-sqrt37.4%

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

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

            \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          5. associate-/l*39.2%

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

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

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          8. hypot-define39.2%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          9. fma-undefine39.2%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
          10. hypot-define99.7%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
        9. Applied egg-rr99.7%

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

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

        if -8.19999999999999963e142 < c < -1.9e-97

        1. Initial program 85.9%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define85.9%

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

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

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

        if -1.9e-97 < c < 1.35e-140

        1. Initial program 69.3%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define69.3%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*88.6%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified88.6%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if 1.35e-140 < c < 4.39999999999999956e99

        1. Initial program 85.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing

        if 4.39999999999999956e99 < c

        1. Initial program 38.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define38.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. +-commutative71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
          2. associate-/l*78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
          3. fma-define78.6%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
        8. Step-by-step derivation
          1. fma-undefine78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
          2. associate-*r/71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
          3. *-commutative71.7%

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

            \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
        9. Applied egg-rr80.8%

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]
      3. Recombined 5 regimes into one program.
      4. Final simplification86.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-140}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+99}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 6: 82.4% accurate, 0.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;c \leq -8.6 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5.9 \cdot 10^{-142}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+99}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* d d) (* c c)))))
         (if (<= c -8.6e+142)
           (/ (fma d (/ b c) a) (- (hypot c d)))
           (if (<= c -1.6e-97)
             t_0
             (if (<= c 5.9e-142)
               (/ (+ b (* a (/ c d))) d)
               (if (<= c 2.4e+99) t_0 (/ (+ a (* d (/ b c))) c)))))))
      double code(double a, double b, double c, double d) {
      	double t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c));
      	double tmp;
      	if (c <= -8.6e+142) {
      		tmp = fma(d, (b / c), a) / -hypot(c, d);
      	} else if (c <= -1.6e-97) {
      		tmp = t_0;
      	} else if (c <= 5.9e-142) {
      		tmp = (b + (a * (c / d))) / d;
      	} else if (c <= 2.4e+99) {
      		tmp = t_0;
      	} else {
      		tmp = (a + (d * (b / c))) / c;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)))
      	tmp = 0.0
      	if (c <= -8.6e+142)
      		tmp = Float64(fma(d, Float64(b / c), a) / Float64(-hypot(c, d)));
      	elseif (c <= -1.6e-97)
      		tmp = t_0;
      	elseif (c <= 5.9e-142)
      		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
      	elseif (c <= 2.4e+99)
      		tmp = t_0;
      	else
      		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8.6e+142], N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[c, -1.6e-97], t$95$0, If[LessEqual[c, 5.9e-142], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.4e+99], t$95$0, N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\
      \mathbf{if}\;c \leq -8.6 \cdot 10^{+142}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\
      
      \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;c \leq 5.9 \cdot 10^{-142}:\\
      \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
      
      \mathbf{elif}\;c \leq 2.4 \cdot 10^{+99}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if c < -8.60000000000000025e142

        1. Initial program 37.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define37.4%

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

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

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

          \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{b \cdot d}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        6. Step-by-step derivation
          1. *-commutative37.4%

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

          \[\leadsto \frac{\color{blue}{c \cdot \left(a + \frac{d \cdot b}{c}\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
        8. Step-by-step derivation
          1. *-commutative37.4%

            \[\leadsto \frac{\color{blue}{\left(a + \frac{d \cdot b}{c}\right) \cdot c}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
          2. add-sqr-sqrt37.4%

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

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

            \[\leadsto \frac{\color{blue}{\frac{d \cdot b}{c} + a}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          5. associate-/l*39.2%

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

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

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          8. hypot-define39.2%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
          9. fma-undefine39.2%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
          10. hypot-define99.7%

            \[\leadsto \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
        9. Applied egg-rr99.7%

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

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

        if -8.60000000000000025e142 < c < -1.5999999999999999e-97 or 5.89999999999999966e-142 < c < 2.4000000000000001e99

        1. Initial program 85.7%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing

        if -1.5999999999999999e-97 < c < 5.89999999999999966e-142

        1. Initial program 69.3%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define69.3%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*88.6%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified88.6%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if 2.4000000000000001e99 < c

        1. Initial program 38.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define38.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. +-commutative71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
          2. associate-/l*78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
          3. fma-define78.6%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
        8. Step-by-step derivation
          1. fma-undefine78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
          2. associate-*r/71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
          3. *-commutative71.7%

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

            \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
        9. Applied egg-rr80.8%

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]
      3. Recombined 4 regimes into one program.
      4. Final simplification86.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.6 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{-\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 5.9 \cdot 10^{-142}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+99}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 7: 82.3% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;c \leq -1.95 \cdot 10^{+143}:\\ \;\;\;\;\frac{a + \frac{b}{c \cdot \frac{1}{d}}}{c}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-141}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+99}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* d d) (* c c)))))
         (if (<= c -1.95e+143)
           (/ (+ a (/ b (* c (/ 1.0 d)))) c)
           (if (<= c -1.6e-97)
             t_0
             (if (<= c 3.2e-141)
               (/ (+ b (* a (/ c d))) d)
               (if (<= c 8e+99) t_0 (/ (+ a (* d (/ b c))) c)))))))
      double code(double a, double b, double c, double d) {
      	double t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c));
      	double tmp;
      	if (c <= -1.95e+143) {
      		tmp = (a + (b / (c * (1.0 / d)))) / c;
      	} else if (c <= -1.6e-97) {
      		tmp = t_0;
      	} else if (c <= 3.2e-141) {
      		tmp = (b + (a * (c / d))) / d;
      	} else if (c <= 8e+99) {
      		tmp = t_0;
      	} else {
      		tmp = (a + (d * (b / c))) / 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) :: t_0
          real(8) :: tmp
          t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c))
          if (c <= (-1.95d+143)) then
              tmp = (a + (b / (c * (1.0d0 / d)))) / c
          else if (c <= (-1.6d-97)) then
              tmp = t_0
          else if (c <= 3.2d-141) then
              tmp = (b + (a * (c / d))) / d
          else if (c <= 8d+99) then
              tmp = t_0
          else
              tmp = (a + (d * (b / c))) / c
          end if
          code = tmp
      end function
      
      public static double code(double a, double b, double c, double d) {
      	double t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c));
      	double tmp;
      	if (c <= -1.95e+143) {
      		tmp = (a + (b / (c * (1.0 / d)))) / c;
      	} else if (c <= -1.6e-97) {
      		tmp = t_0;
      	} else if (c <= 3.2e-141) {
      		tmp = (b + (a * (c / d))) / d;
      	} else if (c <= 8e+99) {
      		tmp = t_0;
      	} else {
      		tmp = (a + (d * (b / c))) / c;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c))
      	tmp = 0
      	if c <= -1.95e+143:
      		tmp = (a + (b / (c * (1.0 / d)))) / c
      	elif c <= -1.6e-97:
      		tmp = t_0
      	elif c <= 3.2e-141:
      		tmp = (b + (a * (c / d))) / d
      	elif c <= 8e+99:
      		tmp = t_0
      	else:
      		tmp = (a + (d * (b / c))) / c
      	return tmp
      
      function code(a, b, c, d)
      	t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)))
      	tmp = 0.0
      	if (c <= -1.95e+143)
      		tmp = Float64(Float64(a + Float64(b / Float64(c * Float64(1.0 / d)))) / c);
      	elseif (c <= -1.6e-97)
      		tmp = t_0;
      	elseif (c <= 3.2e-141)
      		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
      	elseif (c <= 8e+99)
      		tmp = t_0;
      	else
      		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, c, d)
      	t_0 = ((d * b) + (c * a)) / ((d * d) + (c * c));
      	tmp = 0.0;
      	if (c <= -1.95e+143)
      		tmp = (a + (b / (c * (1.0 / d)))) / c;
      	elseif (c <= -1.6e-97)
      		tmp = t_0;
      	elseif (c <= 3.2e-141)
      		tmp = (b + (a * (c / d))) / d;
      	elseif (c <= 8e+99)
      		tmp = t_0;
      	else
      		tmp = (a + (d * (b / c))) / c;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.95e+143], N[(N[(a + N[(b / N[(c * N[(1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.6e-97], t$95$0, If[LessEqual[c, 3.2e-141], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 8e+99], t$95$0, N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\
      \mathbf{if}\;c \leq -1.95 \cdot 10^{+143}:\\
      \;\;\;\;\frac{a + \frac{b}{c \cdot \frac{1}{d}}}{c}\\
      
      \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;c \leq 3.2 \cdot 10^{-141}:\\
      \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
      
      \mathbf{elif}\;c \leq 8 \cdot 10^{+99}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if c < -1.9499999999999999e143

        1. Initial program 37.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define37.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. *-commutative81.1%

            \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
        7. Simplified81.1%

          \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{c}} \]
        8. Step-by-step derivation
          1. *-commutative81.1%

            \[\leadsto \frac{a + \frac{\color{blue}{b \cdot d}}{c}}{c} \]
          2. associate-*r/88.1%

            \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
          3. *-commutative88.1%

            \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
        9. Applied egg-rr88.1%

          \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
        10. Step-by-step derivation
          1. *-commutative88.1%

            \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
          2. clear-num88.0%

            \[\leadsto \frac{a + b \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
          3. un-div-inv88.1%

            \[\leadsto \frac{a + \color{blue}{\frac{b}{\frac{c}{d}}}}{c} \]
        11. Applied egg-rr88.1%

          \[\leadsto \frac{a + \color{blue}{\frac{b}{\frac{c}{d}}}}{c} \]
        12. Step-by-step derivation
          1. div-inv88.1%

            \[\leadsto \frac{a + \frac{b}{\color{blue}{c \cdot \frac{1}{d}}}}{c} \]
        13. Applied egg-rr88.1%

          \[\leadsto \frac{a + \frac{b}{\color{blue}{c \cdot \frac{1}{d}}}}{c} \]

        if -1.9499999999999999e143 < c < -1.5999999999999999e-97 or 3.2000000000000001e-141 < c < 7.9999999999999997e99

        1. Initial program 85.7%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing

        if -1.5999999999999999e-97 < c < 3.2000000000000001e-141

        1. Initial program 69.3%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define69.3%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*88.6%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified88.6%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if 7.9999999999999997e99 < c

        1. Initial program 38.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define38.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. +-commutative71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
          2. associate-/l*78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
          3. fma-define78.6%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
        8. Step-by-step derivation
          1. fma-undefine78.6%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
          2. associate-*r/71.7%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
          3. *-commutative71.7%

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

            \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
        9. Applied egg-rr80.8%

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]
      3. Recombined 4 regimes into one program.
      4. Final simplification86.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.95 \cdot 10^{+143}:\\ \;\;\;\;\frac{a + \frac{b}{c \cdot \frac{1}{d}}}{c}\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-97}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-141}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+99}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 8: 78.7% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.22 \cdot 10^{+23} \lor \neg \left(d \leq 1.95 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (or (<= d -1.22e+23) (not (<= d 1.95e-50)))
         (/ (+ b (* a (/ c d))) d)
         (/ (+ a (* b (/ d c))) c)))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((d <= -1.22e+23) || !(d <= 1.95e-50)) {
      		tmp = (b + (a * (c / d))) / d;
      	} else {
      		tmp = (a + (b * (d / c))) / 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 ((d <= (-1.22d+23)) .or. (.not. (d <= 1.95d-50))) then
              tmp = (b + (a * (c / d))) / d
          else
              tmp = (a + (b * (d / c))) / c
          end if
          code = tmp
      end function
      
      public static double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((d <= -1.22e+23) || !(d <= 1.95e-50)) {
      		tmp = (b + (a * (c / d))) / d;
      	} else {
      		tmp = (a + (b * (d / c))) / c;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	tmp = 0
      	if (d <= -1.22e+23) or not (d <= 1.95e-50):
      		tmp = (b + (a * (c / d))) / d
      	else:
      		tmp = (a + (b * (d / c))) / c
      	return tmp
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if ((d <= -1.22e+23) || !(d <= 1.95e-50))
      		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
      	else
      		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c);
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, c, d)
      	tmp = 0.0;
      	if ((d <= -1.22e+23) || ~((d <= 1.95e-50)))
      		tmp = (b + (a * (c / d))) / d;
      	else
      		tmp = (a + (b * (d / c))) / c;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.22e+23], N[Not[LessEqual[d, 1.95e-50]], $MachinePrecision]], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;d \leq -1.22 \cdot 10^{+23} \lor \neg \left(d \leq 1.95 \cdot 10^{-50}\right):\\
      \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if d < -1.22e23 or 1.9500000000000001e-50 < d

        1. Initial program 57.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define57.6%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*78.3%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified78.3%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if -1.22e23 < d < 1.9500000000000001e-50

        1. Initial program 75.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define75.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. *-commutative83.6%

            \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
        7. Simplified83.6%

          \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{c}} \]
        8. Step-by-step derivation
          1. *-commutative83.6%

            \[\leadsto \frac{a + \frac{\color{blue}{b \cdot d}}{c}}{c} \]
          2. associate-*r/83.9%

            \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
          3. *-commutative83.9%

            \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
        9. Applied egg-rr83.9%

          \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification80.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.22 \cdot 10^{+23} \lor \neg \left(d \leq 1.95 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 9: 73.4% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -4.2 \cdot 10^{+24} \lor \neg \left(d \leq 13500000\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (or (<= d -4.2e+24) (not (<= d 13500000.0)))
         (/ b d)
         (/ (+ a (* b (/ d c))) c)))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((d <= -4.2e+24) || !(d <= 13500000.0)) {
      		tmp = b / d;
      	} else {
      		tmp = (a + (b * (d / c))) / 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 ((d <= (-4.2d+24)) .or. (.not. (d <= 13500000.0d0))) then
              tmp = b / d
          else
              tmp = (a + (b * (d / c))) / c
          end if
          code = tmp
      end function
      
      public static double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((d <= -4.2e+24) || !(d <= 13500000.0)) {
      		tmp = b / d;
      	} else {
      		tmp = (a + (b * (d / c))) / c;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	tmp = 0
      	if (d <= -4.2e+24) or not (d <= 13500000.0):
      		tmp = b / d
      	else:
      		tmp = (a + (b * (d / c))) / c
      	return tmp
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if ((d <= -4.2e+24) || !(d <= 13500000.0))
      		tmp = Float64(b / d);
      	else
      		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c);
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, c, d)
      	tmp = 0.0;
      	if ((d <= -4.2e+24) || ~((d <= 13500000.0)))
      		tmp = b / d;
      	else
      		tmp = (a + (b * (d / c))) / c;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.2e+24], N[Not[LessEqual[d, 13500000.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;d \leq -4.2 \cdot 10^{+24} \lor \neg \left(d \leq 13500000\right):\\
      \;\;\;\;\frac{b}{d}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if d < -4.2000000000000003e24 or 1.35e7 < d

        1. Initial program 53.2%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define53.3%

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

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

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

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

        if -4.2000000000000003e24 < d < 1.35e7

        1. Initial program 77.8%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define77.8%

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
          2. fma-define77.8%

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. *-commutative80.8%

            \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
        7. Simplified80.8%

          \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{c}} \]
        8. Step-by-step derivation
          1. *-commutative80.8%

            \[\leadsto \frac{a + \frac{\color{blue}{b \cdot d}}{c}}{c} \]
          2. associate-*r/81.0%

            \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
          3. *-commutative81.0%

            \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
        9. Applied egg-rr81.0%

          \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification74.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.2 \cdot 10^{+24} \lor \neg \left(d \leq 13500000\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 10: 78.0% accurate, 0.8× speedup?

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

        1. Initial program 49.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define49.5%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*78.2%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified78.2%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if -1.45000000000000006e23 < d < 2.90000000000000008e-50

        1. Initial program 75.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define75.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. +-commutative83.6%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c} + a}}{c} \]
          2. associate-/l*83.9%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c}} + a}{c} \]
          3. fma-define83.9%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}} \]
        8. Step-by-step derivation
          1. fma-undefine83.9%

            \[\leadsto \frac{\color{blue}{b \cdot \frac{d}{c} + a}}{c} \]
          2. associate-*r/83.6%

            \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}} + a}{c} \]
          3. *-commutative83.6%

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

            \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}} + a}{c} \]
        9. Applied egg-rr84.8%

          \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c} + a}}{c} \]

        if 2.90000000000000008e-50 < d

        1. Initial program 63.7%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define63.8%

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
          2. fma-define63.8%

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. add-sqr-sqrt39.8%

            \[\leadsto \frac{b + \color{blue}{\sqrt{\frac{a \cdot c}{d}} \cdot \sqrt{\frac{a \cdot c}{d}}}}{d} \]
          2. pow239.8%

            \[\leadsto \frac{b + \color{blue}{{\left(\sqrt{\frac{a \cdot c}{d}}\right)}^{2}}}{d} \]
          3. *-commutative39.8%

            \[\leadsto \frac{b + {\left(\sqrt{\frac{\color{blue}{c \cdot a}}{d}}\right)}^{2}}{d} \]
          4. associate-/l*46.2%

            \[\leadsto \frac{b + {\left(\sqrt{\color{blue}{c \cdot \frac{a}{d}}}\right)}^{2}}{d} \]
        7. Applied egg-rr46.2%

          \[\leadsto \frac{b + \color{blue}{{\left(\sqrt{c \cdot \frac{a}{d}}\right)}^{2}}}{d} \]
        8. Step-by-step derivation
          1. unpow246.2%

            \[\leadsto \frac{b + \color{blue}{\sqrt{c \cdot \frac{a}{d}} \cdot \sqrt{c \cdot \frac{a}{d}}}}{d} \]
          2. add-sqr-sqrt79.7%

            \[\leadsto \frac{b + \color{blue}{c \cdot \frac{a}{d}}}{d} \]
          3. clear-num79.5%

            \[\leadsto \frac{b + c \cdot \color{blue}{\frac{1}{\frac{d}{a}}}}{d} \]
          4. un-div-inv79.6%

            \[\leadsto \frac{b + \color{blue}{\frac{c}{\frac{d}{a}}}}{d} \]
        9. Applied egg-rr79.6%

          \[\leadsto \frac{b + \color{blue}{\frac{c}{\frac{d}{a}}}}{d} \]
      3. Recombined 3 regimes into one program.
      4. Final simplification81.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.45 \cdot 10^{+23}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq 2.9 \cdot 10^{-50}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 11: 78.7% accurate, 0.8× speedup?

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

        1. Initial program 49.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define49.5%

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. associate-/l*78.2%

            \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
        7. Simplified78.2%

          \[\leadsto \color{blue}{\frac{b + a \cdot \frac{c}{d}}{d}} \]

        if -2.3000000000000001e26 < d < 1.74999999999999996e-48

        1. Initial program 75.4%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define75.4%

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

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

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

          \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
        6. Step-by-step derivation
          1. *-commutative83.6%

            \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
        7. Simplified83.6%

          \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{c}} \]
        8. Step-by-step derivation
          1. *-commutative83.6%

            \[\leadsto \frac{a + \frac{\color{blue}{b \cdot d}}{c}}{c} \]
          2. associate-*r/83.9%

            \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
          3. *-commutative83.9%

            \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]
        9. Applied egg-rr83.9%

          \[\leadsto \frac{a + \color{blue}{\frac{d}{c} \cdot b}}{c} \]

        if 1.74999999999999996e-48 < d

        1. Initial program 63.7%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define63.8%

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(a, c, b \cdot d\right)}}{c \cdot c + d \cdot d} \]
          2. fma-define63.8%

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. Step-by-step derivation
          1. add-sqr-sqrt39.8%

            \[\leadsto \frac{b + \color{blue}{\sqrt{\frac{a \cdot c}{d}} \cdot \sqrt{\frac{a \cdot c}{d}}}}{d} \]
          2. pow239.8%

            \[\leadsto \frac{b + \color{blue}{{\left(\sqrt{\frac{a \cdot c}{d}}\right)}^{2}}}{d} \]
          3. *-commutative39.8%

            \[\leadsto \frac{b + {\left(\sqrt{\frac{\color{blue}{c \cdot a}}{d}}\right)}^{2}}{d} \]
          4. associate-/l*46.2%

            \[\leadsto \frac{b + {\left(\sqrt{\color{blue}{c \cdot \frac{a}{d}}}\right)}^{2}}{d} \]
        7. Applied egg-rr46.2%

          \[\leadsto \frac{b + \color{blue}{{\left(\sqrt{c \cdot \frac{a}{d}}\right)}^{2}}}{d} \]
        8. Step-by-step derivation
          1. unpow246.2%

            \[\leadsto \frac{b + \color{blue}{\sqrt{c \cdot \frac{a}{d}} \cdot \sqrt{c \cdot \frac{a}{d}}}}{d} \]
          2. add-sqr-sqrt79.7%

            \[\leadsto \frac{b + \color{blue}{c \cdot \frac{a}{d}}}{d} \]
          3. clear-num79.5%

            \[\leadsto \frac{b + c \cdot \color{blue}{\frac{1}{\frac{d}{a}}}}{d} \]
          4. un-div-inv79.6%

            \[\leadsto \frac{b + \color{blue}{\frac{c}{\frac{d}{a}}}}{d} \]
        9. Applied egg-rr79.6%

          \[\leadsto \frac{b + \color{blue}{\frac{c}{\frac{d}{a}}}}{d} \]
      3. Recombined 3 regimes into one program.
      4. Final simplification81.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+26}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-48}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 12: 64.4% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -5.4 \cdot 10^{-27} \lor \neg \left(d \leq 1850\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (or (<= d -5.4e-27) (not (<= d 1850.0))) (/ b d) (/ a c)))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((d <= -5.4e-27) || !(d <= 1850.0)) {
      		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 ((d <= (-5.4d-27)) .or. (.not. (d <= 1850.0d0))) 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 ((d <= -5.4e-27) || !(d <= 1850.0)) {
      		tmp = b / d;
      	} else {
      		tmp = a / c;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	tmp = 0
      	if (d <= -5.4e-27) or not (d <= 1850.0):
      		tmp = b / d
      	else:
      		tmp = a / c
      	return tmp
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if ((d <= -5.4e-27) || !(d <= 1850.0))
      		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 ((d <= -5.4e-27) || ~((d <= 1850.0)))
      		tmp = b / d;
      	else
      		tmp = a / c;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.4e-27], N[Not[LessEqual[d, 1850.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;d \leq -5.4 \cdot 10^{-27} \lor \neg \left(d \leq 1850\right):\\
      \;\;\;\;\frac{b}{d}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{a}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if d < -5.39999999999999978e-27 or 1850 < d

        1. Initial program 55.5%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define55.5%

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

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

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

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

        if -5.39999999999999978e-27 < d < 1850

        1. Initial program 77.9%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Step-by-step derivation
          1. fma-define77.9%

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

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

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification65.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.4 \cdot 10^{-27} \lor \neg \left(d \leq 1850\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 13: 42.2% accurate, 5.0× 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 65.6%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Step-by-step derivation
        1. fma-define65.6%

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

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

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

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

      Developer Target 1: 99.1% accurate, 0.1× 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 2024133 
      (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))))