Complex division, imag part

Percentage Accurate: 61.4% → 80.6%
Time: 7.9s
Alternatives: 9
Speedup: 1.5×

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 9 alternatives:

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

Initial Program: 61.4% 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: 80.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -0.0001107:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.10699999999999994e-4 or 4.3000000000000001e91 < d

    1. Initial program 54.7%

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

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
      2. flip3--N/A

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

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

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

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

        \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
      7. lift--.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
      8. frac-2negN/A

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
      9. metadata-evalN/A

        \[\leadsto \frac{\frac{1}{\frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}{c \cdot c + d \cdot d} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{-1}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
      11. lift--.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c - a \cdot d\right)}\right)}}}{c \cdot c + d \cdot d} \]
      12. sub-negN/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c + \left(\mathsf{neg}\left(a \cdot d\right)\right)\right)}\right)}}}{c \cdot c + d \cdot d} \]
      13. distribute-neg-inN/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\color{blue}{\left(\mathsf{neg}\left(b \cdot c\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}}{c \cdot c + d \cdot d} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\left(\mathsf{neg}\left(\color{blue}{b \cdot c}\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}{c \cdot c + d \cdot d} \]
      15. distribute-lft-neg-inN/A

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

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

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

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6417.8

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. mul-1-negN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} + \color{blue}{-1 \cdot a}}{d} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      11. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + -1 \cdot a}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6487.0

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

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

    if -1.10699999999999994e-4 < d < 2.3e-57

    1. Initial program 73.5%

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

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

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. lower-*.f6493.0

        \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
    5. Applied rewrites93.0%

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

    if 2.3e-57 < d < 4.3000000000000001e91

    1. Initial program 83.0%

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

        \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}} \]
      2. div-invN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(b \cdot c - a \cdot d\right) \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)}} \]
      7. lift--.f64N/A

        \[\leadsto \color{blue}{\left(b \cdot c - a \cdot d\right)} \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \]
      8. sub-negN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{d \cdot a}\right)\right) + b \cdot c\right) \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot a} + b \cdot c\right) \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), a, b \cdot c\right)} \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \]
      14. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, a, b \cdot c\right) \cdot \frac{c \cdot c - d \cdot d}{\left(c \cdot c\right) \cdot \left(c \cdot c\right) - \left(d \cdot d\right) \cdot \left(d \cdot d\right)} \]
      15. clear-numN/A

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(d\right), a, b \cdot c\right) \cdot \frac{1}{\color{blue}{c \cdot c + d \cdot d}} \]
      17. lift-+.f64N/A

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-57}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 4.3 \cdot 10^{+91}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot \mathsf{fma}\left(-d, a, c \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 76.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.0001107:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.10699999999999994e-4

    1. Initial program 59.8%

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

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
      2. flip3--N/A

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

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

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

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

        \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
      7. lift--.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
      8. frac-2negN/A

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
      9. metadata-evalN/A

        \[\leadsto \frac{\frac{1}{\frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}{c \cdot c + d \cdot d} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{-1}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
      11. lift--.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c - a \cdot d\right)}\right)}}}{c \cdot c + d \cdot d} \]
      12. sub-negN/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c + \left(\mathsf{neg}\left(a \cdot d\right)\right)\right)}\right)}}}{c \cdot c + d \cdot d} \]
      13. distribute-neg-inN/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\color{blue}{\left(\mathsf{neg}\left(b \cdot c\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}}{c \cdot c + d \cdot d} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{\frac{-1}{\left(\mathsf{neg}\left(\color{blue}{b \cdot c}\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}{c \cdot c + d \cdot d} \]
      15. distribute-lft-neg-inN/A

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

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

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

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6424.0

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. mul-1-negN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} + \color{blue}{-1 \cdot a}}{d} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      11. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + -1 \cdot a}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6483.4

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

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

    if -1.10699999999999994e-4 < d < 2.6000000000000001e-50

    1. Initial program 73.8%

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

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

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. lower-*.f6492.7

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

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

    if 2.6000000000000001e-50 < d

    1. Initial program 58.3%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto \mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{{c}^{2} + {d}^{2}}\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{{c}^{2} + {d}^{2}}}\right) \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
      5. mul-1-negN/A

        \[\leadsto \color{blue}{\left(-1 \cdot d\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot d\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
      7. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
      8. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
      9. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \color{blue}{\frac{a}{{c}^{2} + {d}^{2}}} \]
      10. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{c \cdot c} + {d}^{2}} \]
      11. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
      12. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
      13. lower-*.f6459.7

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

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

      \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{{c}^{\color{blue}{2}}} \]
    7. Step-by-step derivation
      1. Applied rewrites13.7%

        \[\leadsto \left(-d\right) \cdot \frac{a}{c \cdot \color{blue}{c}} \]
      2. Step-by-step derivation
        1. Applied rewrites12.0%

          \[\leadsto \frac{-1}{\color{blue}{\frac{c \cdot c}{a \cdot d}}} \]
        2. Taylor expanded in c around 0

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-50}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{\mathsf{fma}\left(c, \frac{c}{a \cdot d}, \frac{d}{a}\right)}\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 80.7% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-61}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 4.3 \cdot 10^{+91}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (fma c (/ b d) (- a)) d)))
           (if (<= d -0.0001107)
             t_0
             (if (<= d 1.25e-61)
               (/ (- b (/ (* a d) c)) c)
               (if (<= d 4.3e+91) (/ (- (* c b) (* a d)) (+ (* d d) (* c c))) t_0)))))
        double code(double a, double b, double c, double d) {
        	double t_0 = fma(c, (b / d), -a) / d;
        	double tmp;
        	if (d <= -0.0001107) {
        		tmp = t_0;
        	} else if (d <= 1.25e-61) {
        		tmp = (b - ((a * d) / c)) / c;
        	} else if (d <= 4.3e+91) {
        		tmp = ((c * b) - (a * d)) / ((d * d) + (c * c));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
        	tmp = 0.0
        	if (d <= -0.0001107)
        		tmp = t_0;
        	elseif (d <= 1.25e-61)
        		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
        	elseif (d <= 4.3e+91)
        		tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(d * d) + Float64(c * c)));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -0.0001107], t$95$0, If[LessEqual[d, 1.25e-61], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.3e+91], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
        \mathbf{if}\;d \leq -0.0001107:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 1.25 \cdot 10^{-61}:\\
        \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
        
        \mathbf{elif}\;d \leq 4.3 \cdot 10^{+91}:\\
        \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d < -1.10699999999999994e-4 or 4.3000000000000001e91 < d

          1. Initial program 54.7%

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

              \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
            2. flip3--N/A

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

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

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

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

              \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
            7. lift--.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
            8. frac-2negN/A

              \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
            9. metadata-evalN/A

              \[\leadsto \frac{\frac{1}{\frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}{c \cdot c + d \cdot d} \]
            10. lower-/.f64N/A

              \[\leadsto \frac{\frac{1}{\color{blue}{\frac{-1}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
            11. lift--.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c - a \cdot d\right)}\right)}}}{c \cdot c + d \cdot d} \]
            12. sub-negN/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c + \left(\mathsf{neg}\left(a \cdot d\right)\right)\right)}\right)}}}{c \cdot c + d \cdot d} \]
            13. distribute-neg-inN/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\color{blue}{\left(\mathsf{neg}\left(b \cdot c\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}}{c \cdot c + d \cdot d} \]
            14. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\left(\mathsf{neg}\left(\color{blue}{b \cdot c}\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}{c \cdot c + d \cdot d} \]
            15. distribute-lft-neg-inN/A

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

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. *-commutativeN/A

              \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
            7. lower-*.f6417.8

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

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

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

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
            3. unsub-negN/A

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
            4. unpow2N/A

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

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
            6. div-subN/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            7. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            8. sub-negN/A

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
            9. mul-1-negN/A

              \[\leadsto \frac{\frac{b \cdot c}{d} + \color{blue}{-1 \cdot a}}{d} \]
            10. *-commutativeN/A

              \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
            11. associate-/l*N/A

              \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + -1 \cdot a}{d} \]
            12. lower-fma.f64N/A

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
            13. lower-/.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
            14. mul-1-negN/A

              \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
            15. lower-neg.f6487.0

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

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

          if -1.10699999999999994e-4 < d < 1.25e-61

          1. Initial program 73.3%

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6492.9

              \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
          5. Applied rewrites92.9%

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

          if 1.25e-61 < d < 4.3000000000000001e91

          1. Initial program 83.7%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-61}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 4.3 \cdot 10^{+91}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 4: 72.9% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-50}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (- a) d)))
           (if (<= d -0.0001107)
             t_0
             (if (<= d 3.9e-50)
               (/ (- b (/ (* a d) c)) c)
               (if (<= d 8.5e+135) (* (/ a (fma c c (* d d))) (- d)) t_0)))))
        double code(double a, double b, double c, double d) {
        	double t_0 = -a / d;
        	double tmp;
        	if (d <= -0.0001107) {
        		tmp = t_0;
        	} else if (d <= 3.9e-50) {
        		tmp = (b - ((a * d) / c)) / c;
        	} else if (d <= 8.5e+135) {
        		tmp = (a / fma(c, c, (d * d))) * -d;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(-a) / d)
        	tmp = 0.0
        	if (d <= -0.0001107)
        		tmp = t_0;
        	elseif (d <= 3.9e-50)
        		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
        	elseif (d <= 8.5e+135)
        		tmp = Float64(Float64(a / fma(c, c, Float64(d * d))) * Float64(-d));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -0.0001107], t$95$0, If[LessEqual[d, 3.9e-50], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8.5e+135], N[(N[(a / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-d)), $MachinePrecision], t$95$0]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{-a}{d}\\
        \mathbf{if}\;d \leq -0.0001107:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 3.9 \cdot 10^{-50}:\\
        \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
        
        \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\
        \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d < -1.10699999999999994e-4 or 8.49999999999999992e135 < d

          1. Initial program 54.0%

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

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

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            2. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            3. mul-1-negN/A

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6480.1

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites80.1%

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

          if -1.10699999999999994e-4 < d < 3.90000000000000021e-50

          1. Initial program 73.8%

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6492.7

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

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

          if 3.90000000000000021e-50 < d < 8.49999999999999992e135

          1. Initial program 77.2%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

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

              \[\leadsto \mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{{c}^{2} + {d}^{2}}\right) \]
            3. associate-/l*N/A

              \[\leadsto \mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{{c}^{2} + {d}^{2}}}\right) \]
            4. distribute-lft-neg-inN/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
            5. mul-1-negN/A

              \[\leadsto \color{blue}{\left(-1 \cdot d\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            6. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(-1 \cdot d\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
            7. mul-1-negN/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            8. lower-neg.f64N/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            9. lower-/.f64N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \color{blue}{\frac{a}{{c}^{2} + {d}^{2}}} \]
            10. unpow2N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{c \cdot c} + {d}^{2}} \]
            11. lower-fma.f64N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
            12. unpow2N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
            13. lower-*.f6476.0

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-50}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 5: 64.9% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.95 \cdot 10^{+18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-51}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (- a) d)))
           (if (<= d -1.95e+18)
             t_0
             (if (<= d 3.6e-51)
               (/ b c)
               (if (<= d 8.5e+135) (* (/ a (fma c c (* d d))) (- d)) t_0)))))
        double code(double a, double b, double c, double d) {
        	double t_0 = -a / d;
        	double tmp;
        	if (d <= -1.95e+18) {
        		tmp = t_0;
        	} else if (d <= 3.6e-51) {
        		tmp = b / c;
        	} else if (d <= 8.5e+135) {
        		tmp = (a / fma(c, c, (d * d))) * -d;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(-a) / d)
        	tmp = 0.0
        	if (d <= -1.95e+18)
        		tmp = t_0;
        	elseif (d <= 3.6e-51)
        		tmp = Float64(b / c);
        	elseif (d <= 8.5e+135)
        		tmp = Float64(Float64(a / fma(c, c, Float64(d * d))) * Float64(-d));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.95e+18], t$95$0, If[LessEqual[d, 3.6e-51], N[(b / c), $MachinePrecision], If[LessEqual[d, 8.5e+135], N[(N[(a / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-d)), $MachinePrecision], t$95$0]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{-a}{d}\\
        \mathbf{if}\;d \leq -1.95 \cdot 10^{+18}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 3.6 \cdot 10^{-51}:\\
        \;\;\;\;\frac{b}{c}\\
        
        \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\
        \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d < -1.95e18 or 8.49999999999999992e135 < d

          1. Initial program 50.9%

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

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

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            2. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            3. mul-1-negN/A

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6482.4

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites82.4%

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

          if -1.95e18 < d < 3.6e-51

          1. Initial program 75.2%

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

            \[\leadsto \color{blue}{\frac{b}{c}} \]
          4. Step-by-step derivation
            1. lower-/.f6473.7

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites73.7%

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

          if 3.6e-51 < d < 8.49999999999999992e135

          1. Initial program 77.2%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

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

              \[\leadsto \mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{{c}^{2} + {d}^{2}}\right) \]
            3. associate-/l*N/A

              \[\leadsto \mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{{c}^{2} + {d}^{2}}}\right) \]
            4. distribute-lft-neg-inN/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
            5. mul-1-negN/A

              \[\leadsto \color{blue}{\left(-1 \cdot d\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            6. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(-1 \cdot d\right) \cdot \frac{a}{{c}^{2} + {d}^{2}}} \]
            7. mul-1-negN/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            8. lower-neg.f64N/A

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right)} \cdot \frac{a}{{c}^{2} + {d}^{2}} \]
            9. lower-/.f64N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \color{blue}{\frac{a}{{c}^{2} + {d}^{2}}} \]
            10. unpow2N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{c \cdot c} + {d}^{2}} \]
            11. lower-fma.f64N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
            12. unpow2N/A

              \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
            13. lower-*.f6476.0

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.95 \cdot 10^{+18}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-51}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+135}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-d\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 6: 78.1% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-45}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (fma c (/ b d) (- a)) d)))
           (if (<= d -0.0001107)
             t_0
             (if (<= d 1.7e-45) (/ (- b (/ (* a d) c)) c) t_0))))
        double code(double a, double b, double c, double d) {
        	double t_0 = fma(c, (b / d), -a) / d;
        	double tmp;
        	if (d <= -0.0001107) {
        		tmp = t_0;
        	} else if (d <= 1.7e-45) {
        		tmp = (b - ((a * d) / c)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
        	tmp = 0.0
        	if (d <= -0.0001107)
        		tmp = t_0;
        	elseif (d <= 1.7e-45)
        		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -0.0001107], t$95$0, If[LessEqual[d, 1.7e-45], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
        \mathbf{if}\;d \leq -0.0001107:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 1.7 \cdot 10^{-45}:\\
        \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if d < -1.10699999999999994e-4 or 1.70000000000000002e-45 < d

          1. Initial program 59.0%

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

              \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
            2. flip3--N/A

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

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

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

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

              \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
            7. lift--.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{1}{\color{blue}{b \cdot c - a \cdot d}}}}{c \cdot c + d \cdot d} \]
            8. frac-2negN/A

              \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
            9. metadata-evalN/A

              \[\leadsto \frac{\frac{1}{\frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}{c \cdot c + d \cdot d} \]
            10. lower-/.f64N/A

              \[\leadsto \frac{\frac{1}{\color{blue}{\frac{-1}{\mathsf{neg}\left(\left(b \cdot c - a \cdot d\right)\right)}}}}{c \cdot c + d \cdot d} \]
            11. lift--.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c - a \cdot d\right)}\right)}}}{c \cdot c + d \cdot d} \]
            12. sub-negN/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\mathsf{neg}\left(\color{blue}{\left(b \cdot c + \left(\mathsf{neg}\left(a \cdot d\right)\right)\right)}\right)}}}{c \cdot c + d \cdot d} \]
            13. distribute-neg-inN/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\color{blue}{\left(\mathsf{neg}\left(b \cdot c\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}}{c \cdot c + d \cdot d} \]
            14. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\left(\mathsf{neg}\left(\color{blue}{b \cdot c}\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}{c \cdot c + d \cdot d} \]
            15. distribute-lft-neg-inN/A

              \[\leadsto \frac{\frac{1}{\frac{-1}{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot c} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right)}}}{c \cdot c + d \cdot d} \]
          4. Applied rewrites59.0%

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. *-commutativeN/A

              \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
            7. lower-*.f6421.3

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

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

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

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
            3. unsub-negN/A

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
            4. unpow2N/A

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

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
            6. div-subN/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            7. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            8. sub-negN/A

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
            9. mul-1-negN/A

              \[\leadsto \frac{\frac{b \cdot c}{d} + \color{blue}{-1 \cdot a}}{d} \]
            10. *-commutativeN/A

              \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
            11. associate-/l*N/A

              \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + -1 \cdot a}{d} \]
            12. lower-fma.f64N/A

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
            13. lower-/.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
            14. mul-1-negN/A

              \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
            15. lower-neg.f6483.6

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

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

          if -1.10699999999999994e-4 < d < 1.70000000000000002e-45

          1. Initial program 73.8%

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6492.7

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

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

        Alternative 7: 76.0% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;d \leq -0.0001107:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-45}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (- (/ (* c b) d) a) d)))
           (if (<= d -0.0001107)
             t_0
             (if (<= d 1.7e-45) (/ (- b (/ (* a d) c)) c) t_0))))
        double code(double a, double b, double c, double d) {
        	double t_0 = (((c * b) / d) - a) / d;
        	double tmp;
        	if (d <= -0.0001107) {
        		tmp = t_0;
        	} else if (d <= 1.7e-45) {
        		tmp = (b - ((a * d) / c)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        real(8) function code(a, b, c, d)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            real(8), intent (in) :: d
            real(8) :: t_0
            real(8) :: tmp
            t_0 = (((c * b) / d) - a) / d
            if (d <= (-0.0001107d0)) then
                tmp = t_0
            else if (d <= 1.7d-45) then
                tmp = (b - ((a * d) / c)) / c
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double a, double b, double c, double d) {
        	double t_0 = (((c * b) / d) - a) / d;
        	double tmp;
        	if (d <= -0.0001107) {
        		tmp = t_0;
        	} else if (d <= 1.7e-45) {
        		tmp = (b - ((a * d) / c)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(a, b, c, d):
        	t_0 = (((c * b) / d) - a) / d
        	tmp = 0
        	if d <= -0.0001107:
        		tmp = t_0
        	elif d <= 1.7e-45:
        		tmp = (b - ((a * d) / c)) / c
        	else:
        		tmp = t_0
        	return tmp
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d)
        	tmp = 0.0
        	if (d <= -0.0001107)
        		tmp = t_0;
        	elseif (d <= 1.7e-45)
        		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, b, c, d)
        	t_0 = (((c * b) / d) - a) / d;
        	tmp = 0.0;
        	if (d <= -0.0001107)
        		tmp = t_0;
        	elseif (d <= 1.7e-45)
        		tmp = (b - ((a * d) / c)) / c;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -0.0001107], t$95$0, If[LessEqual[d, 1.7e-45], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\
        \mathbf{if}\;d \leq -0.0001107:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 1.7 \cdot 10^{-45}:\\
        \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if d < -1.10699999999999994e-4 or 1.70000000000000002e-45 < d

          1. Initial program 59.0%

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

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

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
            3. unsub-negN/A

              \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
            4. unpow2N/A

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

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
            6. div-subN/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            7. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            8. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} - a}}{d} \]
            9. lower-/.f64N/A

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
            10. lower-*.f6482.1

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

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

          if -1.10699999999999994e-4 < d < 1.70000000000000002e-45

          1. Initial program 73.8%

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

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

              \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
            2. mul-1-negN/A

              \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
            3. unsub-negN/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            4. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6492.7

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

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

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

        Alternative 8: 63.6% accurate, 1.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.95 \cdot 10^{+18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-45}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (- a) d)))
           (if (<= d -1.95e+18) t_0 (if (<= d 3.4e-45) (/ b c) t_0))))
        double code(double a, double b, double c, double d) {
        	double t_0 = -a / d;
        	double tmp;
        	if (d <= -1.95e+18) {
        		tmp = t_0;
        	} else if (d <= 3.4e-45) {
        		tmp = b / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        real(8) function code(a, b, c, d)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            real(8), intent (in) :: d
            real(8) :: t_0
            real(8) :: tmp
            t_0 = -a / d
            if (d <= (-1.95d+18)) then
                tmp = t_0
            else if (d <= 3.4d-45) then
                tmp = b / c
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double a, double b, double c, double d) {
        	double t_0 = -a / d;
        	double tmp;
        	if (d <= -1.95e+18) {
        		tmp = t_0;
        	} else if (d <= 3.4e-45) {
        		tmp = b / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(a, b, c, d):
        	t_0 = -a / d
        	tmp = 0
        	if d <= -1.95e+18:
        		tmp = t_0
        	elif d <= 3.4e-45:
        		tmp = b / c
        	else:
        		tmp = t_0
        	return tmp
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(-a) / d)
        	tmp = 0.0
        	if (d <= -1.95e+18)
        		tmp = t_0;
        	elseif (d <= 3.4e-45)
        		tmp = Float64(b / c);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, b, c, d)
        	t_0 = -a / d;
        	tmp = 0.0;
        	if (d <= -1.95e+18)
        		tmp = t_0;
        	elseif (d <= 3.4e-45)
        		tmp = b / c;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.95e+18], t$95$0, If[LessEqual[d, 3.4e-45], N[(b / c), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{-a}{d}\\
        \mathbf{if}\;d \leq -1.95 \cdot 10^{+18}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 3.4 \cdot 10^{-45}:\\
        \;\;\;\;\frac{b}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if d < -1.95e18 or 3.40000000000000004e-45 < d

          1. Initial program 56.9%

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

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

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            2. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
            3. mul-1-negN/A

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6477.4

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites77.4%

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

          if -1.95e18 < d < 3.40000000000000004e-45

          1. Initial program 75.2%

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

            \[\leadsto \color{blue}{\frac{b}{c}} \]
          4. Step-by-step derivation
            1. lower-/.f6473.7

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites73.7%

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

        Alternative 9: 43.0% accurate, 3.2× speedup?

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

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

          \[\leadsto \color{blue}{\frac{b}{c}} \]
        4. Step-by-step derivation
          1. lower-/.f6444.3

            \[\leadsto \color{blue}{\frac{b}{c}} \]
        5. Applied rewrites44.3%

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

        Developer Target 1: 99.3% accurate, 0.6× 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 2024235 
        (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))))