Complex division, imag part

Percentage Accurate: 61.5% → 98.3%
Time: 10.7s
Alternatives: 14
Speedup: 1.8×

Specification

?
\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \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 14 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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}

Alternative 1: 98.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (-
  (* (/ 1.0 (hypot c d)) (/ b (/ (hypot c d) c)))
  (/ (* d (/ a (hypot c d))) (hypot c d))))
double code(double a, double b, double c, double d) {
	return ((1.0 / hypot(c, d)) * (b / (hypot(c, d) / c))) - ((d * (a / hypot(c, d))) / hypot(c, d));
}
public static double code(double a, double b, double c, double d) {
	return ((1.0 / Math.hypot(c, d)) * (b / (Math.hypot(c, d) / c))) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
}
def code(a, b, c, d):
	return ((1.0 / math.hypot(c, d)) * (b / (math.hypot(c, d) / c))) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
function code(a, b, c, d)
	return Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(b / Float64(hypot(c, d) / c))) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d)))
end
function tmp = code(a, b, c, d)
	tmp = ((1.0 / hypot(c, d)) * (b / (hypot(c, d) / c))) - ((d * (a / hypot(c, d))) / hypot(c, d));
end
code[a_, b_, c_, d_] := N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Derivation
  1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
    2. associate-/l*79.9%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
    4. *-commutative75.9%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
  5. Simplified75.9%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
  6. Step-by-step derivation
    1. *-un-lft-identity75.9%

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

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

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
  8. Step-by-step derivation
    1. associate-*l/84.2%

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

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

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

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

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

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

Alternative 2: 97.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \frac{c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (-
  (/ (* c (/ b (hypot c d))) (hypot c d))
  (/ (* d (/ a (hypot c d))) (hypot c d))))
double code(double a, double b, double c, double d) {
	return ((c * (b / hypot(c, d))) / hypot(c, d)) - ((d * (a / hypot(c, d))) / hypot(c, d));
}
public static double code(double a, double b, double c, double d) {
	return ((c * (b / Math.hypot(c, d))) / Math.hypot(c, d)) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
}
def code(a, b, c, d):
	return ((c * (b / math.hypot(c, d))) / math.hypot(c, d)) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
function code(a, b, c, d)
	return Float64(Float64(Float64(c * Float64(b / hypot(c, d))) / hypot(c, d)) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d)))
end
function tmp = code(a, b, c, d)
	tmp = ((c * (b / hypot(c, d))) / hypot(c, d)) - ((d * (a / hypot(c, d))) / hypot(c, d));
end
code[a_, b_, c_, d_] := N[(N[(N[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Derivation
  1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
    2. associate-/l*79.9%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
    4. *-commutative75.9%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
  5. Simplified75.9%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
  6. Step-by-step derivation
    1. *-un-lft-identity75.9%

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

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

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
  8. Step-by-step derivation
    1. associate-*l/84.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)}} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
    2. *-un-lft-identity98.4%

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

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

    \[\leadsto \color{blue}{\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot c}{\mathsf{hypot}\left(c, d\right)}} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
  14. Final simplification98.0%

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

Alternative 3: 89.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+264}\right):\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+264)))
     (- (/ b c) (/ (* d (/ a (hypot c d))) (hypot c d)))
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+264)) {
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	} else {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+264)) {
		tmp = (b / c) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	t_1 = t_0 / ((c * c) + (d * d))
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 2e+264):
		tmp = (b / c) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
	else:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+264))
		tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d)));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	t_1 = t_0 / ((c * c) + (d * d));
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 2e+264)))
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	else
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+264]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+264}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 2.00000000000000009e264 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 14.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
      2. associate-/l*64.7%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
      4. *-commutative63.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    5. Simplified63.6%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity63.6%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/81.3%

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

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

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

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

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

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

    if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000009e264

    1. Initial program 81.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.6%

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

