Complex division, imag part

Percentage Accurate: 60.8% → 78.9%
Time: 6.5s
Alternatives: 7
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 7 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: 60.8% 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: 78.9% accurate, 0.1× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -8.9999999999999999e-10 or 9.0000000000000002e153 < c

    1. Initial program 39.6%

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

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

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

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

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

    if -8.9999999999999999e-10 < c < 2.04999999999999997e-79

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
      9. associate-*r/N/A

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

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

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

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

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

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

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

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

      if 2.04999999999999997e-79 < c < 9.0000000000000002e153

      1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
        9. associate-*r/N/A

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+153}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{b}, -a, c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \end{array} \]
    10. Add Preprocessing

    Alternative 2: 79.5% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-d}{c}, a, b\right)}{c}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+153}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{b}, -a, c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (if (<= c -9e-10)
       (/ (fma (/ (- d) c) a b) c)
       (if (<= c 2.05e-79)
         (/ (fma (/ c d) b (- a)) d)
         (if (<= c 9e+153)
           (* (/ (fma (/ d b) (- a) c) (fma d d (* c c))) b)
           (/ (- b (* (/ d c) a)) c)))))
    double code(double a, double b, double c, double d) {
    	double tmp;
    	if (c <= -9e-10) {
    		tmp = fma((-d / c), a, b) / c;
    	} else if (c <= 2.05e-79) {
    		tmp = fma((c / d), b, -a) / d;
    	} else if (c <= 9e+153) {
    		tmp = (fma((d / b), -a, c) / fma(d, d, (c * c))) * b;
    	} else {
    		tmp = (b - ((d / c) * a)) / c;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	tmp = 0.0
    	if (c <= -9e-10)
    		tmp = Float64(fma(Float64(Float64(-d) / c), a, b) / c);
    	elseif (c <= 2.05e-79)
    		tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d);
    	elseif (c <= 9e+153)
    		tmp = Float64(Float64(fma(Float64(d / b), Float64(-a), c) / fma(d, d, Float64(c * c))) * b);
    	else
    		tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c);
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := If[LessEqual[c, -9e-10], N[(N[(N[((-d) / c), $MachinePrecision] * a + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 2.05e-79], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 9e+153], N[(N[(N[(N[(d / b), $MachinePrecision] * (-a) + c), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{-d}{c}, a, b\right)}{c}\\
    
    \mathbf{elif}\;c \leq 2.05 \cdot 10^{-79}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
    
    \mathbf{elif}\;c \leq 9 \cdot 10^{+153}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{b}, -a, c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if c < -8.9999999999999999e-10

      1. Initial program 52.9%

        \[\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. fp-cancel-sign-sub-invN/A

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

          \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
        4. *-lft-identityN/A

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

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

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

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

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

          \[\leadsto \frac{b - \frac{d}{c} \cdot a}{c} \]
        2. Step-by-step derivation
          1. Applied rewrites80.1%

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

          if -8.9999999999999999e-10 < c < 2.04999999999999997e-79

          1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
            9. associate-*r/N/A

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

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

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

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

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

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

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

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

            if 2.04999999999999997e-79 < c < 9.0000000000000002e153

            1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
              9. associate-*r/N/A

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

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

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

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

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

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

            if 9.0000000000000002e153 < c

            1. Initial program 23.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. fp-cancel-sign-sub-invN/A

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

                \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
              4. *-lft-identityN/A

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

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

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

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

              \[\leadsto \color{blue}{\frac{b - \frac{a \cdot d}{c}}{c}} \]
            6. Step-by-step derivation
              1. Applied rewrites87.9%

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-d}{c}, a, b\right)}{c}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+153}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{b}, -a, c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \end{array} \]
            9. Add Preprocessing

            Alternative 3: 77.7% accurate, 0.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 9.2 \cdot 10^{+23}\right):\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \end{array} \end{array} \]
            (FPCore (a b c d)
             :precision binary64
             (if (or (<= c -9e-10) (not (<= c 9.2e+23)))
               (/ (- b (* (/ d c) a)) c)
               (/ (fma (/ c d) b (- a)) d)))
            double code(double a, double b, double c, double d) {
            	double tmp;
            	if ((c <= -9e-10) || !(c <= 9.2e+23)) {
            		tmp = (b - ((d / c) * a)) / c;
            	} else {
            		tmp = fma((c / d), b, -a) / d;
            	}
            	return tmp;
            }
            
            function code(a, b, c, d)
            	tmp = 0.0
            	if ((c <= -9e-10) || !(c <= 9.2e+23))
            		tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c);
            	else
            		tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d);
            	end
            	return tmp
            end
            
            code[a_, b_, c_, d_] := If[Or[LessEqual[c, -9e-10], N[Not[LessEqual[c, 9.2e+23]], $MachinePrecision]], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 9.2 \cdot 10^{+23}\right):\\
            \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if c < -8.9999999999999999e-10 or 9.2000000000000002e23 < c

              1. Initial program 45.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 + -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. fp-cancel-sign-sub-invN/A

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

                  \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
                4. *-lft-identityN/A

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

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

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

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

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

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

                if -8.9999999999999999e-10 < c < 9.2000000000000002e23

                1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
                  9. associate-*r/N/A

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

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

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

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

                    \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)} \cdot b \]
                5. Applied rewrites61.9%

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

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

                    \[\leadsto \frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{\color{blue}{d}} \]
                8. Recombined 2 regimes into one program.
                9. Final simplification83.1%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 9.2 \cdot 10^{+23}\right):\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \end{array} \]
                10. Add Preprocessing

                Alternative 4: 72.2% accurate, 0.9× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 5.2 \cdot 10^{+29}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \end{array} \end{array} \]
                (FPCore (a b c d)
                 :precision binary64
                 (if (or (<= c -9e-10) (not (<= c 5.2e+29)))
                   (/ b c)
                   (/ (fma (/ c d) b (- a)) d)))
                double code(double a, double b, double c, double d) {
                	double tmp;
                	if ((c <= -9e-10) || !(c <= 5.2e+29)) {
                		tmp = b / c;
                	} else {
                		tmp = fma((c / d), b, -a) / d;
                	}
                	return tmp;
                }
                
                function code(a, b, c, d)
                	tmp = 0.0
                	if ((c <= -9e-10) || !(c <= 5.2e+29))
                		tmp = Float64(b / c);
                	else
                		tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d);
                	end
                	return tmp
                end
                
                code[a_, b_, c_, d_] := If[Or[LessEqual[c, -9e-10], N[Not[LessEqual[c, 5.2e+29]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 5.2 \cdot 10^{+29}\right):\\
                \;\;\;\;\frac{b}{c}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if c < -8.9999999999999999e-10 or 5.2e29 < c

                  1. Initial program 45.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-/.f6469.4

                      \[\leadsto \color{blue}{\frac{b}{c}} \]
                  5. Applied rewrites69.4%

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

                  if -8.9999999999999999e-10 < c < 5.2e29

                  1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
                    9. associate-*r/N/A

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

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

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

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

                      \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)} \cdot b \]
                  5. Applied rewrites61.9%

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

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

                      \[\leadsto \frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{\color{blue}{d}} \]
                  8. Recombined 2 regimes into one program.
                  9. Final simplification76.7%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10} \lor \neg \left(c \leq 5.2 \cdot 10^{+29}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \end{array} \]
                  10. Add Preprocessing

                  Alternative 5: 77.7% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-d}{c}, a, b\right)}{c}\\ \mathbf{elif}\;c \leq 9.2 \cdot 10^{+23}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \end{array} \end{array} \]
                  (FPCore (a b c d)
                   :precision binary64
                   (if (<= c -9e-10)
                     (/ (fma (/ (- d) c) a b) c)
                     (if (<= c 9.2e+23) (/ (fma (/ c d) b (- a)) d) (/ (- b (* (/ d c) a)) c))))
                  double code(double a, double b, double c, double d) {
                  	double tmp;
                  	if (c <= -9e-10) {
                  		tmp = fma((-d / c), a, b) / c;
                  	} else if (c <= 9.2e+23) {
                  		tmp = fma((c / d), b, -a) / d;
                  	} else {
                  		tmp = (b - ((d / c) * a)) / c;
                  	}
                  	return tmp;
                  }
                  
                  function code(a, b, c, d)
                  	tmp = 0.0
                  	if (c <= -9e-10)
                  		tmp = Float64(fma(Float64(Float64(-d) / c), a, b) / c);
                  	elseif (c <= 9.2e+23)
                  		tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d);
                  	else
                  		tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c);
                  	end
                  	return tmp
                  end
                  
                  code[a_, b_, c_, d_] := If[LessEqual[c, -9e-10], N[(N[(N[((-d) / c), $MachinePrecision] * a + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 9.2e+23], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;c \leq -9 \cdot 10^{-10}:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(\frac{-d}{c}, a, b\right)}{c}\\
                  
                  \mathbf{elif}\;c \leq 9.2 \cdot 10^{+23}:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if c < -8.9999999999999999e-10

                    1. Initial program 52.9%

                      \[\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. fp-cancel-sign-sub-invN/A

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

                        \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
                      4. *-lft-identityN/A

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

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

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

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

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

                        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{c} \]
                      2. Step-by-step derivation
                        1. Applied rewrites80.1%

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

                        if -8.9999999999999999e-10 < c < 9.2000000000000002e23

                        1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(\color{blue}{\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} \cdot -1} + -1 \cdot \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \cdot b \]
                          9. associate-*r/N/A

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

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

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

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

                            \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)} \cdot b \]
                        5. Applied rewrites61.9%

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

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

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

                          if 9.2000000000000002e23 < c

                          1. Initial program 39.6%

                            \[\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. fp-cancel-sign-sub-invN/A

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

                              \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
                            4. *-lft-identityN/A

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

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

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

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

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

                              \[\leadsto \frac{b - \frac{d}{c} \cdot a}{c} \]
                          7. Recombined 3 regimes into one program.
                          8. Final simplification83.1%

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

                          Alternative 6: 63.3% accurate, 1.5× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{+83} \lor \neg \left(d \leq 2.2 \cdot 10^{+23}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
                          (FPCore (a b c d)
                           :precision binary64
                           (if (or (<= d -6.2e+83) (not (<= d 2.2e+23))) (/ (- a) d) (/ b c)))
                          double code(double a, double b, double c, double d) {
                          	double tmp;
                          	if ((d <= -6.2e+83) || !(d <= 2.2e+23)) {
                          		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 <= (-6.2d+83)) .or. (.not. (d <= 2.2d+23))) 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 <= -6.2e+83) || !(d <= 2.2e+23)) {
                          		tmp = -a / d;
                          	} else {
                          		tmp = b / c;
                          	}
                          	return tmp;
                          }
                          
                          def code(a, b, c, d):
                          	tmp = 0
                          	if (d <= -6.2e+83) or not (d <= 2.2e+23):
                          		tmp = -a / d
                          	else:
                          		tmp = b / c
                          	return tmp
                          
                          function code(a, b, c, d)
                          	tmp = 0.0
                          	if ((d <= -6.2e+83) || !(d <= 2.2e+23))
                          		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 ((d <= -6.2e+83) || ~((d <= 2.2e+23)))
                          		tmp = -a / d;
                          	else
                          		tmp = b / c;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6.2e+83], N[Not[LessEqual[d, 2.2e+23]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;d \leq -6.2 \cdot 10^{+83} \lor \neg \left(d \leq 2.2 \cdot 10^{+23}\right):\\
                          \;\;\;\;\frac{-a}{d}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\frac{b}{c}\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if d < -6.19999999999999984e83 or 2.20000000000000008e23 < d

                            1. Initial program 45.5%

                              \[\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. mul-1-negN/A

                                \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
                              2. distribute-neg-frac2N/A

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

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

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

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

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

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

                            if -6.19999999999999984e83 < d < 2.20000000000000008e23

                            1. Initial program 65.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}{c}} \]
                            4. Step-by-step derivation
                              1. lower-/.f6465.4

                                \[\leadsto \color{blue}{\frac{b}{c}} \]
                            5. Applied rewrites65.4%

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

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

                          Alternative 7: 42.5% 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 57.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-/.f6447.1

                              \[\leadsto \color{blue}{\frac{b}{c}} \]
                          5. Applied rewrites47.1%

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

                          Developer Target 1: 99.4% 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 2024344 
                          (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))))