_divideComplex, imaginary part

Percentage Accurate: 61.9% → 96.3%
Time: 13.1s
Alternatives: 10
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\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 10 alternatives:

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

Initial Program: 61.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}

Alternative 1: 96.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{-\mathsf{hypot}\left(y.im, y.re\right)}\right) \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (fma
  (/ y.re (hypot y.re y.im))
  (/ x.im (hypot y.re y.im))
  (* x.re (/ (/ y.im (hypot y.im y.re)) (- (hypot y.im y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return fma((y_46_re / hypot(y_46_re, y_46_im)), (x_46_im / hypot(y_46_re, y_46_im)), (x_46_re * ((y_46_im / hypot(y_46_im, y_46_re)) / -hypot(y_46_im, y_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return fma(Float64(y_46_re / hypot(y_46_re, y_46_im)), Float64(x_46_im / hypot(y_46_re, y_46_im)), Float64(x_46_re * Float64(Float64(y_46_im / hypot(y_46_im, y_46_re)) / Float64(-hypot(y_46_im, y_46_re)))))
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(y$46$re / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(y$46$im / N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{-\mathsf{hypot}\left(y.im, y.re\right)}\right)
\end{array}
Derivation
  1. Initial program 58.9%

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub55.3%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
    2. *-commutative55.3%

      \[\leadsto \frac{\color{blue}{y.re \cdot x.im}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    3. add-sqr-sqrt55.3%

      \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. times-frac58.9%

      \[\leadsto \color{blue}{\frac{y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    5. fmm-def58.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, \frac{x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)} \]
    6. hypot-define58.9%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, \frac{x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
    7. hypot-define77.7%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
    8. associate-/l*81.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{x.re \cdot \frac{y.im}{y.re \cdot y.re + y.im \cdot y.im}}\right) \]
    9. add-sqr-sqrt81.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\right) \]
    10. pow281.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}\right) \]
    11. hypot-define81.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}\right) \]
  4. Applied egg-rr81.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\right)} \]
  5. Step-by-step derivation
    1. *-un-lft-identity81.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\color{blue}{1 \cdot y.im}}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\right) \]
    2. unpow281.3%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{1 \cdot y.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}}\right) \]
    3. times-frac97.6%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)}\right) \]
  6. Applied egg-rr97.6%

    \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)}\right) \]
  7. Step-by-step derivation
    1. associate-*l/97.6%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \color{blue}{\frac{1 \cdot \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\right) \]
    2. *-lft-identity97.6%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\color{blue}{\frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    3. hypot-undefine81.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    4. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\sqrt{\color{blue}{{y.re}^{2}} + y.im \cdot y.im}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    5. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\sqrt{{y.re}^{2} + \color{blue}{{y.im}^{2}}}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    6. +-commutative81.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\sqrt{\color{blue}{{y.im}^{2} + {y.re}^{2}}}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    7. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\sqrt{\color{blue}{y.im \cdot y.im} + {y.re}^{2}}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    8. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\sqrt{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    9. hypot-define97.6%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\right) \]
    10. hypot-undefine81.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\right) \]
    11. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\sqrt{\color{blue}{{y.re}^{2}} + y.im \cdot y.im}}\right) \]
    12. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\sqrt{{y.re}^{2} + \color{blue}{{y.im}^{2}}}}\right) \]
    13. +-commutative81.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\sqrt{\color{blue}{{y.im}^{2} + {y.re}^{2}}}}\right) \]
    14. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\sqrt{\color{blue}{y.im \cdot y.im} + {y.re}^{2}}}\right) \]
    15. unpow281.4%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\sqrt{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}}\right) \]
    16. hypot-define97.6%

      \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)}}\right) \]
  8. Simplified97.6%

    \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \color{blue}{\frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}}\right) \]
  9. Final simplification97.6%

    \[\leadsto \mathsf{fma}\left(\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}, x.re \cdot \frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{-\mathsf{hypot}\left(y.im, y.re\right)}\right) \]
  10. Add Preprocessing

