Complex division, real part

Percentage Accurate: 60.7% → 81.8%
Time: 9.3s
Alternatives: 9
Speedup: 1.2×

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 9 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: 81.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ \mathbf{if}\;d \leq -2.4 \cdot 10^{+42}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-145}:\\ \;\;\;\;a \cdot \left(\frac{c}{t\_0} + \frac{\frac{d \cdot b}{t\_0}}{a}\right)\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{-71}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{+113}:\\ \;\;\;\;\frac{d \cdot b + a \cdot c}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* c c) (* d d))))
   (if (<= d -2.4e+42)
     (/ (+ b (* a (/ c d))) d)
     (if (<= d -3.2e-145)
       (* a (+ (/ c t_0) (/ (/ (* d b) t_0) a)))
       (if (<= d 4.6e-71)
         (/ (+ a (/ (* d b) c)) c)
         (if (<= d 1.65e+113)
           (/ (+ (* d b) (* a c)) t_0)
           (/ (+ b (* c (/ a d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double tmp;
	if (d <= -2.4e+42) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -3.2e-145) {
		tmp = a * ((c / t_0) + (((d * b) / t_0) / a));
	} else if (d <= 4.6e-71) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 1.65e+113) {
		tmp = ((d * b) + (a * c)) / t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = (c * c) + (d * d)
    if (d <= (-2.4d+42)) then
        tmp = (b + (a * (c / d))) / d
    else if (d <= (-3.2d-145)) then
        tmp = a * ((c / t_0) + (((d * b) / t_0) / a))
    else if (d <= 4.6d-71) then
        tmp = (a + ((d * b) / c)) / c
    else if (d <= 1.65d+113) then
        tmp = ((d * b) + (a * c)) / t_0
    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 t_0 = (c * c) + (d * d);
	double tmp;
	if (d <= -2.4e+42) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -3.2e-145) {
		tmp = a * ((c / t_0) + (((d * b) / t_0) / a));
	} else if (d <= 4.6e-71) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 1.65e+113) {
		tmp = ((d * b) + (a * c)) / t_0;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * c) + (d * d)
	tmp = 0
	if d <= -2.4e+42:
		tmp = (b + (a * (c / d))) / d
	elif d <= -3.2e-145:
		tmp = a * ((c / t_0) + (((d * b) / t_0) / a))
	elif d <= 4.6e-71:
		tmp = (a + ((d * b) / c)) / c
	elif d <= 1.65e+113:
		tmp = ((d * b) + (a * c)) / t_0
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (d <= -2.4e+42)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (d <= -3.2e-145)
		tmp = Float64(a * Float64(Float64(c / t_0) + Float64(Float64(Float64(d * b) / t_0) / a)));
	elseif (d <= 4.6e-71)
		tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c);
	elseif (d <= 1.65e+113)
		tmp = Float64(Float64(Float64(d * b) + Float64(a * c)) / t_0);
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * c) + (d * d);
	tmp = 0.0;
	if (d <= -2.4e+42)
		tmp = (b + (a * (c / d))) / d;
	elseif (d <= -3.2e-145)
		tmp = a * ((c / t_0) + (((d * b) / t_0) / a));
	elseif (d <= 4.6e-71)
		tmp = (a + ((d * b) / c)) / c;
	elseif (d <= 1.65e+113)
		tmp = ((d * b) + (a * c)) / t_0;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.4e+42], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.2e-145], N[(a * N[(N[(c / t$95$0), $MachinePrecision] + N[(N[(N[(d * b), $MachinePrecision] / t$95$0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e-71], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.65e+113], N[(N[(N[(d * b), $MachinePrecision] + N[(a * c), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -3.2 \cdot 10^{-145}:\\
\;\;\;\;a \cdot \left(\frac{c}{t\_0} + \frac{\frac{d \cdot b}{t\_0}}{a}\right)\\

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

\mathbf{elif}\;d \leq 1.65 \cdot 10^{+113}:\\
\;\;\;\;\frac{d \cdot b + a \cdot c}{t\_0}\\

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


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

    1. Initial program 36.8%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6485.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified85.0%

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

    if -2.3999999999999999e42 < d < -3.20000000000000008e-145

    1. Initial program 83.9%

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{c}{{c}^{2} + {d}^{2}} + \frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\left(\frac{c}{{c}^{2} + {d}^{2}}\right), \color{blue}{\left(\frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \left({c}^{2} + {d}^{2}\right)\right), \left(\frac{\color{blue}{b \cdot d}}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\left({c}^{2}\right), \left({d}^{2}\right)\right)\right), \left(\frac{b \cdot \color{blue}{d}}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\left(c \cdot c\right), \left({d}^{2}\right)\right)\right), \left(\frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left({d}^{2}\right)\right)\right), \left(\frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right)\right), \left(\frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(b \cdot d\right), \left({c}^{2} + {d}^{2}\right)\right), a\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \left({c}^{2} + {d}^{2}\right)\right), a\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \mathsf{+.f64}\left(\left({c}^{2}\right), \left({d}^{2}\right)\right)\right), a\right)\right)\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \mathsf{+.f64}\left(\left(c \cdot c\right), \left({d}^{2}\right)\right)\right), a\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left({d}^{2}\right)\right)\right), a\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right)\right), a\right)\right)\right) \]
      17. *-lowering-*.f6484.5%

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(\mathsf{/.f64}\left(c, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), a\right)\right)\right) \]
    5. Simplified84.5%

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

    if -3.20000000000000008e-145 < d < 4.5999999999999997e-71

    1. Initial program 63.5%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6497.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified97.0%

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

    if 4.5999999999999997e-71 < d < 1.6500000000000002e113

    1. Initial program 72.0%

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

    if 1.6500000000000002e113 < d

    1. Initial program 35.8%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6487.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified87.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{c \cdot a}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(c \cdot \frac{a}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \left(\frac{a}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6491.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(a, d\right)\right)\right), d\right) \]
    7. Applied egg-rr91.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{+42}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-145}:\\ \;\;\;\;a \cdot \left(\frac{c}{c \cdot c + d \cdot d} + \frac{\frac{d \cdot b}{c \cdot c + d \cdot d}}{a}\right)\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{-71}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{+113}:\\ \;\;\;\;\frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 81.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := d \cdot b + a \cdot c\\ t_1 := c \cdot c + d \cdot d\\ \mathbf{if}\;d \leq -850000000:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -5.5 \cdot 10^{-136}:\\ \;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-72}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+115}:\\ \;\;\;\;\frac{t\_0}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* d b) (* a c))) (t_1 (+ (* c c) (* d d))))
   (if (<= d -850000000.0)
     (/ (+ b (* a (/ c d))) d)
     (if (<= d -5.5e-136)
       (* t_0 (/ 1.0 t_1))
       (if (<= d 1.5e-72)
         (/ (+ a (/ (* d b) c)) c)
         (if (<= d 4.7e+115) (/ t_0 t_1) (/ (+ b (* c (/ a d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (d * b) + (a * c);
	double t_1 = (c * c) + (d * d);
	double tmp;
	if (d <= -850000000.0) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -5.5e-136) {
		tmp = t_0 * (1.0 / t_1);
	} else if (d <= 1.5e-72) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 4.7e+115) {
		tmp = t_0 / t_1;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (d * b) + (a * c)
    t_1 = (c * c) + (d * d)
    if (d <= (-850000000.0d0)) then
        tmp = (b + (a * (c / d))) / d
    else if (d <= (-5.5d-136)) then
        tmp = t_0 * (1.0d0 / t_1)
    else if (d <= 1.5d-72) then
        tmp = (a + ((d * b) / c)) / c
    else if (d <= 4.7d+115) then
        tmp = t_0 / t_1
    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 t_0 = (d * b) + (a * c);
	double t_1 = (c * c) + (d * d);
	double tmp;
	if (d <= -850000000.0) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -5.5e-136) {
		tmp = t_0 * (1.0 / t_1);
	} else if (d <= 1.5e-72) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 4.7e+115) {
		tmp = t_0 / t_1;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (d * b) + (a * c)
	t_1 = (c * c) + (d * d)
	tmp = 0
	if d <= -850000000.0:
		tmp = (b + (a * (c / d))) / d
	elif d <= -5.5e-136:
		tmp = t_0 * (1.0 / t_1)
	elif d <= 1.5e-72:
		tmp = (a + ((d * b) / c)) / c
	elif d <= 4.7e+115:
		tmp = t_0 / t_1
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(d * b) + Float64(a * c))
	t_1 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (d <= -850000000.0)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (d <= -5.5e-136)
		tmp = Float64(t_0 * Float64(1.0 / t_1));
	elseif (d <= 1.5e-72)
		tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c);
	elseif (d <= 4.7e+115)
		tmp = Float64(t_0 / t_1);
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (d * b) + (a * c);
	t_1 = (c * c) + (d * d);
	tmp = 0.0;
	if (d <= -850000000.0)
		tmp = (b + (a * (c / d))) / d;
	elseif (d <= -5.5e-136)
		tmp = t_0 * (1.0 / t_1);
	elseif (d <= 1.5e-72)
		tmp = (a + ((d * b) / c)) / c;
	elseif (d <= 4.7e+115)
		tmp = t_0 / t_1;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b), $MachinePrecision] + N[(a * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -850000000.0], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -5.5e-136], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.5e-72], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.7e+115], N[(t$95$0 / t$95$1), $MachinePrecision], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := d \cdot b + a \cdot c\\