Alternative 4: 82.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;d \leq -1.95 \cdot 10^{+90}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-60}:\\ \;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 10^{-70}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+61}:\\ \;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= d -1.95e+90)
     (* (/ 1.0 (hypot c d)) (- a (/ c (/ d b))))
     (if (<= d -1.35e-60)
       (/ t_0 (+ (* c c) (* d d)))
       (if (<= d 1e-70)
         (/ (- b (* a (/ d c))) c)
         (if (<= d 3e+61)
           (* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
           (/ (- (* b (/ c d)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if (d <= -1.95e+90) {
		tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
	} else if (d <= -1.35e-60) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (d <= 1e-70) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3e+61) {
		tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
	} else {
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if (d <= -1.95e+90) {
		tmp = (1.0 / Math.hypot(c, d)) * (a - (c / (d / b)));
	} else if (d <= -1.35e-60) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (d <= 1e-70) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3e+61) {
		tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
	} else {
		tmp = ((b * (c / d)) - a) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	tmp = 0
	if d <= -1.95e+90:
		tmp = (1.0 / math.hypot(c, d)) * (a - (c / (d / b)))
	elif d <= -1.35e-60:
		tmp = t_0 / ((c * c) + (d * d))
	elif d <= 1e-70:
		tmp = (b - (a * (d / c))) / c
	elif d <= 3e+61:
		tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0))
	else:
		tmp = ((b * (c / d)) - a) / math.hypot(c, d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (d <= -1.95e+90)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(c / Float64(d / b))));
	elseif (d <= -1.35e-60)
		tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 1e-70)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= 3e+61)
		tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0)));
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	tmp = 0.0;
	if (d <= -1.95e+90)
		tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
	elseif (d <= -1.35e-60)
		tmp = t_0 / ((c * c) + (d * d));
	elseif (d <= 1e-70)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= 3e+61)
		tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0));
	else
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.95e+90], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.35e-60], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-70], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+61], N[(t$95$0 * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;d \leq 3 \cdot 10^{+61}:\\
\;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9500000000000001e90 < d < -1.35e-60

    1. Initial program 83.4%

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

    if -1.35e-60 < d < 9.99999999999999996e-71

    1. Initial program 60.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.8%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac82.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub84.8%

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

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

    if 9.99999999999999996e-71 < d < 3e61

    1. Initial program 81.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}} \cdot \left(b \cdot c - a \cdot d\right) \]
      5. hypot-def81.7%

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

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

    if 3e61 < d

    1. Initial program 34.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-172.4%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Step-by-step derivation
      1. associate-*l/81.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b - a}{\mathsf{hypot}\left(c, d\right)}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification84.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.95 \cdot 10^{+90}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-60}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 10^{-70}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+61}:\\ \;\;\;\;\left(c \cdot b - d \cdot a\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 5: 80.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+45} \lor \neg \left(c \leq 1.7 \cdot 10^{+24}\right):\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= c -5.5e+45) (not (<= c 1.7e+24)))
   (- (/ b c) (/ (* d (/ a (hypot c d))) (hypot c d)))
   (* (/ 1.0 d) (- (/ c (/ d b)) a))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -5.5e+45) || !(c <= 1.7e+24)) {
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	} else {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -5.5e+45) || !(c <= 1.7e+24)) {
		tmp = (b / c) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
	} else {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (c <= -5.5e+45) or not (c <= 1.7e+24):
		tmp = (b / c) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
	else:
		tmp = (1.0 / d) * ((c / (d / b)) - a)
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((c <= -5.5e+45) || !(c <= 1.7e+24))
		tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d)));
	else
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((c <= -5.5e+45) || ~((c <= 1.7e+24)))
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	else
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e+45], N[Not[LessEqual[c, 1.7e+24]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45} \lor \neg \left(c \leq 1.7 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.5000000000000001e45 or 1.7e24 < c

    1. Initial program 41.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
      2. associate-/l*86.6%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
      4. *-commutative87.4%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    5. Simplified87.4%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity87.4%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/93.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\frac{1 \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
      2. *-lft-identity93.7%

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

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

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

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

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

    if -5.5000000000000001e45 < c < 1.7e24

    1. Initial program 71.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-141.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+45} \lor \neg \left(c \leq 1.7 \cdot 10^{+24}\right):\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \end{array} \]

Alternative 6: 77.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{+24}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -5.5e+45)
   (/ (- b (* a (/ d c))) c)
   (if (<= c 8.6e+24)
     (* (/ 1.0 d) (- (/ c (/ d b)) a))
     (- (/ b c) (* d (/ (/ a (hypot c d)) (hypot c d)))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -5.5e+45) {
		tmp = (b - (a * (d / c))) / c;
	} else if (c <= 8.6e+24) {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	} else {
		tmp = (b / c) - (d * ((a / hypot(c, d)) / hypot(c, d)));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -5.5e+45) {
		tmp = (b - (a * (d / c))) / c;
	} else if (c <= 8.6e+24) {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	} else {
		tmp = (b / c) - (d * ((a / Math.hypot(c, d)) / Math.hypot(c, d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -5.5e+45:
		tmp = (b - (a * (d / c))) / c
	elif c <= 8.6e+24:
		tmp = (1.0 / d) * ((c / (d / b)) - a)
	else:
		tmp = (b / c) - (d * ((a / math.hypot(c, d)) / math.hypot(c, d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -5.5e+45)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (c <= 8.6e+24)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a));
	else
		tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / hypot(c, d)) / hypot(c, d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -5.5e+45)
		tmp = (b - (a * (d / c))) / c;
	elseif (c <= 8.6e+24)
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	else
		tmp = (b / c) - (d * ((a / hypot(c, d)) / hypot(c, d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 8.6e+24], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.5000000000000001e45

    1. Initial program 35.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow268.5%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub76.6%

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

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

    if -5.5000000000000001e45 < c < 8.59999999999999975e24

    1. Initial program 71.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-141.2%

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

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

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

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

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

    if 8.59999999999999975e24 < c

    1. Initial program 48.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
      2. associate-/l*87.4%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
      4. *-commutative88.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    5. Simplified88.9%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity88.9%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{1 \cdot a}{\color{blue}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}} \]
      3. times-frac96.4%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/96.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \color{blue}{\frac{1 \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
      2. *-lft-identity96.6%

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

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

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

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

Alternative 7: 82.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -9.2 \cdot 10^{+90}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{-60}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3.15 \cdot 10^{-71}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+60}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -9.2e+90)
     (* (/ 1.0 d) (- (/ c (/ d b)) a))
     (if (<= d -1.4e-60)
       t_0
       (if (<= d 3.15e-71)
         (/ (- b (* a (/ d c))) c)
         (if (<= d 3.5e+60) t_0 (/ (- (* b (/ c d)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -9.2e+90) {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	} else if (d <= -1.4e-60) {
		tmp = t_0;
	} else if (d <= 3.15e-71) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.5e+60) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -9.2e+90) {
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	} else if (d <= -1.4e-60) {
		tmp = t_0;
	} else if (d <= 3.15e-71) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.5e+60) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -9.2e+90:
		tmp = (1.0 / d) * ((c / (d / b)) - a)
	elif d <= -1.4e-60:
		tmp = t_0
	elif d <= 3.15e-71:
		tmp = (b - (a * (d / c))) / c
	elif d <= 3.5e+60:
		tmp = t_0
	else:
		tmp = ((b * (c / d)) - a) / math.hypot(c, d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -9.2e+90)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a));
	elseif (d <= -1.4e-60)
		tmp = t_0;
	elseif (d <= 3.15e-71)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= 3.5e+60)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -9.2e+90)
		tmp = (1.0 / d) * ((c / (d / b)) - a);
	elseif (d <= -1.4e-60)
		tmp = t_0;
	elseif (d <= 3.15e-71)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= 3.5e+60)
		tmp = t_0;
	else
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.2e+90], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.4e-60], t$95$0, If[LessEqual[d, 3.15e-71], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.5e+60], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.4 \cdot 10^{-60}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 3.5 \cdot 10^{+60}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-119.3%

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

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

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

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

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

    if -9.20000000000000001e90 < d < -1.4000000000000001e-60 or 3.1500000000000002e-71 < d < 3.5000000000000002e60

    1. Initial program 82.6%

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

    if -1.4000000000000001e-60 < d < 3.1500000000000002e-71

    1. Initial program 60.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.8%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac82.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub84.8%

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

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

    if 3.5000000000000002e60 < d

    1. Initial program 34.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-172.4%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Step-by-step derivation
      1. associate-*l/81.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b - a}{\mathsf{hypot}\left(c, d\right)}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification84.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.2 \cdot 10^{+90}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{-60}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.15 \cdot 10^{-71}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+60}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 8: 82.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -4.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-71}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{+59}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -4.7e+85)
     (* (/ 1.0 (hypot c d)) (- a (/ c (/ d b))))
     (if (<= d -1.3e-58)
       t_0
       (if (<= d 2e-71)
         (/ (- b (* a (/ d c))) c)
         (if (<= d 3.6e+59) t_0 (/ (- (* b (/ c d)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -4.7e+85) {
		tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
	} else if (d <= -1.3e-58) {
		tmp = t_0;
	} else if (d <= 2e-71) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.6e+59) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -4.7e+85) {
		tmp = (1.0 / Math.hypot(c, d)) * (a - (c / (d / b)));
	} else if (d <= -1.3e-58) {
		tmp = t_0;
	} else if (d <= 2e-71) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.6e+59) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -4.7e+85:
		tmp = (1.0 / math.hypot(c, d)) * (a - (c / (d / b)))
	elif d <= -1.3e-58:
		tmp = t_0
	elif d <= 2e-71:
		tmp = (b - (a * (d / c))) / c
	elif d <= 3.6e+59:
		tmp = t_0
	else:
		tmp = ((b * (c / d)) - a) / math.hypot(c, d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -4.7e+85)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(c / Float64(d / b))));
	elseif (d <= -1.3e-58)
		tmp = t_0;
	elseif (d <= 2e-71)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= 3.6e+59)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -4.7e+85)
		tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
	elseif (d <= -1.3e-58)
		tmp = t_0;
	elseif (d <= 2e-71)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= 3.6e+59)
		tmp = t_0;
	else
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.7e+85], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.3e-58], t$95$0, If[LessEqual[d, 2e-71], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.6e+59], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-58}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 3.6 \cdot 10^{+59}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.7000000000000002e85 < d < -1.30000000000000003e-58 or 1.9999999999999998e-71 < d < 3.5999999999999999e59

    1. Initial program 82.6%

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

    if -1.30000000000000003e-58 < d < 1.9999999999999998e-71

    1. Initial program 60.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.8%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac82.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub84.8%

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

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

    if 3.5999999999999999e59 < d

    1. Initial program 34.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-172.4%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Step-by-step derivation
      1. associate-*l/81.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b - a}{\mathsf{hypot}\left(c, d\right)}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification84.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-58}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{-71}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{+59}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 9: 82.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -4.2 \cdot 10^{-57}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 9.2 \cdot 10^{+53}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-119.3%

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

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

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

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

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

    if -9.1999999999999996e89 < d < -4.1999999999999999e-57 or 1.32000000000000002e-61 < d < 9.20000000000000079e53

    1. Initial program 82.3%

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

    if -4.1999999999999999e-57 < d < 1.32000000000000002e-61

    1. Initial program 60.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.8%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac82.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub84.8%

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

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

    if 9.20000000000000079e53 < d

    1. Initial program 35.5%

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

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

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

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

        \[\leadsto \color{blue}{\frac{c \cdot b}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow268.7%

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. times-frac81.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.2 \cdot 10^{+89}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{elif}\;d \leq -4.2 \cdot 10^{-57}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{-61}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{+53}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 10: 77.2% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -6.00000000000000021e45

    1. Initial program 35.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow268.5%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub76.6%

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

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

    if -6.00000000000000021e45 < c < 5.8000000000000002e27

    1. Initial program 71.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-141.2%

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

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

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

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

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

    if 5.8000000000000002e27 < c

    1. Initial program 48.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.0%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac81.8%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
      2. sub-div83.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6 \cdot 10^{+45}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+27}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]

