Complex division, real part

Percentage Accurate: 60.7% → 82.4%
Time: 10.4s
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: 60.7% 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: 82.4% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -2.1 \cdot 10^{-132}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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

\mathbf{elif}\;d \leq 1.55 \cdot 10^{+114}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -8.2000000000000004e71

    1. Initial program 46.8%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified46.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. Step-by-step derivation
      1. *-un-lft-identity46.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(-1 \cdot \color{blue}{\left(\frac{a \cdot c}{d} + b\right)}\right) \]
      3. associate-*r/96.0%

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

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

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

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

    if -8.2000000000000004e71 < d < -2.1000000000000001e-132

    1. Initial program 83.4%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutative83.4%

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

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

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

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

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

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

    if -2.1000000000000001e-132 < d < 1.14999999999999994e-157

    1. Initial program 54.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified54.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 89.2%

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

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

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

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

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

    if 1.14999999999999994e-157 < d < 1.55e114

    1. Initial program 78.5%

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

    if 1.55e114 < d

    1. Initial program 39.3%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified39.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 80.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.2 \cdot 10^{+71}:\\ \;\;\;\;\mathsf{fma}\left(a, \frac{c}{d}, b\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-132}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-157}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{+114}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 85.2% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 4 \cdot 10^{+301}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\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 (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 4e+301)
   (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
   (/ (+ b (* a (/ c d))) d)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 4e+301) {
		tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
	} else {
		tmp = (b + (a * (c / d))) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= 4e+301)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d)));
	else
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+301], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / 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}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 4 \cdot 10^{+301}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\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 (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.00000000000000021e301

    1. Initial program 78.3%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified78.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. Step-by-step derivation
      1. *-un-lft-identity78.3%

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000021e301 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.7%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified11.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 53.4%

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

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

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

Alternative 3: 82.1% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{+43}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{\frac{d}{a}}{c}}}{d}\\

\mathbf{elif}\;d \leq -2.15 \cdot 10^{-132}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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

\mathbf{elif}\;d \leq 1.55 \cdot 10^{+115}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.05e43

    1. Initial program 52.0%

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

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

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

      \[\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 91.0%

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

        \[\leadsto \frac{b + \color{blue}{\frac{1}{\frac{d}{a \cdot c}}}}{d} \]
      2. inv-pow90.9%

        \[\leadsto \frac{b + \color{blue}{{\left(\frac{d}{a \cdot c}\right)}^{-1}}}{d} \]
      3. *-commutative90.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b + \frac{1}{\color{blue}{\frac{\frac{d}{a} \cdot 1}{c}}}}{d} \]
      5. *-rgt-identity94.9%

        \[\leadsto \frac{b + \frac{1}{\frac{\color{blue}{\frac{d}{a}}}{c}}}{d} \]
    13. Simplified94.9%

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

    if -2.05e43 < d < -2.1499999999999998e-132

    1. Initial program 81.5%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutative81.5%

        \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{d \cdot d + c \cdot c}} \]
      2. fma-define81.5%

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

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

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

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

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

    if -2.1499999999999998e-132 < d < 5.69999999999999982e-158

    1. Initial program 54.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified54.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 89.2%

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

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

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

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

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

    if 5.69999999999999982e-158 < d < 1.55000000000000002e115

    1. Initial program 78.5%

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

    if 1.55000000000000002e115 < d

    1. Initial program 39.3%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified39.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 80.1%

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

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

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