t_1 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -850000000:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

\mathbf{elif}\;d \leq -5.5 \cdot 10^{-136}:\\
\;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\

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

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

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


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

    1. Initial program 39.9%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6483.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified83.1%

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

    if -8.5e8 < d < -5.4999999999999999e-136

    1. Initial program 90.6%

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

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

        \[\leadsto \left(a \cdot c + b \cdot d\right) \cdot \frac{1}{\frac{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)}{\color{blue}{c \cdot c - d \cdot d}}} \]
      3. clear-numN/A

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

        \[\leadsto \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \cdot \color{blue}{\left(a \cdot c + b \cdot d\right)} \]
      5. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right)\right), \left(a \cdot c + b \cdot d\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \left(a \cdot c + b \cdot d\right)\right) \]
      12. +-lowering-+.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, c\right), \left(\color{blue}{b} \cdot d\right)\right)\right) \]
      14. *-lowering-*.f6490.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, c\right), \mathsf{*.f64}\left(b, \color{blue}{d}\right)\right)\right) \]
    4. Applied egg-rr90.7%

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

    if -5.4999999999999999e-136 < d < 1.5e-72

    1. Initial program 63.7%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6496.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified96.2%

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

    if 1.5e-72 < d < 4.6999999999999996e115

    1. Initial program 72.0%

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

    if 4.6999999999999996e115 < d

    1. Initial program 35.8%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6487.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified87.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{c \cdot a}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(c \cdot \frac{a}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \left(\frac{a}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6491.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(a, d\right)\right)\right), d\right) \]
    7. Applied egg-rr91.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -850000000:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -5.5 \cdot 10^{-136}:\\ \;\;\;\;\left(d \cdot b + a \cdot c\right) \cdot \frac{1}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-72}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+115}:\\ \;\;\;\;\frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -850000000:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-136}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{+119}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* d b) (* a c)) (+ (* c c) (* d d)))))
   (if (<= d -850000000.0)
     (/ (+ b (* a (/ c d))) d)
     (if (<= d -2.5e-136)
       t_0
       (if (<= d 2.5e-71)
         (/ (+ a (/ (* d b) c)) c)
         (if (<= d 8.8e+119) t_0 (/ (+ b (* c (/ a d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((d * b) + (a * c)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -850000000.0) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -2.5e-136) {
		tmp = t_0;
	} else if (d <= 2.5e-71) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 8.8e+119) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = ((d * b) + (a * c)) / ((c * c) + (d * d))
    if (d <= (-850000000.0d0)) then
        tmp = (b + (a * (c / d))) / d
    else if (d <= (-2.5d-136)) then
        tmp = t_0
    else if (d <= 2.5d-71) then
        tmp = (a + ((d * b) / c)) / c
    else if (d <= 8.8d+119) then
        tmp = t_0
    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 t_0 = ((d * b) + (a * c)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -850000000.0) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= -2.5e-136) {
		tmp = t_0;
	} else if (d <= 2.5e-71) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 8.8e+119) {
		tmp = t_0;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((d * b) + (a * c)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -850000000.0:
		tmp = (b + (a * (c / d))) / d
	elif d <= -2.5e-136:
		tmp = t_0
	elif d <= 2.5e-71:
		tmp = (a + ((d * b) / c)) / c
	elif d <= 8.8e+119:
		tmp = t_0
	else:
		tmp = (b + (c * (a / d))) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(d * b) + Float64(a * c)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -850000000.0)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (d <= -2.5e-136)
		tmp = t_0;
	elseif (d <= 2.5e-71)
		tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c);
	elseif (d <= 8.8e+119)
		tmp = t_0;
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((d * b) + (a * c)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -850000000.0)
		tmp = (b + (a * (c / d))) / d;
	elseif (d <= -2.5e-136)
		tmp = t_0;
	elseif (d <= 2.5e-71)
		tmp = (a + ((d * b) / c)) / c;
	elseif (d <= 8.8e+119)
		tmp = t_0;
	else
		tmp = (b + (c * (a / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(a * c), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -850000000.0], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -2.5e-136], t$95$0, If[LessEqual[d, 2.5e-71], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8.8e+119], t$95$0, N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -850000000:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

\mathbf{elif}\;d \leq -2.5 \cdot 10^{-136}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 8.8 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 39.9%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6483.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified83.1%

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

    if -8.5e8 < d < -2.5000000000000001e-136 or 2.49999999999999999e-71 < d < 8.8000000000000005e119

    1. Initial program 78.4%

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

    if -2.5000000000000001e-136 < d < 2.49999999999999999e-71

    1. Initial program 63.7%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6496.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified96.2%

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

    if 8.8000000000000005e119 < d

    1. Initial program 35.8%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6487.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified87.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{c \cdot a}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(c \cdot \frac{a}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \left(\frac{a}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6491.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(a, d\right)\right)\right), d\right) \]
    7. Applied egg-rr91.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -850000000:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-136}:\\ \;\;\;\;\frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{+119}:\\ \;\;\;\;\frac{d \cdot b + a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.4% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 4.2 \cdot 10^{-24}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{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 < -1.75000000000000003e-49

    1. Initial program 47.2%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6479.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified79.9%

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

    if -1.75000000000000003e-49 < d < 4.1999999999999999e-24

    1. Initial program 66.7%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6488.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified88.9%

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

    if 4.1999999999999999e-24 < d

    1. Initial program 54.4%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6476.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified76.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{c \cdot a}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(c \cdot \frac{a}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \left(\frac{a}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6478.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(c, \mathsf{/.f64}\left(a, d\right)\right)\right), d\right) \]
    7. Applied egg-rr78.6%

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

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

Alternative 5: 77.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{if}\;d \leq -5.6 \cdot 10^{-50}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.5999999999999996e-50 or 5.0000000000000002e-23 < d

    1. Initial program 50.6%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(\frac{a \cdot c}{d}\right)\right), d\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \left(a \cdot \frac{c}{d}\right)\right), d\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \left(\frac{c}{d}\right)\right)\right), d\right) \]
      5. /-lowering-/.f6478.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(b, \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(c, d\right)\right)\right), d\right) \]
    5. Simplified78.5%

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

    if -5.5999999999999996e-50 < d < 5.0000000000000002e-23

    1. Initial program 66.7%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6488.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified88.9%

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

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