Alternative 2: 85.0% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ t_1 := y.re \cdot x.im - y.im \cdot x.re\\ t_2 := \frac{t\_1}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_0 \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - y.im \cdot \frac{x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\\ \mathbf{elif}\;t\_2 \leq 10^{+304}:\\ \;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot y.re y.im)))
        (t_1 (- (* y.re x.im) (* y.im x.re)))
        (t_2 (/ t_1 (+ (* y.re y.re) (* y.im y.im)))))
   (if (<= t_2 (- INFINITY))
     (-
      (* t_0 (* y.re (/ x.im (hypot y.re y.im))))
      (* y.im (/ x.re (pow (hypot y.re y.im) 2.0))))
     (if (<= t_2 1e+304)
       (* t_0 (/ t_1 (hypot y.re y.im)))
       (/ (/ y.re (hypot y.re y.im)) (/ (hypot y.re y.im) x.im))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = 1.0 / hypot(y_46_re, y_46_im);
	double t_1 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	double t_2 = t_1 / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (t_0 * (y_46_re * (x_46_im / hypot(y_46_re, y_46_im)))) - (y_46_im * (x_46_re / pow(hypot(y_46_re, y_46_im), 2.0)));
	} else if (t_2 <= 1e+304) {
		tmp = t_0 * (t_1 / hypot(y_46_re, y_46_im));
	} else {
		tmp = (y_46_re / hypot(y_46_re, y_46_im)) / (hypot(y_46_re, y_46_im) / x_46_im);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = 1.0 / Math.hypot(y_46_re, y_46_im);
	double t_1 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	double t_2 = t_1 / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = (t_0 * (y_46_re * (x_46_im / Math.hypot(y_46_re, y_46_im)))) - (y_46_im * (x_46_re / Math.pow(Math.hypot(y_46_re, y_46_im), 2.0)));
	} else if (t_2 <= 1e+304) {
		tmp = t_0 * (t_1 / Math.hypot(y_46_re, y_46_im));
	} else {
		tmp = (y_46_re / Math.hypot(y_46_re, y_46_im)) / (Math.hypot(y_46_re, y_46_im) / x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = 1.0 / math.hypot(y_46_re, y_46_im)
	t_1 = (y_46_re * x_46_im) - (y_46_im * x_46_re)
	t_2 = t_1 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = (t_0 * (y_46_re * (x_46_im / math.hypot(y_46_re, y_46_im)))) - (y_46_im * (x_46_re / math.pow(math.hypot(y_46_re, y_46_im), 2.0)))
	elif t_2 <= 1e+304:
		tmp = t_0 * (t_1 / math.hypot(y_46_re, y_46_im))
	else:
		tmp = (y_46_re / math.hypot(y_46_re, y_46_im)) / (math.hypot(y_46_re, y_46_im) / x_46_im)
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(1.0 / hypot(y_46_re, y_46_im))
	t_1 = Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re))
	t_2 = Float64(t_1 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(t_0 * Float64(y_46_re * Float64(x_46_im / hypot(y_46_re, y_46_im)))) - Float64(y_46_im * Float64(x_46_re / (hypot(y_46_re, y_46_im) ^ 2.0))));
	elseif (t_2 <= 1e+304)
		tmp = Float64(t_0 * Float64(t_1 / hypot(y_46_re, y_46_im)));
	else
		tmp = Float64(Float64(y_46_re / hypot(y_46_re, y_46_im)) / Float64(hypot(y_46_re, y_46_im) / x_46_im));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = 1.0 / hypot(y_46_re, y_46_im);
	t_1 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	t_2 = t_1 / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = (t_0 * (y_46_re * (x_46_im / hypot(y_46_re, y_46_im)))) - (y_46_im * (x_46_re / (hypot(y_46_re, y_46_im) ^ 2.0)));
	elseif (t_2 <= 1e+304)
		tmp = t_0 * (t_1 / hypot(y_46_re, y_46_im));
	else
		tmp = (y_46_re / hypot(y_46_re, y_46_im)) / (hypot(y_46_re, y_46_im) / x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$0 * N[(y$46$re * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y$46$im * N[(x$46$re / N[Power[N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+304], N[(t$95$0 * N[(t$95$1 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$46$re / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision] / x$46$im), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}\\
t_1 := y.re \cdot x.im - y.im \cdot x.re\\
t_2 := \frac{t\_1}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_0 \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - y.im \cdot \frac{x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\\

\mathbf{elif}\;t\_2 \leq 10^{+304}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(y.re, y.im\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < -inf.0

    1. Initial program 26.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub10.3%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
      2. *-un-lft-identity10.3%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. add-sqr-sqrt10.3%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. times-frac10.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. fmm-def10.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)} \]
      6. hypot-define10.3%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      7. hypot-define18.6%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. associate-/l*66.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{x.re \cdot \frac{y.im}{y.re \cdot y.re + y.im \cdot y.im}}\right) \]
      9. add-sqr-sqrt66.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\right) \]
      10. pow266.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}\right) \]
      11. hypot-define66.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr66.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -x.re \cdot \frac{y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\right)} \]
    5. Step-by-step derivation
      1. fmm-undef66.2%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)} - x.re \cdot \frac{y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]
      2. *-commutative66.2%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{\color{blue}{y.re \cdot x.im}}{\mathsf{hypot}\left(y.re, y.im\right)} - x.re \cdot \frac{y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \]
      3. associate-/l*79.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)} - x.re \cdot \frac{y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \]
      4. associate-*r/32.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - \color{blue}{\frac{x.re \cdot y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]
      5. *-commutative32.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - \frac{\color{blue}{y.im \cdot x.re}}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \]
      6. associate-/l*79.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - \color{blue}{y.im \cdot \frac{x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]
    6. Simplified79.6%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - y.im \cdot \frac{x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]

    if -inf.0 < (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 9.9999999999999994e303

    1. Initial program 77.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity77.4%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. add-sqr-sqrt77.4%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      3. times-frac77.4%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      4. hypot-define77.4%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \]
      5. hypot-define98.5%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
    4. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}} \]

    if 9.9999999999999994e303 < (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im)))

    1. Initial program 18.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 16.2%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2} + {y.re}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*26.4%

        \[\leadsto \color{blue}{x.im \cdot \frac{y.re}{{y.im}^{2} + {y.re}^{2}}} \]
      2. +-commutative26.4%

        \[\leadsto x.im \cdot \frac{y.re}{\color{blue}{{y.re}^{2} + {y.im}^{2}}} \]
    5. Simplified26.4%

      \[\leadsto \color{blue}{x.im \cdot \frac{y.re}{{y.re}^{2} + {y.im}^{2}}} \]
    6. Step-by-step derivation
      1. *-commutative26.4%

        \[\leadsto \color{blue}{\frac{y.re}{{y.re}^{2} + {y.im}^{2}} \cdot x.im} \]
      2. pow226.4%

        \[\leadsto \frac{y.re}{\color{blue}{y.re \cdot y.re} + {y.im}^{2}} \cdot x.im \]
      3. pow226.4%

        \[\leadsto \frac{y.re}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \cdot x.im \]
      4. add-sqr-sqrt26.4%

        \[\leadsto \frac{y.re}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \cdot x.im \]
      5. hypot-undefine26.4%

        \[\leadsto \frac{y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot x.im \]
      6. hypot-undefine26.4%

        \[\leadsto \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot x.im \]
      7. unpow226.4%

        \[\leadsto \frac{y.re}{\color{blue}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \cdot x.im \]
      8. associate-*l/16.2%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]
      9. unpow216.2%

        \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}} \]
      10. frac-times70.2%

        \[\leadsto \color{blue}{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      11. clear-num70.1%

        \[\leadsto \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
      12. un-div-inv70.1%

        \[\leadsto \color{blue}{\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
    7. Applied egg-rr70.1%

      \[\leadsto \color{blue}{\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im} \leq -\infty:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right) - y.im \cdot \frac{x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}\\ \mathbf{elif}\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+304}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot x.im - y.im \cdot x.re\\ \mathbf{if}\;\frac{t\_0}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+304}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (- (* y.re x.im) (* y.im x.re))))
   (if (<= (/ t_0 (+ (* y.re y.re) (* y.im y.im))) 1e+304)
     (* (/ 1.0 (hypot y.re y.im)) (/ t_0 (hypot y.re y.im)))
     (/ (/ y.re (hypot y.re y.im)) (/ (hypot y.re y.im) x.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	double tmp;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+304) {
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
	} else {
		tmp = (y_46_re / hypot(y_46_re, y_46_im)) / (hypot(y_46_re, y_46_im) / x_46_im);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	double tmp;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+304) {
		tmp = (1.0 / Math.hypot(y_46_re, y_46_im)) * (t_0 / Math.hypot(y_46_re, y_46_im));
	} else {
		tmp = (y_46_re / Math.hypot(y_46_re, y_46_im)) / (Math.hypot(y_46_re, y_46_im) / x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (y_46_re * x_46_im) - (y_46_im * x_46_re)
	tmp = 0
	if (t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+304:
		tmp = (1.0 / math.hypot(y_46_re, y_46_im)) * (t_0 / math.hypot(y_46_re, y_46_im))
	else:
		tmp = (y_46_re / math.hypot(y_46_re, y_46_im)) / (math.hypot(y_46_re, y_46_im) / x_46_im)
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) <= 1e+304)
		tmp = Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(t_0 / hypot(y_46_re, y_46_im)));
	else
		tmp = Float64(Float64(y_46_re / hypot(y_46_re, y_46_im)) / Float64(hypot(y_46_re, y_46_im) / x_46_im));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	tmp = 0.0;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+304)
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
	else
		tmp = (y_46_re / hypot(y_46_re, y_46_im)) / (hypot(y_46_re, y_46_im) / x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+304], N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$46$re / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision] / x$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot x.im - y.im \cdot x.re\\
\mathbf{if}\;\frac{t\_0}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+304}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(y.re, y.im\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 9.9999999999999994e303

    1. Initial program 73.6%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity73.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. add-sqr-sqrt73.6%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      3. times-frac73.6%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      4. hypot-define73.6%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \]
      5. hypot-define94.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
    4. Applied egg-rr94.6%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}} \]

    if 9.9999999999999994e303 < (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im)))

    1. Initial program 18.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in x.im around inf 16.2%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2} + {y.re}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*26.4%

        \[\leadsto \color{blue}{x.im \cdot \frac{y.re}{{y.im}^{2} + {y.re}^{2}}} \]
      2. +-commutative26.4%

        \[\leadsto x.im \cdot \frac{y.re}{\color{blue}{{y.re}^{2} + {y.im}^{2}}} \]
    5. Simplified26.4%

      \[\leadsto \color{blue}{x.im \cdot \frac{y.re}{{y.re}^{2} + {y.im}^{2}}} \]
    6. Step-by-step derivation
      1. *-commutative26.4%

        \[\leadsto \color{blue}{\frac{y.re}{{y.re}^{2} + {y.im}^{2}} \cdot x.im} \]
      2. pow226.4%

        \[\leadsto \frac{y.re}{\color{blue}{y.re \cdot y.re} + {y.im}^{2}} \cdot x.im \]
      3. pow226.4%

        \[\leadsto \frac{y.re}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \cdot x.im \]
      4. add-sqr-sqrt26.4%

        \[\leadsto \frac{y.re}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \cdot x.im \]
      5. hypot-undefine26.4%

        \[\leadsto \frac{y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot x.im \]
      6. hypot-undefine26.4%

        \[\leadsto \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot x.im \]
      7. unpow226.4%

        \[\leadsto \frac{y.re}{\color{blue}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \cdot x.im \]
      8. associate-*l/16.2%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]
      9. unpow216.2%

        \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}} \]
      10. frac-times70.2%

        \[\leadsto \color{blue}{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      11. clear-num70.1%

        \[\leadsto \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
      12. un-div-inv70.1%

        \[\leadsto \color{blue}{\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
    7. Applied egg-rr70.1%

      \[\leadsto \color{blue}{\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+304}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ t_1 := \frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{if}\;y.re \leq -1 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.re \leq -7 \cdot 10^{-89}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 3.35 \cdot 10^{+75}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im))))
        (t_1 (/ (- x.im (* x.re (/ y.im y.re))) y.re)))
   (if (<= y.re -1e+83)
     t_1
     (if (<= y.re -7e-89)
       t_0
       (if (<= y.re 5e-84)
         (/ (- (* x.im (/ y.re y.im)) x.re) y.im)
         (if (<= y.re 3.35e+75) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double t_1 = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	double tmp;
	if (y_46_re <= -1e+83) {
		tmp = t_1;
	} else if (y_46_re <= -7e-89) {
		tmp = t_0;
	} else if (y_46_re <= 5e-84) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 3.35e+75) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((y_46re * x_46im) - (y_46im * x_46re)) / ((y_46re * y_46re) + (y_46im * y_46im))
    t_1 = (x_46im - (x_46re * (y_46im / y_46re))) / y_46re
    if (y_46re <= (-1d+83)) then
        tmp = t_1
    else if (y_46re <= (-7d-89)) then
        tmp = t_0
    else if (y_46re <= 5d-84) then
        tmp = ((x_46im * (y_46re / y_46im)) - x_46re) / y_46im
    else if (y_46re <= 3.35d+75) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double t_1 = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	double tmp;
	if (y_46_re <= -1e+83) {
		tmp = t_1;
	} else if (y_46_re <= -7e-89) {
		tmp = t_0;
	} else if (y_46_re <= 5e-84) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 3.35e+75) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	t_1 = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	tmp = 0
	if y_46_re <= -1e+83:
		tmp = t_1
	elif y_46_re <= -7e-89:
		tmp = t_0
	elif y_46_re <= 5e-84:
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im
	elif y_46_re <= 3.35e+75:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	t_1 = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_46_re))) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -1e+83)
		tmp = t_1;
	elseif (y_46_re <= -7e-89)
		tmp = t_0;
	elseif (y_46_re <= 5e-84)
		tmp = Float64(Float64(Float64(x_46_im * Float64(y_46_re / y_46_im)) - x_46_re) / y_46_im);
	elseif (y_46_re <= 3.35e+75)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	t_1 = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -1e+83)
		tmp = t_1;
	elseif (y_46_re <= -7e-89)
		tmp = t_0;
	elseif (y_46_re <= 5e-84)
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	elseif (y_46_re <= 3.35e+75)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1e+83], t$95$1, If[LessEqual[y$46$re, -7e-89], t$95$0, If[LessEqual[y$46$re, 5e-84], N[(N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 3.35e+75], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\
\mathbf{if}\;y.re \leq -1 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y.re \leq -7 \cdot 10^{-89}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq 5 \cdot 10^{-84}:\\
\;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\

\mathbf{elif}\;y.re \leq 3.35 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -1.00000000000000003e83 or 3.35e75 < y.re

    1. Initial program 33.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 80.2%

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. mul-1-neg80.2%

        \[\leadsto \frac{x.im + \color{blue}{\left(-\frac{x.re \cdot y.im}{y.re}\right)}}{y.re} \]
      2. unsub-neg80.2%

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      3. associate-/l*85.1%

        \[\leadsto \frac{x.im - \color{blue}{x.re \cdot \frac{y.im}{y.re}}}{y.re} \]
    5. Simplified85.1%

      \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]

    if -1.00000000000000003e83 < y.re < -6.9999999999999994e-89 or 5.0000000000000002e-84 < y.re < 3.35e75

    1. Initial program 84.6%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing

    if -6.9999999999999994e-89 < y.re < 5.0000000000000002e-84

    1. Initial program 67.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 79.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutative79.8%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg79.8%

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg79.8%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow279.8%

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*87.4%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-sub91.2%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. *-commutative91.2%

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} - x.re}{y.im} \]
      8. associate-/l*90.2%

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} - x.re}{y.im} \]
    5. Simplified90.2%

      \[\leadsto \color{blue}{\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}} \]
    6. Step-by-step derivation
      1. clear-num90.2%

        \[\leadsto \frac{y.re \cdot \color{blue}{\frac{1}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
      2. un-div-inv90.2%

        \[\leadsto \frac{\color{blue}{\frac{y.re}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
    7. Applied egg-rr90.2%

      \[\leadsto \frac{\color{blue}{\frac{y.re}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
    8. Step-by-step derivation
      1. associate-/r/91.4%

        \[\leadsto \frac{\color{blue}{\frac{y.re}{y.im} \cdot x.im} - x.re}{y.im} \]
    9. Simplified91.4%

      \[\leadsto \frac{\color{blue}{\frac{y.re}{y.im} \cdot x.im} - x.re}{y.im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -1 \cdot 10^{+83}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{elif}\;y.re \leq -7 \cdot 10^{-89}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 3.35 \cdot 10^{+75}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -5.8 \cdot 10^{-10} \lor \neg \left(y.im \leq 1.8 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -5.8e-10) (not (<= y.im 1.8e-19)))
   (/ (- (* y.re (/ x.im y.im)) x.re) y.im)
   (/ (- x.im (/ (* y.im x.re) y.re)) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -5.8e-10) || !(y_46_im <= 1.8e-19)) {
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	} else {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-5.8d-10)) .or. (.not. (y_46im <= 1.8d-19))) then
        tmp = ((y_46re * (x_46im / y_46im)) - x_46re) / y_46im
    else
        tmp = (x_46im - ((y_46im * x_46re) / y_46re)) / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -5.8e-10) || !(y_46_im <= 1.8e-19)) {
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	} else {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -5.8e-10) or not (y_46_im <= 1.8e-19):
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im
	else:
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -5.8e-10) || !(y_46_im <= 1.8e-19))
		tmp = Float64(Float64(Float64(y_46_re * Float64(x_46_im / y_46_im)) - x_46_re) / y_46_im);
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -5.8e-10) || ~((y_46_im <= 1.8e-19)))
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	else
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -5.8e-10], N[Not[LessEqual[y$46$im, 1.8e-19]], $MachinePrecision]], N[(N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -5.8 \cdot 10^{-10} \lor \neg \left(y.im \leq 1.8 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -5.79999999999999962e-10 or 1.8000000000000001e-19 < y.im

    1. Initial program 53.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 67.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutative67.9%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg67.9%

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg67.9%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow267.9%

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*70.2%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-sub70.2%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. *-commutative70.2%

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} - x.re}{y.im} \]
      8. associate-/l*76.3%

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} - x.re}{y.im} \]
    5. Simplified76.3%

      \[\leadsto \color{blue}{\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}} \]

    if -5.79999999999999962e-10 < y.im < 1.8000000000000001e-19

    1. Initial program 64.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 87.5%

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. mul-1-neg87.5%

        \[\leadsto \frac{x.im + \color{blue}{\left(-\frac{x.re \cdot y.im}{y.re}\right)}}{y.re} \]
      2. unsub-neg87.5%

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      3. associate-/l*86.8%

        \[\leadsto \frac{x.im - \color{blue}{x.re \cdot \frac{y.im}{y.re}}}{y.re} \]
    5. Simplified86.8%

      \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Taylor expanded in x.re around 0 87.5%

      \[\leadsto \frac{x.im - \color{blue}{\frac{x.re \cdot y.im}{y.re}}}{y.re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -5.8 \cdot 10^{-10} \lor \neg \left(y.im \leq 1.8 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -6.2 \cdot 10^{+36} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\ \;\;\;\;\frac{x.re}{-y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -6.2e+36) (not (<= y.im 9e-18)))
   (/ x.re (- y.im))
   (/ (- x.im (* x.re (/ y.im y.re))) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -6.2e+36) || !(y_46_im <= 9e-18)) {
		tmp = x_46_re / -y_46_im;
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-6.2d+36)) .or. (.not. (y_46im <= 9d-18))) then
        tmp = x_46re / -y_46im
    else
        tmp = (x_46im - (x_46re * (y_46im / y_46re))) / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -6.2e+36) || !(y_46_im <= 9e-18)) {
		tmp = x_46_re / -y_46_im;
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -6.2e+36) or not (y_46_im <= 9e-18):
		tmp = x_46_re / -y_46_im
	else:
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -6.2e+36) || !(y_46_im <= 9e-18))
		tmp = Float64(x_46_re / Float64(-y_46_im));
	else
		tmp = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_46_re))) / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -6.2e+36) || ~((y_46_im <= 9e-18)))
		tmp = x_46_re / -y_46_im;
	else
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -6.2e+36], N[Not[LessEqual[y$46$im, 9e-18]], $MachinePrecision]], N[(x$46$re / (-y$46$im)), $MachinePrecision], N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -6.2 \cdot 10^{+36} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{x.re}{-y.im}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -6.1999999999999999e36 or 8.99999999999999987e-18 < y.im

    1. Initial program 51.6%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 63.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. associate-*r/63.2%

        \[\leadsto \color{blue}{\frac{-1 \cdot x.re}{y.im}} \]
      2. neg-mul-163.2%

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} \]
    5. Simplified63.2%

      \[\leadsto \color{blue}{\frac{-x.re}{y.im}} \]

    if -6.1999999999999999e36 < y.im < 8.99999999999999987e-18

    1. Initial program 64.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 82.2%

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. mul-1-neg82.2%

        \[\leadsto \frac{x.im + \color{blue}{\left(-\frac{x.re \cdot y.im}{y.re}\right)}}{y.re} \]
      2. unsub-neg82.2%

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      3. associate-/l*82.2%

        \[\leadsto \frac{x.im - \color{blue}{x.re \cdot \frac{y.im}{y.re}}}{y.re} \]
    5. Simplified82.2%

      \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -6.2 \cdot 10^{+36} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\ \;\;\;\;\frac{x.re}{-y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -3.9 \cdot 10^{-10}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 1.45 \cdot 10^{-18}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\frac{y.im}{x.im}} - x.re}{y.im}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.im -3.9e-10)
   (/ (- (* y.re (/ x.im y.im)) x.re) y.im)
   (if (<= y.im 1.45e-18)
     (/ (- x.im (/ (* y.im x.re) y.re)) y.re)
     (/ (- (/ y.re (/ y.im x.im)) x.re) y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_im <= -3.9e-10) {
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_im <= 1.45e-18) {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	} else {
		tmp = ((y_46_re / (y_46_im / x_46_im)) - x_46_re) / y_46_im;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if (y_46im <= (-3.9d-10)) then
        tmp = ((y_46re * (x_46im / y_46im)) - x_46re) / y_46im
    else if (y_46im <= 1.45d-18) then
        tmp = (x_46im - ((y_46im * x_46re) / y_46re)) / y_46re
    else
        tmp = ((y_46re / (y_46im / x_46im)) - x_46re) / y_46im
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_im <= -3.9e-10) {
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_im <= 1.45e-18) {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	} else {
		tmp = ((y_46_re / (y_46_im / x_46_im)) - x_46_re) / y_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_im <= -3.9e-10:
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im
	elif y_46_im <= 1.45e-18:
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re
	else:
		tmp = ((y_46_re / (y_46_im / x_46_im)) - x_46_re) / y_46_im
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_im <= -3.9e-10)
		tmp = Float64(Float64(Float64(y_46_re * Float64(x_46_im / y_46_im)) - x_46_re) / y_46_im);
	elseif (y_46_im <= 1.45e-18)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re);
	else
		tmp = Float64(Float64(Float64(y_46_re / Float64(y_46_im / x_46_im)) - x_46_re) / y_46_im);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_im <= -3.9e-10)
		tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
	elseif (y_46_im <= 1.45e-18)
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	else
		tmp = ((y_46_re / (y_46_im / x_46_im)) - x_46_re) / y_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -3.9e-10], N[(N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.45e-18], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(y$46$re / N[(y$46$im / x$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\

\mathbf{elif}\;y.im \leq 1.45 \cdot 10^{-18}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y.re}{\frac{y.im}{x.im}} - x.re}{y.im}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -3.9e-10

    1. Initial program 53.6%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 67.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutative67.1%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg67.1%

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg67.1%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow267.1%

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*69.8%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-sub69.8%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. *-commutative69.8%

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} - x.re}{y.im} \]
      8. associate-/l*74.0%

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} - x.re}{y.im} \]
    5. Simplified74.0%

      \[\leadsto \color{blue}{\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}} \]

    if -3.9e-10 < y.im < 1.45e-18

    1. Initial program 64.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 87.5%

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. mul-1-neg87.5%

        \[\leadsto \frac{x.im + \color{blue}{\left(-\frac{x.re \cdot y.im}{y.re}\right)}}{y.re} \]
      2. unsub-neg87.5%

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      3. associate-/l*86.8%

        \[\leadsto \frac{x.im - \color{blue}{x.re \cdot \frac{y.im}{y.re}}}{y.re} \]
    5. Simplified86.8%

      \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Taylor expanded in x.re around 0 87.5%

      \[\leadsto \frac{x.im - \color{blue}{\frac{x.re \cdot y.im}{y.re}}}{y.re} \]

    if 1.45e-18 < y.im

    1. Initial program 53.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 68.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutative68.7%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg68.7%

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg68.7%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow268.7%

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*70.6%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-sub70.6%

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. *-commutative70.6%

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} - x.re}{y.im} \]
      8. associate-/l*79.0%

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} - x.re}{y.im} \]
    5. Simplified79.0%

      \[\leadsto \color{blue}{\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}} \]
    6. Step-by-step derivation
      1. clear-num79.0%

        \[\leadsto \frac{y.re \cdot \color{blue}{\frac{1}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
      2. un-div-inv79.0%

        \[\leadsto \frac{\color{blue}{\frac{y.re}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
    7. Applied egg-rr79.0%

      \[\leadsto \frac{\color{blue}{\frac{y.re}{\frac{y.im}{x.im}}} - x.re}{y.im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.9 \cdot 10^{-10}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 1.45 \cdot 10^{-18}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\frac{y.im}{x.im}} - x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 64.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -3.6 \cdot 10^{-10} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\ \;\;\;\;\frac{x.re}{-y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -3.6e-10) (not (<= y.im 9e-18)))
   (/ x.re (- y.im))
   (/ x.im y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -3.6e-10) || !(y_46_im <= 9e-18)) {
		tmp = x_46_re / -y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-3.6d-10)) .or. (.not. (y_46im <= 9d-18))) then
        tmp = x_46re / -y_46im
    else
        tmp = x_46im / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -3.6e-10) || !(y_46_im <= 9e-18)) {
		tmp = x_46_re / -y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -3.6e-10) or not (y_46_im <= 9e-18):
		tmp = x_46_re / -y_46_im
	else:
		tmp = x_46_im / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -3.6e-10) || !(y_46_im <= 9e-18))
		tmp = Float64(x_46_re / Float64(-y_46_im));
	else
		tmp = Float64(x_46_im / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -3.6e-10) || ~((y_46_im <= 9e-18)))
		tmp = x_46_re / -y_46_im;
	else
		tmp = x_46_im / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -3.6e-10], N[Not[LessEqual[y$46$im, 9e-18]], $MachinePrecision]], N[(x$46$re / (-y$46$im)), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.6 \cdot 10^{-10} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{x.re}{-y.im}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -3.6e-10 or 8.99999999999999987e-18 < y.im

    1. Initial program 53.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 60.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. associate-*r/60.1%

        \[\leadsto \color{blue}{\frac{-1 \cdot x.re}{y.im}} \]
      2. neg-mul-160.1%

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} \]
    5. Simplified60.1%

      \[\leadsto \color{blue}{\frac{-x.re}{y.im}} \]

    if -3.6e-10 < y.im < 8.99999999999999987e-18

    1. Initial program 64.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 74.6%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.6 \cdot 10^{-10} \lor \neg \left(y.im \leq 9 \cdot 10^{-18}\right):\\ \;\;\;\;\frac{x.re}{-y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 44.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq 4.6 \cdot 10^{+206}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.im}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.im 4.6e+206) (/ x.im y.re) (/ x.re y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_im <= 4.6e+206) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = x_46_re / y_46_im;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if (y_46im <= 4.6d+206) then
        tmp = x_46im / y_46re
    else
        tmp = x_46re / y_46im
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_im <= 4.6e+206) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = x_46_re / y_46_im;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_im <= 4.6e+206:
		tmp = x_46_im / y_46_re
	else:
		tmp = x_46_re / y_46_im
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_im <= 4.6e+206)
		tmp = Float64(x_46_im / y_46_re);
	else
		tmp = Float64(x_46_re / y_46_im);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_im <= 4.6e+206)
		tmp = x_46_im / y_46_re;
	else
		tmp = x_46_re / y_46_im;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, 4.6e+206], N[(x$46$im / y$46$re), $MachinePrecision], N[(x$46$re / y$46$im), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq 4.6 \cdot 10^{+206}:\\
\;\;\;\;\frac{x.im}{y.re}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.im}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < 4.60000000000000032e206

    1. Initial program 60.2%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf 51.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]

    if 4.60000000000000032e206 < y.im

    1. Initial program 41.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0 88.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot x.re}{y.im}} \]
      2. neg-mul-188.8%

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} \]
    5. Simplified88.8%

      \[\leadsto \color{blue}{\frac{-x.re}{y.im}} \]
    6. Step-by-step derivation
      1. neg-sub088.8%

        \[\leadsto \frac{\color{blue}{0 - x.re}}{y.im} \]
      2. sub-neg88.8%

        \[\leadsto \frac{\color{blue}{0 + \left(-x.re\right)}}{y.im} \]
      3. add-sqr-sqrt41.5%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{-x.re} \cdot \sqrt{-x.re}}}{y.im} \]
      4. sqrt-unprod48.9%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}}{y.im} \]
      5. sqr-neg48.9%

        \[\leadsto \frac{0 + \sqrt{\color{blue}{x.re \cdot x.re}}}{y.im} \]
      6. sqrt-unprod24.6%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{x.re} \cdot \sqrt{x.re}}}{y.im} \]
      7. add-sqr-sqrt43.2%

        \[\leadsto \frac{0 + \color{blue}{x.re}}{y.im} \]
    7. Applied egg-rr43.2%

      \[\leadsto \frac{\color{blue}{0 + x.re}}{y.im} \]
    8. Step-by-step derivation
      1. +-lft-identity43.2%

        \[\leadsto \frac{\color{blue}{x.re}}{y.im} \]
    9. Simplified43.2%

      \[\leadsto \frac{\color{blue}{x.re}}{y.im} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 42.6% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{x.im}{y.re} \end{array} \]
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return x_46_im / y_46_re;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = x_46im / y_46re
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return x_46_im / y_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(x_46_im / y_46_re)
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = x_46_im / y_46_re;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im}{y.re}
\end{array}
Derivation
  1. Initial program 58.9%

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
  2. Add Preprocessing
  3. Taylor expanded in y.re around inf 48.2%

    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024170 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  :precision binary64
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))