Alternative 4: 82.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -8.2 \cdot 10^{+41}:\\ \;\;\;\;\frac{b + \frac{1}{\frac{\frac{d}{a}}{c}}}{d}\\ \mathbf{elif}\;d \leq -2.15 \cdot 10^{-132}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-158}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.08 \cdot 10^{+114}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
   (if (<= d -8.2e+41)
     (/ (+ b (/ 1.0 (/ (/ d a) c))) d)
     (if (<= d -2.15e-132)
       t_0
       (if (<= d 9.2e-158)
         (/ (+ a (* d (/ b c))) c)
         (if (<= d 1.08e+114) t_0 (/ (+ b (* a (/ c d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -8.2e+41) {
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	} else if (d <= -2.15e-132) {
		tmp = t_0;
	} else if (d <= 9.2e-158) {
		tmp = (a + (d * (b / c))) / c;
	} else if (d <= 1.08e+114) {
		tmp = t_0;
	} else {
		tmp = (b + (a * (c / d))) / 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) :: t_0
    real(8) :: tmp
    t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
    if (d <= (-8.2d+41)) then
        tmp = (b + (1.0d0 / ((d / a) / c))) / d
    else if (d <= (-2.15d-132)) then
        tmp = t_0
    else if (d <= 9.2d-158) then
        tmp = (a + (d * (b / c))) / c
    else if (d <= 1.08d+114) then
        tmp = t_0
    else
        tmp = (b + (a * (c / d))) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -8.2e+41) {
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	} else if (d <= -2.15e-132) {
		tmp = t_0;
	} else if (d <= 9.2e-158) {
		tmp = (a + (d * (b / c))) / c;
	} else if (d <= 1.08e+114) {
		tmp = t_0;
	} else {
		tmp = (b + (a * (c / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -8.2e+41:
		tmp = (b + (1.0 / ((d / a) / c))) / d
	elif d <= -2.15e-132:
		tmp = t_0
	elif d <= 9.2e-158:
		tmp = (a + (d * (b / c))) / c
	elif d <= 1.08e+114:
		tmp = t_0
	else:
		tmp = (b + (a * (c / d))) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -8.2e+41)
		tmp = Float64(Float64(b + Float64(1.0 / Float64(Float64(d / a) / c))) / d);
	elseif (d <= -2.15e-132)
		tmp = t_0;
	elseif (d <= 9.2e-158)
		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
	elseif (d <= 1.08e+114)
		tmp = t_0;
	else
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -8.2e+41)
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	elseif (d <= -2.15e-132)
		tmp = t_0;
	elseif (d <= 9.2e-158)
		tmp = (a + (d * (b / c))) / c;
	elseif (d <= 1.08e+114)
		tmp = t_0;
	else
		tmp = (b + (a * (c / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.2e+41], N[(N[(b + N[(1.0 / N[(N[(d / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -2.15e-132], t$95$0, If[LessEqual[d, 9.2e-158], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.08e+114], t$95$0, N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -8.2 \cdot 10^{+41}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{\frac{d}{a}}{c}}}{d}\\

\mathbf{elif}\;d \leq -2.15 \cdot 10^{-132}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 1.08 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 52.0%

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

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

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

      \[\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 91.0%

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

        \[\leadsto \frac{b + \color{blue}{\frac{1}{\frac{d}{a \cdot c}}}}{d} \]
      2. inv-pow90.9%

        \[\leadsto \frac{b + \color{blue}{{\left(\frac{d}{a \cdot c}\right)}^{-1}}}{d} \]
      3. *-commutative90.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b + \frac{1}{\color{blue}{\frac{\frac{d}{a} \cdot 1}{c}}}}{d} \]
      5. *-rgt-identity94.9%

        \[\leadsto \frac{b + \frac{1}{\frac{\color{blue}{\frac{d}{a}}}{c}}}{d} \]
    13. Simplified94.9%

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

    if -8.2000000000000007e41 < d < -2.1499999999999998e-132 or 9.1999999999999995e-158 < d < 1.08000000000000004e114

    1. Initial program 79.8%

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

    if -2.1499999999999998e-132 < d < 9.1999999999999995e-158

    1. Initial program 54.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified54.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 89.2%

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

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

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

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

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

    if 1.08000000000000004e114 < d

    1. Initial program 39.3%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified39.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 80.1%

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

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

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

Alternative 5: 77.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{+39} \lor \neg \left(d \leq 2.4 \cdot 10^{+76}\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.00000000000000015e39 or 2.4e76 < d

    1. Initial program 50.0%

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

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

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

      \[\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 82.0%

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

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

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

    if -5.00000000000000015e39 < d < 2.4e76

    1. Initial program 69.2%

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

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

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

      \[\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 78.5%

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

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

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

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

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

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

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

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

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

Alternative 6: 72.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+40} \lor \neg \left(d \leq 5.6 \cdot 10^{+109}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.00000000000000024e40 or 5.6000000000000004e109 < d

    1. Initial program 47.5%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 0 82.6%

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

    if -8.00000000000000024e40 < d < 5.6000000000000004e109

    1. Initial program 68.8%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified68.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 75.2%

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

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

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

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

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

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

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

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

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

Alternative 7: 72.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.6 \cdot 10^{+39} \lor \neg \left(d \leq 5.2 \cdot 10^{+109}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -2.6e+39) (not (<= d 5.2e+109)))
   (/ b d)
   (/ (+ a (* d (/ b c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -2.6e+39) || !(d <= 5.2e+109)) {
		tmp = b / d;
	} 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) :: tmp
    if ((d <= (-2.6d+39)) .or. (.not. (d <= 5.2d+109))) then
        tmp = b / d
    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 tmp;
	if ((d <= -2.6e+39) || !(d <= 5.2e+109)) {
		tmp = b / d;
	} else {
		tmp = (a + (d * (b / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -2.6e+39) or not (d <= 5.2e+109):
		tmp = b / d
	else:
		tmp = (a + (d * (b / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -2.6e+39) || !(d <= 5.2e+109))
		tmp = Float64(b / d);
	else
		tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -2.6e+39) || ~((d <= 5.2e+109)))
		tmp = b / d;
	else
		tmp = (a + (d * (b / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.6e+39], N[Not[LessEqual[d, 5.2e+109]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.6 \cdot 10^{+39} \lor \neg \left(d \leq 5.2 \cdot 10^{+109}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.6e39 or 5.1999999999999997e109 < d

    1. Initial program 47.5%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 0 82.6%

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

    if -2.6e39 < d < 5.1999999999999997e109

    1. Initial program 68.8%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified68.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 75.2%

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

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

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

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

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

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

Alternative 8: 73.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{+41} \lor \neg \left(d \leq 5.2 \cdot 10^{+109}\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 -2.4e+41) (not (<= d 5.2e+109)))
   (/ b d)
   (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -2.4e+41) || !(d <= 5.2e+109)) {
		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 <= (-2.4d+41)) .or. (.not. (d <= 5.2d+109))) 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 <= -2.4e+41) || !(d <= 5.2e+109)) {
		tmp = b / d;
	} else {
		tmp = (a + (b * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -2.4e+41) or not (d <= 5.2e+109):
		tmp = b / d
	else:
		tmp = (a + (b * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -2.4e+41) || !(d <= 5.2e+109))
		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 <= -2.4e+41) || ~((d <= 5.2e+109)))
		tmp = b / d;
	else
		tmp = (a + (b * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.4e+41], N[Not[LessEqual[d, 5.2e+109]], $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 -2.4 \cdot 10^{+41} \lor \neg \left(d \leq 5.2 \cdot 10^{+109}\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 < -2.4000000000000002e41 or 5.1999999999999997e109 < d

    1. Initial program 47.5%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 0 82.6%

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

    if -2.4000000000000002e41 < d < 5.1999999999999997e109

    1. Initial program 68.8%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified68.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 75.2%

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{c}} \]
    8. Taylor expanded in d around 0 75.2%

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

        \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
    10. Simplified76.4%

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

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

Alternative 9: 77.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3.3 \cdot 10^{+41}:\\ \;\;\;\;\frac{b + \frac{1}{\frac{\frac{d}{a}}{c}}}{d}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{+76}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -3.3e+41)
   (/ (+ b (/ 1.0 (/ (/ d a) c))) d)
   (if (<= d 2.4e+76) (/ (+ a (/ d (/ c b))) c) (/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.3e+41) {
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	} else if (d <= 2.4e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / 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 <= (-3.3d+41)) then
        tmp = (b + (1.0d0 / ((d / a) / c))) / d
    else if (d <= 2.4d+76) then
        tmp = (a + (d / (c / b))) / c
    else
        tmp = (b + (c * (a / d))) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.3e+41) {
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	} else if (d <= 2.4e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -3.3e+41:
		tmp = (b + (1.0 / ((d / a) / c))) / d
	elif d <= 2.4e+76:
		tmp = (a + (d / (c / b))) / c
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -3.3e+41)
		tmp = Float64(Float64(b + Float64(1.0 / Float64(Float64(d / a) / c))) / d);
	elseif (d <= 2.4e+76)
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c);
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -3.3e+41)
		tmp = (b + (1.0 / ((d / a) / c))) / d;
	elseif (d <= 2.4e+76)
		tmp = (a + (d / (c / b))) / c;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.3e+41], N[(N[(b + N[(1.0 / N[(N[(d / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.4e+76], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{+41}:\\
\;\;\;\;\frac{b + \frac{1}{\frac{\frac{d}{a}}{c}}}{d}\\

\mathbf{elif}\;d \leq 2.4 \cdot 10^{+76}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.3e41

    1. Initial program 52.0%

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

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

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

      \[\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 91.0%

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

        \[\leadsto \frac{b + \color{blue}{\frac{1}{\frac{d}{a \cdot c}}}}{d} \]
      2. inv-pow90.9%

        \[\leadsto \frac{b + \color{blue}{{\left(\frac{d}{a \cdot c}\right)}^{-1}}}{d} \]
      3. *-commutative90.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b + \frac{1}{\color{blue}{\frac{\frac{d}{a} \cdot 1}{c}}}}{d} \]
      5. *-rgt-identity94.9%

        \[\leadsto \frac{b + \frac{1}{\frac{\color{blue}{\frac{d}{a}}}{c}}}{d} \]
    13. Simplified94.9%

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

    if -3.3e41 < d < 2.4e76

    1. Initial program 69.2%

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

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

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

      \[\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 78.5%

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

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

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

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

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

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

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

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

    if 2.4e76 < d

    1. Initial program 47.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 d around inf 72.6%

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

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

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

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

Alternative 10: 77.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3.2 \cdot 10^{+41}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{+76}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -3.2e+41)
   (/ (+ b (/ c (/ d a))) d)
   (if (<= d 3.6e+76) (/ (+ a (/ d (/ c b))) c) (/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.2e+41) {
		tmp = (b + (c / (d / a))) / d;
	} else if (d <= 3.6e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / 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 <= (-3.2d+41)) then
        tmp = (b + (c / (d / a))) / d
    else if (d <= 3.6d+76) then
        tmp = (a + (d / (c / b))) / c
    else
        tmp = (b + (c * (a / d))) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.2e+41) {
		tmp = (b + (c / (d / a))) / d;
	} else if (d <= 3.6e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -3.2e+41:
		tmp = (b + (c / (d / a))) / d
	elif d <= 3.6e+76:
		tmp = (a + (d / (c / b))) / c
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -3.2e+41)
		tmp = Float64(Float64(b + Float64(c / Float64(d / a))) / d);
	elseif (d <= 3.6e+76)
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c);
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -3.2e+41)
		tmp = (b + (c / (d / a))) / d;
	elseif (d <= 3.6e+76)
		tmp = (a + (d / (c / b))) / c;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.2e+41], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 3.6e+76], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.2 \cdot 10^{+41}:\\
\;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\

\mathbf{elif}\;d \leq 3.6 \cdot 10^{+76}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.2000000000000001e41

    1. Initial program 52.0%

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

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

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

      \[\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 91.0%

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

        \[\leadsto \frac{b + \color{blue}{\left(\sqrt[3]{\frac{a \cdot c}{d}} \cdot \sqrt[3]{\frac{a \cdot c}{d}}\right) \cdot \sqrt[3]{\frac{a \cdot c}{d}}}}{d} \]
      2. pow390.9%

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

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

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

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

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

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

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

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

    if -3.2000000000000001e41 < d < 3.6000000000000003e76

    1. Initial program 69.2%

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

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

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

      \[\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 78.5%

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

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

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

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

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

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

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

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

    if 3.6000000000000003e76 < d

    1. Initial program 47.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 d around inf 72.6%

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

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

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

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

Alternative 11: 77.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{+41}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+76}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -2.4e+41)
   (/ (+ b (* a (/ c d))) d)
   (if (<= d 2.5e+76) (/ (+ a (/ d (/ c b))) c) (/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -2.4e+41) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= 2.5e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / 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.4d+41)) then
        tmp = (b + (a * (c / d))) / d
    else if (d <= 2.5d+76) then
        tmp = (a + (d / (c / b))) / c
    else
        tmp = (b + (c * (a / d))) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -2.4e+41) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= 2.5e+76) {
		tmp = (a + (d / (c / b))) / c;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -2.4e+41:
		tmp = (b + (a * (c / d))) / d
	elif d <= 2.5e+76:
		tmp = (a + (d / (c / b))) / c
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -2.4e+41)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (d <= 2.5e+76)
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c);
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -2.4e+41)
		tmp = (b + (a * (c / d))) / d;
	elseif (d <= 2.5e+76)
		tmp = (a + (d / (c / b))) / c;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.4e+41], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 2.5e+76], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{+41}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

\mathbf{elif}\;d \leq 2.5 \cdot 10^{+76}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.4000000000000002e41

    1. Initial program 52.0%

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

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

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

      \[\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 91.0%

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

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

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

    if -2.4000000000000002e41 < d < 2.49999999999999996e76

    1. Initial program 69.2%

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

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

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

      \[\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 78.5%

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

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

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

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

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

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

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

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

    if 2.49999999999999996e76 < d

    1. Initial program 47.9%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified47.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 d around inf 72.6%

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

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

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

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

Alternative 12: 64.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{+40} \lor \neg \left(d \leq 0.7\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.05000000000000005e40 or 0.69999999999999996 < d

    1. Initial program 52.7%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified52.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 0 74.7%

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

    if -1.05000000000000005e40 < d < 0.69999999999999996

    1. Initial program 68.6%

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    3. Simplified68.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 64.5%

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

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

Alternative 13: 42.9% 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 61.7%

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

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

      \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
  3. Simplified61.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 c around inf 43.4%

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

Developer Target 1: 99.5% 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 2024136 
(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))))