Complex division, imag part

Percentage Accurate: 61.6% → 97.2%
Time: 12.9s
Alternatives: 14
Speedup: 1.1×

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.6% 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: 97.2% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\sqrt{\frac{a \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \frac{a \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}}\right) \]
    3. sqr-neg61.5%

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{-a \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}\right) \]
    7. distribute-rgt-neg-out54.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}}\right) \]
  11. Final simplification96.7%

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

Alternative 2: 89.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -9 \cdot 10^{+118}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-194}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{+117}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0
         (fma
          (/ c (hypot c d))
          (/ b (hypot c d))
          (/ (* d (- a)) (pow (hypot c d) 2.0))))
        (t_1 (/ (- (* b (/ c d)) a) d)))
   (if (<= d -9e+118)
     t_1
     (if (<= d -1.45e-112)
       t_0
       (if (<= d 4.8e-194)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 4.8e+117) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), ((d * -a) / pow(hypot(c, d), 2.0)));
	double t_1 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -9e+118) {
		tmp = t_1;
	} else if (d <= -1.45e-112) {
		tmp = t_0;
	} else if (d <= 4.8e-194) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 4.8e+117) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d * Float64(-a)) / (hypot(c, d) ^ 2.0)))
	t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d)
	tmp = 0.0
	if (d <= -9e+118)
		tmp = t_1;
	elseif (d <= -1.45e-112)
		tmp = t_0;
	elseif (d <= 4.8e-194)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 4.8e+117)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d * (-a)), $MachinePrecision] / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9e+118], t$95$1, If[LessEqual[d, -1.45e-112], t$95$0, If[LessEqual[d, 4.8e-194], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.8e+117], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -9 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 4.8 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -9.00000000000000004e118 or 4.7999999999999998e117 < d

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.00000000000000004e118 < d < -1.44999999999999996e-112 or 4.8e-194 < d < 4.7999999999999998e117

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.44999999999999996e-112 < d < 4.8e-194

    1. Initial program 62.5%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 91.7%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in91.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{+118}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-194}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{+117}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.8% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\
t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.5000000000000001e113 or 5.2e119 < d

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.5000000000000001e113 < d < -1.44999999999999996e-112 or 3.5e-164 < d < 5.2e119

    1. Initial program 77.7%

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

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

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

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

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

        \[\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} \]
      4. fma-define77.7%

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

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

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

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

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

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

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

        \[\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) \]
      12. fma-define84.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 \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt84.7%

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

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

      \[\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 \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    7. Step-by-step derivation
      1. fma-undefine84.7%

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

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

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

    if -1.44999999999999996e-112 < d < 3.5e-164

    1. Initial program 62.1%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 91.2%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in91.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{+113}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-112}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{-164}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+119}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.7% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;c \leq -8.8 \cdot 10^{-162}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.9500000000000001e87

    1. Initial program 38.7%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 85.8%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in85.8%

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

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

    if -1.9500000000000001e87 < c < -8.7999999999999997e-162

    1. Initial program 72.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing

    if -8.7999999999999997e-162 < c < 9.9999999999999996e30

    1. Initial program 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999996e30 < c

    1. Initial program 50.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt82.6%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{-a \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}\right) \]
      7. distribute-rgt-neg-out75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.95 \cdot 10^{+87}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;c \leq -8.8 \cdot 10^{-162}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 10^{+31}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.9% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -2.15 \cdot 10^{-112}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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

\mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.95000000000000011e113 or 3.0000000000000001e67 < d

    1. Initial program 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.95000000000000011e113 < d < -2.1499999999999999e-112

    1. Initial program 90.3%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing

    if -2.1499999999999999e-112 < d < 1.10000000000000006e-120

    1. Initial program 61.8%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 90.3%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in90.3%

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

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

    if 1.10000000000000006e-120 < d < 3.0000000000000001e67

    1. Initial program 74.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
  3. Recombined 4 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.95 \cdot 10^{+113}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -2.15 \cdot 10^{-112}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-120}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 82.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -4.5 \cdot 10^{+115}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -1.75 \cdot 10^{-112}:\\ \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{+66}:\\ \;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ (- (* b (/ c d)) a) d)))
   (if (<= d -4.5e+115)
     t_1
     (if (<= d -1.75e-112)
       (/ t_0 (fma c c (* d d)))
       (if (<= d 9e-121)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 2.6e+66) (/ t_0 (+ (* c c) (* d d))) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -4.5e+115) {
		tmp = t_1;
	} else if (d <= -1.75e-112) {
		tmp = t_0 / fma(c, c, (d * d));
	} else if (d <= 9e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 2.6e+66) {
		tmp = t_0 / ((c * c) + (d * d));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d)
	tmp = 0.0
	if (d <= -4.5e+115)
		tmp = t_1;
	elseif (d <= -1.75e-112)
		tmp = Float64(t_0 / fma(c, c, Float64(d * d)));
	elseif (d <= 9e-121)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 2.6e+66)
		tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)));
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -4.5e+115], t$95$1, If[LessEqual[d, -1.75e-112], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.6e+66], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -4.49999999999999963e115 or 2.60000000000000012e66 < d

    1. Initial program 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.49999999999999963e115 < d < -1.74999999999999997e-112

    1. Initial program 90.3%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing

    if -1.74999999999999997e-112 < d < 9.0000000000000007e-121

    1. Initial program 61.8%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 90.3%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in90.3%

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

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

    if 9.0000000000000007e-121 < d < 2.60000000000000012e66

    1. Initial program 74.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
  3. Recombined 4 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.5 \cdot 10^{+115}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.75 \cdot 10^{-112}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{+66}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.9 \cdot 10^{+113}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-112}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ (- (* b (/ c d)) a) d)))
   (if (<= d -2.9e+113)
     t_1
     (if (<= d -6.8e-112)
       t_0
       (if (<= d 1.55e-121)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 3e+67) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -2.9e+113) {
		tmp = t_1;
	} else if (d <= -6.8e-112) {
		tmp = t_0;
	} else if (d <= 1.55e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 3e+67) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    t_1 = ((b * (c / d)) - a) / d
    if (d <= (-2.9d+113)) then
        tmp = t_1
    else if (d <= (-6.8d-112)) then
        tmp = t_0
    else if (d <= 1.55d-121) then
        tmp = (b - ((d * a) / c)) / c
    else if (d <= 3d+67) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -2.9e+113) {
		tmp = t_1;
	} else if (d <= -6.8e-112) {
		tmp = t_0;
	} else if (d <= 1.55e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 3e+67) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	t_1 = ((b * (c / d)) - a) / d
	tmp = 0
	if d <= -2.9e+113:
		tmp = t_1
	elif d <= -6.8e-112:
		tmp = t_0
	elif d <= 1.55e-121:
		tmp = (b - ((d * a) / c)) / c
	elif d <= 3e+67:
		tmp = t_0
	else:
		tmp = t_1
	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)))
	t_1 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d)
	tmp = 0.0
	if (d <= -2.9e+113)
		tmp = t_1;
	elseif (d <= -6.8e-112)
		tmp = t_0;
	elseif (d <= 1.55e-121)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 3e+67)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	t_1 = ((b * (c / d)) - a) / d;
	tmp = 0.0;
	if (d <= -2.9e+113)
		tmp = t_1;
	elseif (d <= -6.8e-112)
		tmp = t_0;
	elseif (d <= 1.55e-121)
		tmp = (b - ((d * a) / c)) / c;
	elseif (d <= 3e+67)
		tmp = t_0;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.9e+113], t$95$1, If[LessEqual[d, -6.8e-112], t$95$0, If[LessEqual[d, 1.55e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+67], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -6.8 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.89999999999999984e113 or 3.0000000000000001e67 < d

    1. Initial program 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.89999999999999984e113 < d < -6.7999999999999996e-112 or 1.5499999999999999e-121 < d < 3.0000000000000001e67

    1. Initial program 82.1%

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

    if -6.7999999999999996e-112 < d < 1.5499999999999999e-121

    1. Initial program 61.8%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 90.3%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in90.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.9 \cdot 10^{+113}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-112}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 77.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{+86} \lor \neg \left(c \leq 1.1 \cdot 10^{+31}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1e86 or 1.10000000000000005e31 < c

    1. Initial program 45.4%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 80.4%

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

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

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

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

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

    if -1e86 < c < 1.10000000000000005e31

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 73.4% accurate, 0.8× speedup?

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

    1. Initial program 48.9%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified68.0%

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

    if -1.55000000000000005e24 < d < 1.2e86

    1. Initial program 69.1%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 72.8%

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

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

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

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

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

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

Alternative 10: 76.2% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 40.0%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 86.1%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in86.1%

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

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

    if -2.05e86 < c < 9.9999999999999996e30

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999996e30 < c

    1. Initial program 50.4%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 75.1%

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

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

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

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

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

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

Alternative 11: 63.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.45 \cdot 10^{+33} \lor \neg \left(c \leq 1.45 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.45000000000000007e33 or 1.4500000000000001e43 < c

    1. Initial program 47.3%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 69.9%

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

    if -2.45000000000000007e33 < c < 1.4500000000000001e43

    1. Initial program 72.1%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified59.0%

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

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

Alternative 12: 63.5% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 44.6%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 73.8%

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    6. Step-by-step derivation
      1. clear-num74.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{c}{b}}} \]
      2. inv-pow74.4%

        \[\leadsto \color{blue}{{\left(\frac{c}{b}\right)}^{-1}} \]
    7. Applied egg-rr74.4%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{c}{b}}} \]
    9. Simplified74.4%

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

    if -4.70000000000000001e41 < c < 1.35e42

    1. Initial program 72.1%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified59.0%

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

    if 1.35e42 < c

    1. Initial program 50.5%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 65.4%

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

Alternative 13: 45.3% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+119}:\\
\;\;\;\;\frac{a}{d}\\

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


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

    1. Initial program 38.9%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified80.1%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt35.9%

        \[\leadsto \frac{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
      2. sqrt-unprod38.8%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
      3. sqr-neg38.8%

        \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
      4. sqrt-unprod18.9%

        \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
      5. add-sqr-sqrt29.2%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
      6. *-un-lft-identity29.2%

        \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
    9. Applied egg-rr29.2%

      \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
    10. Step-by-step derivation
      1. *-lft-identity29.2%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
    11. Simplified29.2%

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

    if -8.1999999999999994e119 < d

    1. Initial program 65.6%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 48.3%

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

Alternative 14: 10.5% accurate, 5.0× speedup?

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

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 61.8%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-a}{d}} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt19.1%

      \[\leadsto \frac{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
    2. sqrt-unprod19.0%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
    3. sqr-neg19.0%

      \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
    4. sqrt-unprod4.9%

      \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
    5. add-sqr-sqrt11.0%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
    6. *-un-lft-identity11.0%

      \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
  9. Applied egg-rr11.0%

    \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
  10. Step-by-step derivation
    1. *-lft-identity11.0%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
  11. Simplified11.0%

    \[\leadsto \frac{\color{blue}{a}}{d} \]
  12. Add Preprocessing

Developer Target 1: 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 2024139 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (! :herbie-platform default (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))))