Alternative 11: 72.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+52} \lor \neg \left(d \leq 2.8 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5e52 or 2.8000000000000001e55 < d

    1. Initial program 42.5%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/72.4%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-172.4%

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified72.4%

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

    if -2.5e52 < d < 2.8000000000000001e55

    1. Initial program 66.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow269.6%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac72.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub74.6%

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

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

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

Alternative 12: 69.2% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.5000000000000001e45

    1. Initial program 35.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow268.5%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
      11. div-sub76.6%

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

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

    if -5.5000000000000001e45 < c < 1.7500000000000001e24

    1. Initial program 71.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/68.3%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-168.3%

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified68.3%

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

    if 1.7500000000000001e24 < c

    1. Initial program 48.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.0%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac81.8%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
      2. sub-div83.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+24}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]

Alternative 13: 63.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{b}{c}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.5000000000000001e45 or 7.2000000000000004e30 < c

    1. Initial program 41.3%

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

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

    if -5.5000000000000001e45 < c < 7.2000000000000004e30

    1. Initial program 71.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/67.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-167.8%

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+30}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 14: 42.0% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{b}{c} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
	return b / 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 = b / c
end function
public static double code(double a, double b, double c, double d) {
	return b / c;
}
def code(a, b, c, d):
	return b / c
function code(a, b, c, d)
	return Float64(b / c)
end
function tmp = code(a, b, c, d)
	tmp = b / c;
end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 56.8%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification41.5%

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

Developer target: 99.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \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))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (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(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * 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 = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (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[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * 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{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023192 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))