Complex division, real part

Percentage Accurate: 61.0% → 80.4%
Time: 8.5s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 61.0% 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: 80.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.72:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\

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

\mathbf{elif}\;d \leq 1.05 \cdot 10^{+85}:\\
\;\;\;\;\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}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -0.71999999999999997

    1. Initial program 40.5%

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

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

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

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

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

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

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

    if -0.71999999999999997 < d < 1.69999999999999995e-101

    1. Initial program 77.6%

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

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

    if 1.69999999999999995e-101 < d < 1.05000000000000005e85

    1. Initial program 87.8%

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

    if 1.05000000000000005e85 < d

    1. Initial program 37.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -0.72:\\ \;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-101}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{+85}:\\ \;\;\;\;\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: 72.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;d \leq -1.75:\\
\;\;\;\;\frac{\frac{a \cdot c}{d}}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.59999999999999988e76 or 1.32e21 < d

    1. Initial program 40.6%

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

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

    if -1.59999999999999988e76 < d < -2.2500000000000001e24

    1. Initial program 46.2%

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

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

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

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

    if -2.2500000000000001e24 < d < -1.75

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. associate-/l*80.8%

        \[\leadsto \color{blue}{a \cdot \frac{c}{{d}^{2}}} \]
    8. Simplified80.8%

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
      2. unpow281.1%

        \[\leadsto \frac{a \cdot c}{\color{blue}{d \cdot d}} \]
      3. associate-/r*81.1%

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

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}}}{d} \]
    10. Applied egg-rr80.5%

      \[\leadsto \color{blue}{\frac{a \cdot \frac{c}{d}}{d}} \]
    11. Taylor expanded in a around 0 81.1%

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

    if -1.75 < d < 1.32e21

    1. Initial program 79.5%

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

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

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

Alternative 3: 78.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;d \leq 3.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{d \cdot b}{c \cdot c + d \cdot d}\\

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

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


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

    1. Initial program 40.5%

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

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

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

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

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

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

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

    if -0.900000000000000022 < d < 2.40000000000000022e-41

    1. Initial program 77.8%

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

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

    if 2.40000000000000022e-41 < d < 3.79999999999999996e-12

    1. Initial program 99.7%

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

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

    if 3.79999999999999996e-12 < d < 5.59999999999999976e47

    1. Initial program 77.1%

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

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

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

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

    if 5.59999999999999976e47 < d

    1. Initial program 45.1%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 61.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.26 \cdot 10^{+76}:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq -1.4 \cdot 10^{+37}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;d \leq -0.28:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.26000000000000007e76 or 1.55000000000000005e-40 < d

    1. Initial program 48.2%

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

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

    if -1.26000000000000007e76 < d < -1.3999999999999999e37 or -1.5999999999999999e-70 < d < 1.55000000000000005e-40

    1. Initial program 74.5%

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

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

    if -1.3999999999999999e37 < d < -0.28000000000000003

    1. Initial program 86.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. associate-/l*58.1%

        \[\leadsto \color{blue}{a \cdot \frac{c}{{d}^{2}}} \]
    8. Simplified58.1%

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
      2. unpow258.3%

        \[\leadsto \frac{a \cdot c}{\color{blue}{d \cdot d}} \]
      3. associate-/r*58.3%

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

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}}}{d} \]
    10. Applied egg-rr57.9%

      \[\leadsto \color{blue}{\frac{a \cdot \frac{c}{d}}{d}} \]
    11. Step-by-step derivation
      1. *-commutative57.9%

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

        \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{a}{d}} \]
    12. Applied egg-rr57.9%

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

    if -0.28000000000000003 < d < -1.5999999999999999e-70

    1. Initial program 84.4%

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

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

      \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}}}{c} \]
    5. Step-by-step derivation
      1. *-commutative51.7%

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}}}{c} \]
    6. Simplified51.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.26 \cdot 10^{+76}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{+37}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -0.28:\\ \;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{elif}\;d \leq -1.6 \cdot 10^{-70}:\\ \;\;\;\;\frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{-40}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 61.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.26 \cdot 10^{+76}:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq -1.05 \cdot 10^{+38}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;d \leq -0.45:\\
\;\;\;\;\frac{\frac{a}{\frac{d}{c}}}{d}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.26000000000000007e76 or 1.15e-40 < d

    1. Initial program 48.2%

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

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

    if -1.26000000000000007e76 < d < -1.05e38 or -2.75e-70 < d < 1.15e-40

    1. Initial program 74.5%

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

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

    if -1.05e38 < d < -0.450000000000000011

    1. Initial program 86.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. associate-/l*58.1%

        \[\leadsto \color{blue}{a \cdot \frac{c}{{d}^{2}}} \]
    8. Simplified58.1%

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
      2. unpow258.3%

        \[\leadsto \frac{a \cdot c}{\color{blue}{d \cdot d}} \]
      3. associate-/r*58.3%

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

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}}}{d} \]
    10. Applied egg-rr57.9%

      \[\leadsto \color{blue}{\frac{a \cdot \frac{c}{d}}{d}} \]
    11. Step-by-step derivation
      1. clear-num85.7%

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

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

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

    if -0.450000000000000011 < d < -2.75e-70

    1. Initial program 84.4%

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

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

      \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}}}{c} \]
    5. Step-by-step derivation
      1. *-commutative51.7%

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}}}{c} \]
    6. Simplified51.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.26 \cdot 10^{+76}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -1.05 \cdot 10^{+38}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -0.45:\\ \;\;\;\;\frac{\frac{a}{\frac{d}{c}}}{d}\\ \mathbf{elif}\;d \leq -2.75 \cdot 10^{-70}:\\ \;\;\;\;\frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-40}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{+76}:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq -1.05 \cdot 10^{+32}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;d \leq -1.05:\\