Alternative 6: 72.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -550000000000:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq 36000:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.5e11 or 36000 < d

    1. Initial program 46.8%

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

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6469.5%

        \[\leadsto \mathsf{/.f64}\left(b, \color{blue}{d}\right) \]
    5. Simplified69.5%

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

    if -5.5e11 < d < 36000

    1. Initial program 68.0%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6484.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -550000000000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 36000:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 71.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1250000000000:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq 58000:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.25e12 or 58000 < d

    1. Initial program 46.8%

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

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6469.5%

        \[\leadsto \mathsf{/.f64}\left(b, \color{blue}{d}\right) \]
    5. Simplified69.5%

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

    if -1.25e12 < d < 58000

    1. Initial program 68.0%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(\frac{b \cdot d}{c}\right)\right), c\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\left(b \cdot d\right), c\right)\right), c\right) \]
      4. *-lowering-*.f6484.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{/.f64}\left(\mathsf{*.f64}\left(b, d\right), c\right)\right), c\right) \]
    5. Simplified84.2%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \left(d \cdot \frac{b}{c}\right)\right), c\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{*.f64}\left(d, \left(\frac{b}{c}\right)\right)\right), c\right) \]
      4. /-lowering-/.f6483.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \mathsf{*.f64}\left(d, \mathsf{/.f64}\left(b, c\right)\right)\right), c\right) \]
    7. Applied egg-rr83.5%

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

Alternative 8: 64.1% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -70000000000:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq 1.35 \cdot 10^{-56}:\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7e10 or 1.34999999999999997e-56 < d

    1. Initial program 49.0%

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

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

        \[\leadsto \mathsf{/.f64}\left(b, \color{blue}{d}\right) \]
    5. Simplified65.0%

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

    if -7e10 < d < 1.34999999999999997e-56

    1. Initial program 68.5%

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6469.9%

        \[\leadsto \mathsf{/.f64}\left(a, \color{blue}{c}\right) \]
    5. Simplified69.9%

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

Alternative 9: 43.3% 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 58.7%

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

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

      \[\leadsto \mathsf{/.f64}\left(a, \color{blue}{c}\right) \]
  5. Simplified44.6%

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

Developer Target 1: 99.2% 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 2024156 
(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))))