_divideComplex, real part

Percentage Accurate: 61.0% → 81.8%
Time: 7.0s
Alternatives: 9
Speedup: 1.6×

Specification

?
\[\begin{array}{l} \\ \frac{x.re \cdot y.re + x.im \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.re y.re) (* x.im 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_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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_46re * y_46re) + (x_46im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + Float64(x_46_im * 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_re * y_46_re) + (x_46_im * 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$re * y$46$re), $MachinePrecision] + N[(x$46$im * 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.re \cdot y.re + x.im \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 9 alternatives:

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

Initial Program: 61.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x.re \cdot y.re + x.im \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.re y.re) (* x.im 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_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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_46re * y_46re) + (x_46im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + Float64(x_46_im * 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_re * y_46_re) + (x_46_im * 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$re * y$46$re), $MachinePrecision] + N[(x$46$im * 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.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}

Alternative 1: 81.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\ t_1 := \mathsf{fma}\left(x.im, \frac{y.im}{t\_0}, y.re \cdot \frac{x.re}{t\_0}\right)\\ \mathbf{if}\;y.re \leq -9.8 \cdot 10^{+117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq -8.4 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.re \leq 4.15 \cdot 10^{-69}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 2.3 \cdot 10^{+114}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (fma y.im y.im (* y.re y.re)))
        (t_1 (fma x.im (/ y.im t_0) (* y.re (/ x.re t_0)))))
   (if (<= y.re -9.8e+117)
     (/ (fma (/ x.im y.re) y.im x.re) y.re)
     (if (<= y.re -8.4e-21)
       t_1
       (if (<= y.re 4.15e-69)
         (/ (fma (/ x.re y.im) y.re x.im) y.im)
         (if (<= y.re 2.3e+114)
           t_1
           (/ (fma (/ y.im y.re) x.im x.re) y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	double t_1 = fma(x_46_im, (y_46_im / t_0), (y_46_re * (x_46_re / t_0)));
	double tmp;
	if (y_46_re <= -9.8e+117) {
		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
	} else if (y_46_re <= -8.4e-21) {
		tmp = t_1;
	} else if (y_46_re <= 4.15e-69) {
		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
	} else if (y_46_re <= 2.3e+114) {
		tmp = t_1;
	} else {
		tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))
	t_1 = fma(x_46_im, Float64(y_46_im / t_0), Float64(y_46_re * Float64(x_46_re / t_0)))
	tmp = 0.0
	if (y_46_re <= -9.8e+117)
		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
	elseif (y_46_re <= -8.4e-21)
		tmp = t_1;
	elseif (y_46_re <= 4.15e-69)
		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
	elseif (y_46_re <= 2.3e+114)
		tmp = t_1;
	else
		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$im * N[(y$46$im / t$95$0), $MachinePrecision] + N[(y$46$re * N[(x$46$re / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -9.8e+117], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -8.4e-21], t$95$1, If[LessEqual[y$46$re, 4.15e-69], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 2.3e+114], t$95$1, N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y.re \leq -8.4 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y.re \leq 4.15 \cdot 10^{-69}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\

\mathbf{elif}\;y.re \leq 2.3 \cdot 10^{+114}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -9.8000000000000002e117

    1. Initial program 34.3%

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

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      2. *-lft-identityN/A

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
      3. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right)} \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}{y.re} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)\right)}}{y.re} \]
      5. distribute-lft-outN/A

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot x.re + -1 \cdot \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
      6. +-commutativeN/A

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re} + -1 \cdot x.re\right)}}{y.re} \]
      7. distribute-rgt-inN/A

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right) \cdot -1 + \left(-1 \cdot x.re\right) \cdot -1}}{y.re} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      9. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      10. mul-1-negN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x.im \cdot y.im}{y.re}\right)\right)}\right)\right) + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      11. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.im \cdot x.im}}{y.re} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      13. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.im \cdot \frac{x.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im}{y.re} \cdot y.im} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      15. *-commutativeN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{-1 \cdot \left(-1 \cdot x.re\right)}}{y.re} \]
      16. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}}{y.re} \]
      17. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}\right)\right)}{y.re} \]
      18. remove-double-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{x.re}}{y.re} \]
      19. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}}{y.re} \]
      20. lower-/.f6486.9

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.im}{y.re}}, y.im, x.re\right)}{y.re} \]
    5. Applied rewrites86.9%

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

    if -9.8000000000000002e117 < y.re < -8.4000000000000005e-21 or 4.1500000000000002e-69 < y.re < 2.3e114

    1. Initial program 77.3%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Applied rewrites86.9%

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

    if -8.4000000000000005e-21 < y.re < 4.1500000000000002e-69

    1. Initial program 68.7%

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

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

        \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}} + \frac{x.im}{y.im}} \]
      2. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2}} \cdot y.re} + \frac{x.im}{y.im} \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}}} + \frac{x.im}{y.im} \]
      4. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im}}{y.im}} + \frac{x.im}{y.im} \]
      6. div-addN/A

        \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im} + x.im}{y.im}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{x.im + \frac{x.re \cdot y.re}{y.im}}}{y.im} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im}} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.re \cdot y.re}{y.im} + x.im}}{y.im} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.re}}{y.im} + x.im}{y.im} \]
      11. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.re}{y.im}} + x.im}{y.im} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.re}{y.im} \cdot y.re} + x.im}{y.im} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}}{y.im} \]
      14. lower-/.f6492.2

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.re}{y.im}}, y.re, x.im\right)}{y.im} \]
    5. Applied rewrites92.2%

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

    if 2.3e114 < y.re

    1. Initial program 31.8%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Applied rewrites40.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)} \]
    4. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.im}{y.re}} + x.re}{y.re} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{y.im}{y.re} \cdot x.im} + x.re}{y.re} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}}{y.re} \]
      6. lower-/.f6485.4

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{y.im}{y.re}}, x.im, x.re\right)}{y.re} \]
    6. Applied rewrites85.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -9.8 \cdot 10^{+117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq -8.4 \cdot 10^{-21}:\\ \;\;\;\;\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{elif}\;y.re \leq 4.15 \cdot 10^{-69}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 2.3 \cdot 10^{+114}:\\ \;\;\;\;\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -4.2 \cdot 10^{+39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{-60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 1.4 \cdot 10^{+105}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -4.2e+39)
   (/ (fma (/ x.im y.re) y.im x.re) y.re)
   (if (<= y.re 1.7e-60)
     (/ (fma (/ x.re y.im) y.re x.im) y.im)
     (if (<= y.re 1.4e+105)
       (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
       (/ (fma (/ y.im y.re) x.im x.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_re <= -4.2e+39) {
		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
	} else if (y_46_re <= 1.7e-60) {
		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
	} else if (y_46_re <= 1.4e+105) {
		tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else {
		tmp = fma((y_46_im / y_46_re), x_46_im, x_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_re <= -4.2e+39)
		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
	elseif (y_46_re <= 1.7e-60)
		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
	elseif (y_46_re <= 1.4e+105)
		tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	else
		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -4.2e+39], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.7e-60], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.4e+105], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -4.2 \cdot 10^{+39}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\

\mathbf{elif}\;y.re \leq 1.7 \cdot 10^{-60}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\

\mathbf{elif}\;y.re \leq 1.4 \cdot 10^{+105}:\\
\;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -4.1999999999999997e39

    1. Initial program 39.4%

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

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      2. *-lft-identityN/A

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
      3. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right)} \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}{y.re} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)\right)}}{y.re} \]
      5. distribute-lft-outN/A

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot x.re + -1 \cdot \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
      6. +-commutativeN/A

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re} + -1 \cdot x.re\right)}}{y.re} \]
      7. distribute-rgt-inN/A

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right) \cdot -1 + \left(-1 \cdot x.re\right) \cdot -1}}{y.re} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      9. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      10. mul-1-negN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x.im \cdot y.im}{y.re}\right)\right)}\right)\right) + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      11. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.im \cdot x.im}}{y.re} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      13. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.im \cdot \frac{x.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im}{y.re} \cdot y.im} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
      15. *-commutativeN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{-1 \cdot \left(-1 \cdot x.re\right)}}{y.re} \]
      16. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}}{y.re} \]
      17. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}\right)\right)}{y.re} \]
      18. remove-double-negN/A

        \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{x.re}}{y.re} \]
      19. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}}{y.re} \]
      20. lower-/.f6481.3

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.im}{y.re}}, y.im, x.re\right)}{y.re} \]
    5. Applied rewrites81.3%

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

    if -4.1999999999999997e39 < y.re < 1.70000000000000003e-60

    1. Initial program 69.9%

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

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

        \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}} + \frac{x.im}{y.im}} \]
      2. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2}} \cdot y.re} + \frac{x.im}{y.im} \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}}} + \frac{x.im}{y.im} \]
      4. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im}}{y.im}} + \frac{x.im}{y.im} \]
      6. div-addN/A

        \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im} + x.im}{y.im}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{x.im + \frac{x.re \cdot y.re}{y.im}}}{y.im} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im}} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.re \cdot y.re}{y.im} + x.im}}{y.im} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.re}}{y.im} + x.im}{y.im} \]
      11. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.re}{y.im}} + x.im}{y.im} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{x.re}{y.im} \cdot y.re} + x.im}{y.im} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}}{y.im} \]
      14. lower-/.f6488.0

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.re}{y.im}}, y.re, x.im\right)}{y.im} \]
    5. Applied rewrites88.0%

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

    if 1.70000000000000003e-60 < y.re < 1.4000000000000001e105

    1. Initial program 85.7%

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

    if 1.4000000000000001e105 < y.re

    1. Initial program 37.7%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Applied rewrites48.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)} \]
    4. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      2. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.im}{y.re}} + x.re}{y.re} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{y.im}{y.re} \cdot x.im} + x.re}{y.re} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}}{y.re} \]
      6. lower-/.f6484.6

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{y.im}{y.re}}, x.im, x.re\right)}{y.re} \]
    6. Applied rewrites84.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -4.2 \cdot 10^{+39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{-60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 1.4 \cdot 10^{+105}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 66.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\ \mathbf{if}\;y.re \leq -4.6 \cdot 10^{+86}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\ \;\;\;\;\frac{x.re}{t\_0} \cdot y.re\\ \mathbf{elif}\;y.re \leq 2.8 \cdot 10^{-11}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \frac{y.re}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (fma y.im y.im (* y.re y.re))))
   (if (<= y.re -4.6e+86)
     (/ x.re y.re)
     (if (<= y.re -9.5e-21)
       (* (/ x.re t_0) y.re)
       (if (<= y.re 2.8e-11)
         (/ x.im y.im)
         (if (<= y.re 5.8e+115) (* x.re (/ y.re t_0)) (/ x.re y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	double tmp;
	if (y_46_re <= -4.6e+86) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= -9.5e-21) {
		tmp = (x_46_re / t_0) * y_46_re;
	} else if (y_46_re <= 2.8e-11) {
		tmp = x_46_im / y_46_im;
	} else if (y_46_re <= 5.8e+115) {
		tmp = x_46_re * (y_46_re / t_0);
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))
	tmp = 0.0
	if (y_46_re <= -4.6e+86)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= -9.5e-21)
		tmp = Float64(Float64(x_46_re / t_0) * y_46_re);
	elseif (y_46_re <= 2.8e-11)
		tmp = Float64(x_46_im / y_46_im);
	elseif (y_46_re <= 5.8e+115)
		tmp = Float64(x_46_re * Float64(y_46_re / t_0));
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -4.6e+86], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -9.5e-21], N[(N[(x$46$re / t$95$0), $MachinePrecision] * y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2.8e-11], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 5.8e+115], N[(x$46$re * N[(y$46$re / t$95$0), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
\mathbf{if}\;y.re \leq -4.6 \cdot 10^{+86}:\\
\;\;\;\;\frac{x.re}{y.re}\\

\mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\
\;\;\;\;\frac{x.re}{t\_0} \cdot y.re\\

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

\mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\
\;\;\;\;x.re \cdot \frac{y.re}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -4.59999999999999979e86 or 5.80000000000000009e115 < y.re

    1. Initial program 32.7%

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

      \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f6472.6

        \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
    5. Applied rewrites72.6%

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

    if -4.59999999999999979e86 < y.re < -9.4999999999999994e-21

    1. Initial program 74.8%

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

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

        \[\leadsto \frac{\color{blue}{y.re \cdot x.re}}{{y.im}^{2} + {y.re}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{y.re \cdot \frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \cdot y.re \]
      6. unpow2N/A

        \[\leadsto \frac{x.re}{\color{blue}{y.im \cdot y.im} + {y.re}^{2}} \cdot y.re \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}} \cdot y.re \]
      8. unpow2N/A

        \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
      9. lower-*.f6458.5

        \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
    5. Applied rewrites58.5%

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

    if -9.4999999999999994e-21 < y.re < 2.8e-11

    1. Initial program 70.2%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
    4. Step-by-step derivation
      1. lower-/.f6478.8

        \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
    5. Applied rewrites78.8%

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

    if 2.8e-11 < y.re < 5.80000000000000009e115

    1. Initial program 84.2%

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

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

        \[\leadsto \frac{\color{blue}{y.re \cdot x.re}}{{y.im}^{2} + {y.re}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{y.re \cdot \frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \cdot y.re \]
      6. unpow2N/A

        \[\leadsto \frac{x.re}{\color{blue}{y.im \cdot y.im} + {y.re}^{2}} \cdot y.re \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}} \cdot y.re \]
      8. unpow2N/A

        \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
      9. lower-*.f6467.7

        \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
    5. Applied rewrites67.7%

      \[\leadsto \color{blue}{\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re} \]
    6. Step-by-step derivation
      1. Applied rewrites68.8%

        \[\leadsto x.re \cdot \color{blue}{\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    7. Recombined 4 regimes into one program.
    8. Final simplification73.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -4.6 \cdot 10^{+86}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\ \;\;\;\;\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re\\ \mathbf{elif}\;y.re \leq 2.8 \cdot 10^{-11}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 4: 66.4% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{if}\;y.re \leq -4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 2.8 \cdot 10^{-11}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
    (FPCore (x.re x.im y.re y.im)
     :precision binary64
     (let* ((t_0 (* x.re (/ y.re (fma y.im y.im (* y.re y.re))))))
       (if (<= y.re -4.4e+96)
         (/ x.re y.re)
         (if (<= y.re -9.5e-21)
           t_0
           (if (<= y.re 2.8e-11)
             (/ x.im y.im)
             (if (<= y.re 5.8e+115) t_0 (/ x.re y.re)))))))
    double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
    	double t_0 = x_46_re * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
    	double tmp;
    	if (y_46_re <= -4.4e+96) {
    		tmp = x_46_re / y_46_re;
    	} else if (y_46_re <= -9.5e-21) {
    		tmp = t_0;
    	} else if (y_46_re <= 2.8e-11) {
    		tmp = x_46_im / y_46_im;
    	} else if (y_46_re <= 5.8e+115) {
    		tmp = t_0;
    	} else {
    		tmp = x_46_re / y_46_re;
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im, y_46_re, y_46_im)
    	t_0 = Float64(x_46_re * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))))
    	tmp = 0.0
    	if (y_46_re <= -4.4e+96)
    		tmp = Float64(x_46_re / y_46_re);
    	elseif (y_46_re <= -9.5e-21)
    		tmp = t_0;
    	elseif (y_46_re <= 2.8e-11)
    		tmp = Float64(x_46_im / y_46_im);
    	elseif (y_46_re <= 5.8e+115)
    		tmp = t_0;
    	else
    		tmp = Float64(x_46_re / y_46_re);
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -4.4e+96], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -9.5e-21], t$95$0, If[LessEqual[y$46$re, 2.8e-11], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 5.8e+115], t$95$0, N[(x$46$re / y$46$re), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
    \mathbf{if}\;y.re \leq -4.4 \cdot 10^{+96}:\\
    \;\;\;\;\frac{x.re}{y.re}\\
    
    \mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y.re \leq 2.8 \cdot 10^{-11}:\\
    \;\;\;\;\frac{x.im}{y.im}\\
    
    \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x.re}{y.re}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y.re < -4.3999999999999998e96 or 5.80000000000000009e115 < y.re

      1. Initial program 33.1%

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

        \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
      4. Step-by-step derivation
        1. lower-/.f6472.2

          \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
      5. Applied rewrites72.2%

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

      if -4.3999999999999998e96 < y.re < -9.4999999999999994e-21 or 2.8e-11 < y.re < 5.80000000000000009e115

      1. Initial program 79.3%

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

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

          \[\leadsto \frac{\color{blue}{y.re \cdot x.re}}{{y.im}^{2} + {y.re}^{2}} \]
        2. associate-/l*N/A

          \[\leadsto \color{blue}{y.re \cdot \frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
        4. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}} \cdot y.re} \]
        5. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2} + {y.re}^{2}}} \cdot y.re \]
        6. unpow2N/A

          \[\leadsto \frac{x.re}{\color{blue}{y.im \cdot y.im} + {y.re}^{2}} \cdot y.re \]
        7. lower-fma.f64N/A

          \[\leadsto \frac{x.re}{\color{blue}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}} \cdot y.re \]
        8. unpow2N/A

          \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
        9. lower-*.f6464.7

          \[\leadsto \frac{x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{y.re \cdot y.re}\right)} \cdot y.re \]
      5. Applied rewrites64.7%

        \[\leadsto \color{blue}{\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re} \]
      6. Step-by-step derivation
        1. Applied rewrites65.3%

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

        if -9.4999999999999994e-21 < y.re < 2.8e-11

        1. Initial program 70.2%

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

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        4. Step-by-step derivation
          1. lower-/.f6478.8

            \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        5. Applied rewrites78.8%

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
      7. Recombined 3 regimes into one program.
      8. Final simplification73.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -9.5 \cdot 10^{-21}:\\ \;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.re \leq 2.8 \cdot 10^{-11}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{+115}:\\ \;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 5: 69.7% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21} \lor \neg \left(y.re \leq 8.5 \cdot 10^{-23}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \end{array} \]
      (FPCore (x.re x.im y.re y.im)
       :precision binary64
       (if (or (<= y.re -9.6e-21) (not (<= y.re 8.5e-23)))
         (/ (fma (/ y.im y.re) x.im x.re) y.re)
         (/ x.im 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_re <= -9.6e-21) || !(y_46_re <= 8.5e-23)) {
      		tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
      	} else {
      		tmp = x_46_im / 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_re <= -9.6e-21) || !(y_46_re <= 8.5e-23))
      		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
      	else
      		tmp = Float64(x_46_im / y_46_im);
      	end
      	return tmp
      end
      
      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -9.6e-21], N[Not[LessEqual[y$46$re, 8.5e-23]], $MachinePrecision]], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21} \lor \neg \left(y.re \leq 8.5 \cdot 10^{-23}\right):\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{x.im}{y.im}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y.re < -9.5999999999999997e-21 or 8.4999999999999996e-23 < y.re

        1. Initial program 54.5%

          \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
        2. Add Preprocessing
        3. Applied rewrites60.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)} \]
        4. Taylor expanded in y.re around inf

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          2. +-commutativeN/A

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

            \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.im}{y.re}} + x.re}{y.re} \]
          4. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{y.im}{y.re} \cdot x.im} + x.re}{y.re} \]
          5. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}}{y.re} \]
          6. lower-/.f6473.3

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{y.im}{y.re}}, x.im, x.re\right)}{y.re} \]
        6. Applied rewrites73.3%

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

        if -9.5999999999999997e-21 < y.re < 8.4999999999999996e-23

        1. Initial program 69.7%

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

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        4. Step-by-step derivation
          1. lower-/.f6480.0

            \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        5. Applied rewrites80.0%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21} \lor \neg \left(y.re \leq 8.5 \cdot 10^{-23}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 6: 77.1% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -4.2 \cdot 10^{+39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-23}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
      (FPCore (x.re x.im y.re y.im)
       :precision binary64
       (if (<= y.re -4.2e+39)
         (/ (fma (/ x.im y.re) y.im x.re) y.re)
         (if (<= y.re 8.5e-23)
           (/ (fma (/ x.re y.im) y.re x.im) y.im)
           (/ (fma (/ y.im y.re) x.im x.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_re <= -4.2e+39) {
      		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
      	} else if (y_46_re <= 8.5e-23) {
      		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
      	} else {
      		tmp = fma((y_46_im / y_46_re), x_46_im, x_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_re <= -4.2e+39)
      		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
      	elseif (y_46_re <= 8.5e-23)
      		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
      	else
      		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
      	end
      	return tmp
      end
      
      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -4.2e+39], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 8.5e-23], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y.re \leq -4.2 \cdot 10^{+39}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
      
      \mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-23}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y.re < -4.1999999999999997e39

        1. Initial program 39.4%

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

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        4. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          2. *-lft-identityN/A

            \[\leadsto \frac{\color{blue}{1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
          3. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right)} \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}{y.re} \]
          4. associate-*r*N/A

            \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)\right)}}{y.re} \]
          5. distribute-lft-outN/A

            \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot x.re + -1 \cdot \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
          6. +-commutativeN/A

            \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re} + -1 \cdot x.re\right)}}{y.re} \]
          7. distribute-rgt-inN/A

            \[\leadsto \frac{\color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right) \cdot -1 + \left(-1 \cdot x.re\right) \cdot -1}}{y.re} \]
          8. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          9. mul-1-negN/A

            \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          10. mul-1-negN/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x.im \cdot y.im}{y.re}\right)\right)}\right)\right) + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          11. remove-double-negN/A

            \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          12. *-commutativeN/A

            \[\leadsto \frac{\frac{\color{blue}{y.im \cdot x.im}}{y.re} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          13. associate-/l*N/A

            \[\leadsto \frac{\color{blue}{y.im \cdot \frac{x.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          14. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{x.im}{y.re} \cdot y.im} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          15. *-commutativeN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{-1 \cdot \left(-1 \cdot x.re\right)}}{y.re} \]
          16. mul-1-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}}{y.re} \]
          17. mul-1-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}\right)\right)}{y.re} \]
          18. remove-double-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{x.re}}{y.re} \]
          19. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}}{y.re} \]
          20. lower-/.f6481.3

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.im}{y.re}}, y.im, x.re\right)}{y.re} \]
        5. Applied rewrites81.3%

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

        if -4.1999999999999997e39 < y.re < 8.4999999999999996e-23

        1. Initial program 70.7%

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

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

            \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}} + \frac{x.im}{y.im}} \]
          2. associate-*l/N/A

            \[\leadsto \color{blue}{\frac{x.re}{{y.im}^{2}} \cdot y.re} + \frac{x.im}{y.im} \]
          3. associate-*l/N/A

            \[\leadsto \color{blue}{\frac{x.re \cdot y.re}{{y.im}^{2}}} + \frac{x.im}{y.im} \]
          4. unpow2N/A

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

            \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im}}{y.im}} + \frac{x.im}{y.im} \]
          6. div-addN/A

            \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re}{y.im} + x.im}{y.im}} \]
          7. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{x.im + \frac{x.re \cdot y.re}{y.im}}}{y.im} \]
          8. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im}} \]
          9. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{x.re \cdot y.re}{y.im} + x.im}}{y.im} \]
          10. *-commutativeN/A

            \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.re}}{y.im} + x.im}{y.im} \]
          11. associate-/l*N/A

            \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.re}{y.im}} + x.im}{y.im} \]
          12. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{x.re}{y.im} \cdot y.re} + x.im}{y.im} \]
          13. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}}{y.im} \]
          14. lower-/.f6487.1

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.re}{y.im}}, y.re, x.im\right)}{y.im} \]
        5. Applied rewrites87.1%

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

        if 8.4999999999999996e-23 < y.re

        1. Initial program 63.1%

          \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
        2. Add Preprocessing
        3. Applied rewrites69.1%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)} \]
        4. Taylor expanded in y.re around inf

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          2. +-commutativeN/A

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

            \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.im}{y.re}} + x.re}{y.re} \]
          4. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{y.im}{y.re} \cdot x.im} + x.re}{y.re} \]
          5. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}}{y.re} \]
          6. lower-/.f6473.4

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{y.im}{y.re}}, x.im, x.re\right)}{y.re} \]
        6. Applied rewrites73.4%

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

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

      Alternative 7: 69.9% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-23}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
      (FPCore (x.re x.im y.re y.im)
       :precision binary64
       (if (<= y.re -9.6e-21)
         (/ (fma (/ x.im y.re) y.im x.re) y.re)
         (if (<= y.re 8.5e-23)
           (/ x.im y.im)
           (/ (fma (/ y.im y.re) x.im x.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_re <= -9.6e-21) {
      		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
      	} else if (y_46_re <= 8.5e-23) {
      		tmp = x_46_im / y_46_im;
      	} else {
      		tmp = fma((y_46_im / y_46_re), x_46_im, x_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_re <= -9.6e-21)
      		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
      	elseif (y_46_re <= 8.5e-23)
      		tmp = Float64(x_46_im / y_46_im);
      	else
      		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
      	end
      	return tmp
      end
      
      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -9.6e-21], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 8.5e-23], N[(x$46$im / y$46$im), $MachinePrecision], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
      
      \mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-23}:\\
      \;\;\;\;\frac{x.im}{y.im}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y.re < -9.5999999999999997e-21

        1. Initial program 47.0%

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

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        4. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          2. *-lft-identityN/A

            \[\leadsto \frac{\color{blue}{1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
          3. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right)} \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)}{y.re} \]
          4. associate-*r*N/A

            \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \left(x.re + \frac{x.im \cdot y.im}{y.re}\right)\right)}}{y.re} \]
          5. distribute-lft-outN/A

            \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot x.re + -1 \cdot \frac{x.im \cdot y.im}{y.re}\right)}}{y.re} \]
          6. +-commutativeN/A

            \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re} + -1 \cdot x.re\right)}}{y.re} \]
          7. distribute-rgt-inN/A

            \[\leadsto \frac{\color{blue}{\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right) \cdot -1 + \left(-1 \cdot x.re\right) \cdot -1}}{y.re} \]
          8. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          9. mul-1-negN/A

            \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{x.im \cdot y.im}{y.re}\right)\right)} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          10. mul-1-negN/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x.im \cdot y.im}{y.re}\right)\right)}\right)\right) + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          11. remove-double-negN/A

            \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          12. *-commutativeN/A

            \[\leadsto \frac{\frac{\color{blue}{y.im \cdot x.im}}{y.re} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          13. associate-/l*N/A

            \[\leadsto \frac{\color{blue}{y.im \cdot \frac{x.im}{y.re}} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          14. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{x.im}{y.re} \cdot y.im} + \left(-1 \cdot x.re\right) \cdot -1}{y.re} \]
          15. *-commutativeN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{-1 \cdot \left(-1 \cdot x.re\right)}}{y.re} \]
          16. mul-1-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}}{y.re} \]
          17. mul-1-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}\right)\right)}{y.re} \]
          18. remove-double-negN/A

            \[\leadsto \frac{\frac{x.im}{y.re} \cdot y.im + \color{blue}{x.re}}{y.re} \]
          19. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}}{y.re} \]
          20. lower-/.f6474.4

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x.im}{y.re}}, y.im, x.re\right)}{y.re} \]
        5. Applied rewrites74.4%

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

        if -9.5999999999999997e-21 < y.re < 8.4999999999999996e-23

        1. Initial program 69.7%

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

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        4. Step-by-step derivation
          1. lower-/.f6480.0

            \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        5. Applied rewrites80.0%

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

        if 8.4999999999999996e-23 < y.re

        1. Initial program 63.1%

          \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
        2. Add Preprocessing
        3. Applied rewrites69.1%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)} \]
        4. Taylor expanded in y.re around inf

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          2. +-commutativeN/A

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

            \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.im}{y.re}} + x.re}{y.re} \]
          4. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\frac{y.im}{y.re} \cdot x.im} + x.re}{y.re} \]
          5. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}}{y.re} \]
          6. lower-/.f6473.4

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{y.im}{y.re}}, x.im, x.re\right)}{y.re} \]
        6. Applied rewrites73.4%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -9.6 \cdot 10^{-21}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-23}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 8: 63.6% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -3 \cdot 10^{+50} \lor \neg \left(y.re \leq 2.1 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \end{array} \]
      (FPCore (x.re x.im y.re y.im)
       :precision binary64
       (if (or (<= y.re -3e+50) (not (<= y.re 2.1e-9))) (/ x.re y.re) (/ x.im 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_re <= -3e+50) || !(y_46_re <= 2.1e-9)) {
      		tmp = x_46_re / y_46_re;
      	} else {
      		tmp = x_46_im / y_46_im;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x_46re, x_46im, y_46re, y_46im)
      use fmin_fmax_functions
          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_46re <= (-3d+50)) .or. (.not. (y_46re <= 2.1d-9))) then
              tmp = x_46re / y_46re
          else
              tmp = x_46im / 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_re <= -3e+50) || !(y_46_re <= 2.1e-9)) {
      		tmp = x_46_re / y_46_re;
      	} else {
      		tmp = x_46_im / y_46_im;
      	}
      	return tmp;
      }
      
      def code(x_46_re, x_46_im, y_46_re, y_46_im):
      	tmp = 0
      	if (y_46_re <= -3e+50) or not (y_46_re <= 2.1e-9):
      		tmp = x_46_re / y_46_re
      	else:
      		tmp = x_46_im / 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_re <= -3e+50) || !(y_46_re <= 2.1e-9))
      		tmp = Float64(x_46_re / y_46_re);
      	else
      		tmp = Float64(x_46_im / 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_re <= -3e+50) || ~((y_46_re <= 2.1e-9)))
      		tmp = x_46_re / y_46_re;
      	else
      		tmp = x_46_im / y_46_im;
      	end
      	tmp_2 = tmp;
      end
      
      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -3e+50], N[Not[LessEqual[y$46$re, 2.1e-9]], $MachinePrecision]], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y.re \leq -3 \cdot 10^{+50} \lor \neg \left(y.re \leq 2.1 \cdot 10^{-9}\right):\\
      \;\;\;\;\frac{x.re}{y.re}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{x.im}{y.im}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y.re < -2.9999999999999998e50 or 2.10000000000000019e-9 < y.re

        1. Initial program 50.1%

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

          \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
        4. Step-by-step derivation
          1. lower-/.f6464.8

            \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
        5. Applied rewrites64.8%

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

        if -2.9999999999999998e50 < y.re < 2.10000000000000019e-9

        1. Initial program 71.3%

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

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        4. Step-by-step derivation
          1. lower-/.f6473.3

            \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
        5. Applied rewrites73.3%

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

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

      Alternative 9: 43.2% accurate, 3.2× speedup?

      \[\begin{array}{l} \\ \frac{x.im}{y.im} \end{array} \]
      (FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.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_im;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x_46re, x_46im, y_46re, y_46im)
      use fmin_fmax_functions
          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_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_im;
      }
      
      def code(x_46_re, x_46_im, y_46_re, y_46_im):
      	return x_46_im / y_46_im
      
      function code(x_46_re, x_46_im, y_46_re, y_46_im)
      	return Float64(x_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_im;
      end
      
      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{x.im}{y.im}
      \end{array}
      
      Derivation
      1. Initial program 61.5%

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

        \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
      4. Step-by-step derivation
        1. lower-/.f6448.8

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
      5. Applied rewrites48.8%

        \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
      6. Final simplification48.8%

        \[\leadsto \frac{x.im}{y.im} \]
      7. Add Preprocessing

      Reproduce

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