\;\;\;\;\frac{\frac{a \cdot c}{d}}{d}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.59999999999999988e76 or 7.6999999999999997e-41 < d

    1. Initial program 48.2%

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

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

    if -1.59999999999999988e76 < d < -1.05e32 or -2.4000000000000001e-70 < d < 7.6999999999999997e-41

    1. Initial program 74.5%

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

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

    if -1.05e32 < d < -1.05000000000000004

    1. Initial program 86.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
    7. Step-by-step derivation
      1. associate-/l*58.1%

        \[\leadsto \color{blue}{a \cdot \frac{c}{{d}^{2}}} \]
    8. Simplified58.1%

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{d}^{2}}} \]
      2. unpow258.3%

        \[\leadsto \frac{a \cdot c}{\color{blue}{d \cdot d}} \]
      3. associate-/r*58.3%

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

        \[\leadsto \frac{\color{blue}{a \cdot \frac{c}{d}}}{d} \]
    10. Applied egg-rr57.9%

      \[\leadsto \color{blue}{\frac{a \cdot \frac{c}{d}}{d}} \]
    11. Taylor expanded in a around 0 58.3%

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

    if -1.05000000000000004 < d < -2.4000000000000001e-70

    1. Initial program 84.4%

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

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

      \[\leadsto \frac{\color{blue}{\frac{b \cdot d}{c}}}{c} \]
    5. Step-by-step derivation
      1. *-commutative51.7%

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

        \[\leadsto \frac{\color{blue}{d \cdot \frac{b}{c}}}{c} \]
    6. Simplified51.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+76}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -1.05 \cdot 10^{+32}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -1.05:\\ \;\;\;\;\frac{\frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-70}:\\ \;\;\;\;\frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{elif}\;d \leq 7.7 \cdot 10^{-41}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 72.6% accurate, 0.8× speedup?

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

    1. Initial program 40.6%

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

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

    if -1.36000000000000004e76 < d < 4.65e20

    1. Initial program 77.8%

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

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

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

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

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

Alternative 8: 78.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.8 \lor \neg \left(d \leq 3.8 \cdot 10^{+46}\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.80000000000000004 or 3.7999999999999999e46 < d

    1. Initial program 42.4%

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

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

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

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

    if -0.80000000000000004 < d < 3.7999999999999999e46

    1. Initial program 79.5%

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

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

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

Alternative 9: 78.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -0.42:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+46}:\\ \;\;\;\;\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 -0.42)
   (/ (+ b (* a (/ c d))) d)
   (if (<= d 6.5e+46) (/ (+ a (/ (* d b) c)) c) (/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -0.42) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= 6.5e+46) {
		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 <= (-0.42d0)) then
        tmp = (b + (a * (c / d))) / d
    else if (d <= 6.5d+46) 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 <= -0.42) {
		tmp = (b + (a * (c / d))) / d;
	} else if (d <= 6.5e+46) {
		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 <= -0.42:
		tmp = (b + (a * (c / d))) / d
	elif d <= 6.5e+46:
		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 <= -0.42)
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	elseif (d <= 6.5e+46)
		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 <= -0.42)
		tmp = (b + (a * (c / d))) / d;
	elseif (d <= 6.5e+46)
		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, -0.42], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 6.5e+46], 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 -0.42:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

\mathbf{elif}\;d \leq 6.5 \cdot 10^{+46}:\\
\;\;\;\;\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 < -0.419999999999999984

    1. Initial program 40.5%

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

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

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

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

    if -0.419999999999999984 < d < 6.50000000000000008e46

    1. Initial program 79.5%

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

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

    if 6.50000000000000008e46 < d

    1. Initial program 45.1%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 78.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -0.65:\\ \;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+46}:\\ \;\;\;\;\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 -0.65)
   (/ (+ b (/ a (/ d c))) d)
   (if (<= d 5.2e+46) (/ (+ a (/ (* d b) c)) c) (/ (+ b (* c (/ a d))) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -0.65) {
		tmp = (b + (a / (d / c))) / d;
	} else if (d <= 5.2e+46) {
		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 <= (-0.65d0)) then
        tmp = (b + (a / (d / c))) / d
    else if (d <= 5.2d+46) 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 <= -0.65) {
		tmp = (b + (a / (d / c))) / d;
	} else if (d <= 5.2e+46) {
		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 <= -0.65:
		tmp = (b + (a / (d / c))) / d
	elif d <= 5.2e+46:
		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 <= -0.65)
		tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / d);
	elseif (d <= 5.2e+46)
		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 <= -0.65)
		tmp = (b + (a / (d / c))) / d;
	elseif (d <= 5.2e+46)
		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, -0.65], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 5.2e+46], 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 -0.65:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{d}\\

\mathbf{elif}\;d \leq 5.2 \cdot 10^{+46}:\\
\;\;\;\;\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 < -0.650000000000000022

    1. Initial program 40.5%

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

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

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

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

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

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

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

    if -0.650000000000000022 < d < 5.20000000000000027e46

    1. Initial program 79.5%

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

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

    if 5.20000000000000027e46 < d

    1. Initial program 45.1%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 63.2% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.6000000000000003e76 or 1.4499999999999999e-40 < d

    1. Initial program 48.2%

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

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

    if -3.6000000000000003e76 < d < 1.4499999999999999e-40

    1. Initial program 76.1%

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

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

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

Alternative 12: 42.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 62.7%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  4. Final simplification40.9%

    \[\leadsto \frac{a}{c} \]
  5. Add Preprocessing

Developer target: 99.3% 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 2024074 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :alt
  (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))))