Complex division, real part

Percentage Accurate: 61.9% → 80.5%
Time: 13.1s
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.9% 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.5% accurate, 0.1× speedup?

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

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

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

\mathbf{elif}\;c \leq 1.7 \cdot 10^{-160}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\

\mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -9.19999999999999987e50 or 1.1200000000000001e-11 < c

    1. Initial program 44.4%

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

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

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

        \[\leadsto \frac{a}{c} + \frac{d \cdot b}{\color{blue}{c \cdot c}} \]
      3. times-frac85.2%

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

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

    if -9.19999999999999987e50 < c < -2.00000000000000007e-97

    1. Initial program 87.5%

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

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

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

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

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

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

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

    if -2.00000000000000007e-97 < c < 1.70000000000000011e-160

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c \cdot a}{d}}{d}} + \frac{b}{d} \]
      4. div-inv92.9%

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out93.8%

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

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv93.9%

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

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

    if 1.70000000000000011e-160 < c < 1.1200000000000001e-11

    1. Initial program 91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.2 \cdot 10^{+50}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-97}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 2: 85.7% accurate, 0.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e304

    1. Initial program 79.6%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity79.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt79.6%

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{a \cdot c + b \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def79.6%

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

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

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

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

    if 9.9999999999999994e304 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 17.6%

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

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

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot b}}{{c}^{2}} \]
      2. unpow253.9%

        \[\leadsto \frac{a}{c} + \frac{d \cdot b}{\color{blue}{c \cdot c}} \]
      3. times-frac66.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 10^{+305}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 3: 80.5% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;c \leq -9 \cdot 10^{-109}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 1.15 \cdot 10^{-160}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\

\mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.9499999999999999e50 or 1.1200000000000001e-11 < c

    1. Initial program 44.4%

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

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

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

        \[\leadsto \frac{a}{c} + \frac{d \cdot b}{\color{blue}{c \cdot c}} \]
      3. times-frac85.2%

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

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

    if -2.9499999999999999e50 < c < -9.0000000000000002e-109 or 1.14999999999999992e-160 < c < 1.1200000000000001e-11

    1. Initial program 89.9%

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

    if -9.0000000000000002e-109 < c < 1.14999999999999992e-160

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c \cdot a}{d}}{d}} + \frac{b}{d} \]
      4. div-inv92.9%

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out93.8%

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

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv93.9%

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

      \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(a \cdot \frac{c}{d} + b\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.95 \cdot 10^{+50}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq -9 \cdot 10^{-109}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{-11}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 4: 72.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-28} \lor \neg \left(c \leq 7.5 \cdot 10^{-109}\right) \land \left(c \leq 2.4 \cdot 10^{-31} \lor \neg \left(c \leq 1.45 \cdot 10^{-11}\right)\right):\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.8500000000000001e-28 or 7.49999999999999982e-109 < c < 2.4e-31 or 1.45e-11 < c

    1. Initial program 54.8%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{b \cdot d}{\color{blue}{1 \cdot \left(c \cdot c\right)}} \]
      3. times-frac77.6%

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b}{1} \cdot \frac{d}{c \cdot c}} \]
      4. /-rgt-identity77.6%

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

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

    if -1.8500000000000001e-28 < c < 7.49999999999999982e-109 or 2.4e-31 < c < 1.45e-11

    1. Initial program 75.9%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow279.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out88.0%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative88.0%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(a \cdot \color{blue}{\frac{c}{d}} + b\right) \]
    6. Applied egg-rr88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.85 \cdot 10^{-28} \lor \neg \left(c \leq 7.5 \cdot 10^{-109}\right) \land \left(c \leq 2.4 \cdot 10^{-31} \lor \neg \left(c \leq 1.45 \cdot 10^{-11}\right)\right):\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \end{array} \]

Alternative 5: 72.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ t_1 := \frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{if}\;c \leq -1.45 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + d \cdot \frac{b}{c \cdot c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d)))))
        (t_1 (+ (/ a c) (* b (/ d (* c c))))))
   (if (<= c -1.45e-31)
     t_1
     (if (<= c 3.4e-105)
       t_0
       (if (<= c 5.2e-38)
         t_1
         (if (<= c 1.3e-11) t_0 (+ (/ a c) (* d (/ b (* c c))))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = (a / c) + (b * (d / (c * c)));
	double tmp;
	if (c <= -1.45e-31) {
		tmp = t_1;
	} else if (c <= 3.4e-105) {
		tmp = t_0;
	} else if (c <= 5.2e-38) {
		tmp = t_1;
	} else if (c <= 1.3e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + (d * (b / (c * c)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (1.0d0 / d) * (b + (a * (c / d)))
    t_1 = (a / c) + (b * (d / (c * c)))
    if (c <= (-1.45d-31)) then
        tmp = t_1
    else if (c <= 3.4d-105) then
        tmp = t_0
    else if (c <= 5.2d-38) then
        tmp = t_1
    else if (c <= 1.3d-11) then
        tmp = t_0
    else
        tmp = (a / c) + (d * (b / (c * c)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = (a / c) + (b * (d / (c * c)));
	double tmp;
	if (c <= -1.45e-31) {
		tmp = t_1;
	} else if (c <= 3.4e-105) {
		tmp = t_0;
	} else if (c <= 5.2e-38) {
		tmp = t_1;
	} else if (c <= 1.3e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + (d * (b / (c * c)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (1.0 / d) * (b + (a * (c / d)))
	t_1 = (a / c) + (b * (d / (c * c)))
	tmp = 0
	if c <= -1.45e-31:
		tmp = t_1
	elif c <= 3.4e-105:
		tmp = t_0
	elif c <= 5.2e-38:
		tmp = t_1
	elif c <= 1.3e-11:
		tmp = t_0
	else:
		tmp = (a / c) + (d * (b / (c * c)))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d))))
	t_1 = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c))))
	tmp = 0.0
	if (c <= -1.45e-31)
		tmp = t_1;
	elseif (c <= 3.4e-105)
		tmp = t_0;
	elseif (c <= 5.2e-38)
		tmp = t_1;
	elseif (c <= 1.3e-11)
		tmp = t_0;
	else
		tmp = Float64(Float64(a / c) + Float64(d * Float64(b / Float64(c * c))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (1.0 / d) * (b + (a * (c / d)));
	t_1 = (a / c) + (b * (d / (c * c)));
	tmp = 0.0;
	if (c <= -1.45e-31)
		tmp = t_1;
	elseif (c <= 3.4e-105)
		tmp = t_0;
	elseif (c <= 5.2e-38)
		tmp = t_1;
	elseif (c <= 1.3e-11)
		tmp = t_0;
	else
		tmp = (a / c) + (d * (b / (c * c)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.45e-31], t$95$1, If[LessEqual[c, 3.4e-105], t$95$0, If[LessEqual[c, 5.2e-38], t$95$1, If[LessEqual[c, 1.3e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
t_1 := \frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\
\mathbf{if}\;c \leq -1.45 \cdot 10^{-31}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 3.4 \cdot 10^{-105}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 5.2 \cdot 10^{-38}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.45e-31 or 3.39999999999999992e-105 < c < 5.20000000000000022e-38

    1. Initial program 60.6%

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{{c}^{2}}} \]
    3. Step-by-step derivation
      1. unpow275.5%

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{b \cdot d}{\color{blue}{1 \cdot \left(c \cdot c\right)}} \]
      3. times-frac75.8%

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b}{1} \cdot \frac{d}{c \cdot c}} \]
      4. /-rgt-identity75.8%

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

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

    if -1.45e-31 < c < 3.39999999999999992e-105 or 5.20000000000000022e-38 < c < 1.3e-11

    1. Initial program 75.9%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow279.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out88.0%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative88.0%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(a \cdot \color{blue}{\frac{c}{d}} + b\right) \]
    6. Applied egg-rr88.0%

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

    if 1.3e-11 < c

    1. Initial program 47.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.45 \cdot 10^{-31}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{-38}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + d \cdot \frac{b}{c \cdot c}\\ \end{array} \]

Alternative 6: 75.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{if}\;c \leq -5.3 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{-37}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d)))))
        (t_1 (+ (/ a c) (* (/ d c) (/ b c)))))
   (if (<= c -5.3e-29)
     t_1
     (if (<= c 6.8e-105)
       t_0
       (if (<= c 6.2e-37)
         (+ (/ a c) (* b (/ d (* c c))))
         (if (<= c 1.3e-11) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = (a / c) + ((d / c) * (b / c));
	double tmp;
	if (c <= -5.3e-29) {
		tmp = t_1;
	} else if (c <= 6.8e-105) {
		tmp = t_0;
	} else if (c <= 6.2e-37) {
		tmp = (a / c) + (b * (d / (c * c)));
	} else if (c <= 1.3e-11) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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 = (1.0d0 / d) * (b + (a * (c / d)))
    t_1 = (a / c) + ((d / c) * (b / c))
    if (c <= (-5.3d-29)) then
        tmp = t_1
    else if (c <= 6.8d-105) then
        tmp = t_0
    else if (c <= 6.2d-37) then
        tmp = (a / c) + (b * (d / (c * c)))
    else if (c <= 1.3d-11) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = (a / c) + ((d / c) * (b / c));
	double tmp;
	if (c <= -5.3e-29) {
		tmp = t_1;
	} else if (c <= 6.8e-105) {
		tmp = t_0;
	} else if (c <= 6.2e-37) {
		tmp = (a / c) + (b * (d / (c * c)));
	} else if (c <= 1.3e-11) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (1.0 / d) * (b + (a * (c / d)))
	t_1 = (a / c) + ((d / c) * (b / c))
	tmp = 0
	if c <= -5.3e-29:
		tmp = t_1
	elif c <= 6.8e-105:
		tmp = t_0
	elif c <= 6.2e-37:
		tmp = (a / c) + (b * (d / (c * c)))
	elif c <= 1.3e-11:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d))))
	t_1 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c)))
	tmp = 0.0
	if (c <= -5.3e-29)
		tmp = t_1;
	elseif (c <= 6.8e-105)
		tmp = t_0;
	elseif (c <= 6.2e-37)
		tmp = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c))));
	elseif (c <= 1.3e-11)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (1.0 / d) * (b + (a * (c / d)));
	t_1 = (a / c) + ((d / c) * (b / c));
	tmp = 0.0;
	if (c <= -5.3e-29)
		tmp = t_1;
	elseif (c <= 6.8e-105)
		tmp = t_0;
	elseif (c <= 6.2e-37)
		tmp = (a / c) + (b * (d / (c * c)));
	elseif (c <= 1.3e-11)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.3e-29], t$95$1, If[LessEqual[c, 6.8e-105], t$95$0, If[LessEqual[c, 6.2e-37], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e-11], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -5.3 \cdot 10^{-29}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.2999999999999999e-29 or 1.3e-11 < c

    1. Initial program 48.8%

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

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

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

        \[\leadsto \frac{a}{c} + \frac{d \cdot b}{\color{blue}{c \cdot c}} \]
      3. times-frac84.2%

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

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

    if -5.2999999999999999e-29 < c < 6.79999999999999984e-105 or 6.19999999999999987e-37 < c < 1.3e-11

    1. Initial program 75.9%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow279.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out88.0%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative88.0%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(a \cdot \color{blue}{\frac{c}{d}} + b\right) \]
    6. Applied egg-rr88.0%

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

    if 6.79999999999999984e-105 < c < 6.19999999999999987e-37

    1. Initial program 94.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{b \cdot d}{\color{blue}{1 \cdot \left(c \cdot c\right)}} \]
      3. times-frac64.7%

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b}{1} \cdot \frac{d}{c \cdot c}} \]
      4. /-rgt-identity64.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.3 \cdot 10^{-29}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{-37}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 7: 75.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{if}\;c \leq -3.8 \cdot 10^{-28}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{-30}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d))))))
   (if (<= c -3.8e-28)
     (+ (/ a c) (/ (* b (/ d c)) c))
     (if (<= c 6.8e-105)
       t_0
       (if (<= c 5.6e-30)
         (+ (/ a c) (* b (/ d (* c c))))
         (if (<= c 1.2e-11) t_0 (+ (/ a c) (* (/ d c) (/ b c)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double tmp;
	if (c <= -3.8e-28) {
		tmp = (a / c) + ((b * (d / c)) / c);
	} else if (c <= 6.8e-105) {
		tmp = t_0;
	} else if (c <= 5.6e-30) {
		tmp = (a / c) + (b * (d / (c * c)));
	} else if (c <= 1.2e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d / c) * (b / c));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 / d) * (b + (a * (c / d)))
    if (c <= (-3.8d-28)) then
        tmp = (a / c) + ((b * (d / c)) / c)
    else if (c <= 6.8d-105) then
        tmp = t_0
    else if (c <= 5.6d-30) then
        tmp = (a / c) + (b * (d / (c * c)))
    else if (c <= 1.2d-11) then
        tmp = t_0
    else
        tmp = (a / c) + ((d / c) * (b / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double tmp;
	if (c <= -3.8e-28) {
		tmp = (a / c) + ((b * (d / c)) / c);
	} else if (c <= 6.8e-105) {
		tmp = t_0;
	} else if (c <= 5.6e-30) {
		tmp = (a / c) + (b * (d / (c * c)));
	} else if (c <= 1.2e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d / c) * (b / c));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (1.0 / d) * (b + (a * (c / d)))
	tmp = 0
	if c <= -3.8e-28:
		tmp = (a / c) + ((b * (d / c)) / c)
	elif c <= 6.8e-105:
		tmp = t_0
	elif c <= 5.6e-30:
		tmp = (a / c) + (b * (d / (c * c)))
	elif c <= 1.2e-11:
		tmp = t_0
	else:
		tmp = (a / c) + ((d / c) * (b / c))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d))))
	tmp = 0.0
	if (c <= -3.8e-28)
		tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c));
	elseif (c <= 6.8e-105)
		tmp = t_0;
	elseif (c <= 5.6e-30)
		tmp = Float64(Float64(a / c) + Float64(b * Float64(d / Float64(c * c))));
	elseif (c <= 1.2e-11)
		tmp = t_0;
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (1.0 / d) * (b + (a * (c / d)));
	tmp = 0.0;
	if (c <= -3.8e-28)
		tmp = (a / c) + ((b * (d / c)) / c);
	elseif (c <= 6.8e-105)
		tmp = t_0;
	elseif (c <= 5.6e-30)
		tmp = (a / c) + (b * (d / (c * c)));
	elseif (c <= 1.2e-11)
		tmp = t_0;
	else
		tmp = (a / c) + ((d / c) * (b / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.8e-28], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.8e-105], t$95$0, If[LessEqual[c, 5.6e-30], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.2e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{if}\;c \leq -3.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\

\mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.2 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -3.80000000000000009e-28

    1. Initial program 50.3%

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{{c}^{2}}} \]
    3. Step-by-step derivation
      1. unpow278.9%

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

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

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

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

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

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

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

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

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

    if -3.80000000000000009e-28 < c < 6.79999999999999984e-105 or 5.59999999999999977e-30 < c < 1.2000000000000001e-11

    1. Initial program 75.9%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow279.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out88.0%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative88.0%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(a \cdot \color{blue}{\frac{c}{d}} + b\right) \]
    6. Applied egg-rr88.0%

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

    if 6.79999999999999984e-105 < c < 5.59999999999999977e-30

    1. Initial program 94.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{b \cdot d}{\color{blue}{1 \cdot \left(c \cdot c\right)}} \]
      3. times-frac64.7%

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b}{1} \cdot \frac{d}{c \cdot c}} \]
      4. /-rgt-identity64.7%

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

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

    if 1.2000000000000001e-11 < c

    1. Initial program 47.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{-28}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{-30}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 8: 75.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ t_1 := b \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{a}{c} + \frac{t_1}{c}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-31}:\\ \;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{t_1}}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d))))) (t_1 (* b (/ d c))))
   (if (<= c -2.8e-32)
     (+ (/ a c) (/ t_1 c))
     (if (<= c 4e-106)
       t_0
       (if (<= c 8.6e-31)
         (+ (/ a c) (/ 1.0 (/ c t_1)))
         (if (<= c 1.15e-11) t_0 (+ (/ a c) (* (/ d c) (/ b c)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = b * (d / c);
	double tmp;
	if (c <= -2.8e-32) {
		tmp = (a / c) + (t_1 / c);
	} else if (c <= 4e-106) {
		tmp = t_0;
	} else if (c <= 8.6e-31) {
		tmp = (a / c) + (1.0 / (c / t_1));
	} else if (c <= 1.15e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d / c) * (b / c));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (1.0d0 / d) * (b + (a * (c / d)))
    t_1 = b * (d / c)
    if (c <= (-2.8d-32)) then
        tmp = (a / c) + (t_1 / c)
    else if (c <= 4d-106) then
        tmp = t_0
    else if (c <= 8.6d-31) then
        tmp = (a / c) + (1.0d0 / (c / t_1))
    else if (c <= 1.15d-11) then
        tmp = t_0
    else
        tmp = (a / c) + ((d / c) * (b / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / d) * (b + (a * (c / d)));
	double t_1 = b * (d / c);
	double tmp;
	if (c <= -2.8e-32) {
		tmp = (a / c) + (t_1 / c);
	} else if (c <= 4e-106) {
		tmp = t_0;
	} else if (c <= 8.6e-31) {
		tmp = (a / c) + (1.0 / (c / t_1));
	} else if (c <= 1.15e-11) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d / c) * (b / c));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (1.0 / d) * (b + (a * (c / d)))
	t_1 = b * (d / c)
	tmp = 0
	if c <= -2.8e-32:
		tmp = (a / c) + (t_1 / c)
	elif c <= 4e-106:
		tmp = t_0
	elif c <= 8.6e-31:
		tmp = (a / c) + (1.0 / (c / t_1))
	elif c <= 1.15e-11:
		tmp = t_0
	else:
		tmp = (a / c) + ((d / c) * (b / c))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d))))
	t_1 = Float64(b * Float64(d / c))
	tmp = 0.0
	if (c <= -2.8e-32)
		tmp = Float64(Float64(a / c) + Float64(t_1 / c));
	elseif (c <= 4e-106)
		tmp = t_0;
	elseif (c <= 8.6e-31)
		tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / t_1)));
	elseif (c <= 1.15e-11)
		tmp = t_0;
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (1.0 / d) * (b + (a * (c / d)));
	t_1 = b * (d / c);
	tmp = 0.0;
	if (c <= -2.8e-32)
		tmp = (a / c) + (t_1 / c);
	elseif (c <= 4e-106)
		tmp = t_0;
	elseif (c <= 8.6e-31)
		tmp = (a / c) + (1.0 / (c / t_1));
	elseif (c <= 1.15e-11)
		tmp = t_0;
	else
		tmp = (a / c) + ((d / c) * (b / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.8e-32], N[(N[(a / c), $MachinePrecision] + N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4e-106], t$95$0, If[LessEqual[c, 8.6e-31], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e-11], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq 4 \cdot 10^{-106}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 8.6 \cdot 10^{-31}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{t_1}}\\

\mathbf{elif}\;c \leq 1.15 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.7999999999999999e-32

    1. Initial program 50.3%

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{{c}^{2}}} \]
    3. Step-by-step derivation
      1. unpow278.9%

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

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

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

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

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

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

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

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

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

    if -2.7999999999999999e-32 < c < 3.99999999999999976e-106 or 8.6e-31 < c < 1.15000000000000007e-11

    1. Initial program 75.9%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow279.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out88.0%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative88.0%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv88.0%

        \[\leadsto \frac{1}{d} \cdot \left(a \cdot \color{blue}{\frac{c}{d}} + b\right) \]
    6. Applied egg-rr88.0%

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

    if 3.99999999999999976e-106 < c < 8.6e-31

    1. Initial program 94.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.15000000000000007e-11 < c

    1. Initial program 47.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-106}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-31}:\\ \;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{b \cdot \frac{d}{c}}}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 9: 72.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{-47} \lor \neg \left(c \leq 1.5 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.5000000000000002e-47 or 1.5e-11 < c

    1. Initial program 49.6%

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

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

        \[\leadsto \color{blue}{\frac{a}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. unpow250.4%

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

        \[\leadsto \frac{a}{\frac{c \cdot c + \color{blue}{d \cdot d}}{c}} \]
      4. +-commutative50.4%

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d + c \cdot c}}{c}} \]
      5. fma-udef50.4%

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

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

      \[\leadsto \frac{a}{\color{blue}{c + \frac{{d}^{2}}{c}}} \]
    6. Step-by-step derivation
      1. unpow276.1%

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

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

    if -5.5000000000000002e-47 < c < 1.5e-11

    1. Initial program 78.2%

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

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

        \[\leadsto \frac{b}{d} + \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. unpow273.6%

        \[\leadsto \frac{b}{d} + \frac{c \cdot a}{\color{blue}{d \cdot d}} \]
      3. times-frac80.3%

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

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

        \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{a}{d} + \frac{b}{d}} \]
      2. frac-times73.6%

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

        \[\leadsto \color{blue}{\frac{\frac{c \cdot a}{d}}{d}} + \frac{b}{d} \]
      4. div-inv81.0%

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

        \[\leadsto \frac{c \cdot a}{d} \cdot \frac{1}{d} + \color{blue}{b \cdot \frac{1}{d}} \]
      6. distribute-rgt-out81.5%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{c \cdot a}{d} + b\right)} \]
      7. div-inv81.5%

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot a\right) \cdot \frac{1}{d}} + b\right) \]
      8. *-commutative81.5%

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{a \cdot \left(c \cdot \frac{1}{d}\right)} + b\right) \]
      10. div-inv81.6%

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

      \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(a \cdot \frac{c}{d} + b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{-47} \lor \neg \left(c \leq 1.5 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \end{array} \]

Alternative 10: 64.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.1 \cdot 10^{-94} \lor \neg \left(c \leq 8.5 \cdot 10^{-121}\right):\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.0999999999999998e-94 or 8.50000000000000025e-121 < c

    1. Initial program 58.5%

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

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

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

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

        \[\leadsto \frac{a}{\frac{c \cdot c + \color{blue}{d \cdot d}}{c}} \]
      4. +-commutative51.1%

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d + c \cdot c}}{c}} \]
      5. fma-udef51.1%

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

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

      \[\leadsto \frac{a}{\color{blue}{c + \frac{{d}^{2}}{c}}} \]
    6. Step-by-step derivation
      1. unpow270.7%

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

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

    if -3.0999999999999998e-94 < c < 8.50000000000000025e-121

    1. Initial program 74.5%

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

      \[\leadsto \color{blue}{\frac{b}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{-94} \lor \neg \left(c \leq 8.5 \cdot 10^{-121}\right):\\ \;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]

Alternative 11: 61.2% accurate, 2.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.79999999999999948e-7 or 9.4999999999999994e-121 < c

    1. Initial program 55.2%

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

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

    if -6.79999999999999948e-7 < c < 9.4999999999999994e-121

    1. Initial program 76.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.8 \cdot 10^{-7}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{-121}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 12: 42.2% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Final simplification46.7%

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

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

  :herbie-target
  (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))))