_divideComplex, imaginary part

Percentage Accurate: 62.0% → 84.0%
Time: 3.6s
Alternatives: 9
Speedup: 1.7×

Specification

?
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
(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));
}
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_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]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}

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: 62.0% accurate, 1.0× speedup?

\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
(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));
}
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_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]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}

Alternative 1: 84.0% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re}\\ t_1 := x.im \cdot y.re - x.re \cdot y.im\\ t_2 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{t\_1}, \frac{y.re \cdot y.re}{t\_1}\right)}\\ \mathbf{if}\;y.re \leq -5 \cdot 10^{+146}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq -1 \cdot 10^{-107}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y.re \leq 2.2 \cdot 10^{-98}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 2.25 \cdot 10^{+112}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/
          (+
           x.im
           (*
            y.im
            (fma
             -1.0
             (/ x.re y.re)
             (* -1.0 (/ (* x.im y.im) (pow y.re 2.0))))))
          y.re))
        (t_1 (- (* x.im y.re) (* x.re y.im)))
        (t_2 (/ 1.0 (fma y.im (/ y.im t_1) (/ (* y.re y.re) t_1)))))
   (if (<= y.re -5e+146)
     t_0
     (if (<= y.re -1e-107)
       t_2
       (if (<= y.re 2.2e-98)
         (/ (- (/ (* y.re x.im) y.im) x.re) y.im)
         (if (<= y.re 2.25e+112) t_2 t_0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (x_46_im + (y_46_im * fma(-1.0, (x_46_re / y_46_re), (-1.0 * ((x_46_im * y_46_im) / pow(y_46_re, 2.0)))))) / y_46_re;
	double t_1 = (x_46_im * y_46_re) - (x_46_re * y_46_im);
	double t_2 = 1.0 / fma(y_46_im, (y_46_im / t_1), ((y_46_re * y_46_re) / t_1));
	double tmp;
	if (y_46_re <= -5e+146) {
		tmp = t_0;
	} else if (y_46_re <= -1e-107) {
		tmp = t_2;
	} else if (y_46_re <= 2.2e-98) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else if (y_46_re <= 2.25e+112) {
		tmp = t_2;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(x_46_im + Float64(y_46_im * fma(-1.0, Float64(x_46_re / y_46_re), Float64(-1.0 * Float64(Float64(x_46_im * y_46_im) / (y_46_re ^ 2.0)))))) / y_46_re)
	t_1 = Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im))
	t_2 = Float64(1.0 / fma(y_46_im, Float64(y_46_im / t_1), Float64(Float64(y_46_re * y_46_re) / t_1)))
	tmp = 0.0
	if (y_46_re <= -5e+146)
		tmp = t_0;
	elseif (y_46_re <= -1e-107)
		tmp = t_2;
	elseif (y_46_re <= 2.2e-98)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
	elseif (y_46_re <= 2.25e+112)
		tmp = t_2;
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + N[(y$46$im * N[(-1.0 * N[(x$46$re / y$46$re), $MachinePrecision] + N[(-1.0 * N[(N[(x$46$im * y$46$im), $MachinePrecision] / N[Power[y$46$re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(y$46$im * N[(y$46$im / t$95$1), $MachinePrecision] + N[(N[(y$46$re * y$46$re), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -5e+146], t$95$0, If[LessEqual[y$46$re, -1e-107], t$95$2, If[LessEqual[y$46$re, 2.2e-98], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 2.25e+112], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
t_0 := \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re}\\
t_1 := x.im \cdot y.re - x.re \cdot y.im\\
t_2 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{t\_1}, \frac{y.re \cdot y.re}{t\_1}\right)}\\
\mathbf{if}\;y.re \leq -5 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq -1 \cdot 10^{-107}:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;y.re \leq 2.25 \cdot 10^{+112}:\\
\;\;\;\;t\_2\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -4.9999999999999999e146 or 2.24999999999999995e112 < y.re

    1. Initial program 62.0%

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

      \[\leadsto \frac{\color{blue}{x.im \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
    3. Step-by-step derivation
      1. lower-*.f6439.9%

        \[\leadsto \frac{x.im \cdot \color{blue}{y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied rewrites39.9%

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

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

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

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

        \[\leadsto \frac{y.re \cdot \color{blue}{x.im}}{\mathsf{Rewrite=>}\left(lift-+.f64, \left(y.re \cdot y.re + y.im \cdot y.im\right)\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot \color{blue}{x.im}}{\mathsf{Rewrite=>}\left(+-commutative, \left(y.im \cdot y.im + y.re \cdot y.re\right)\right)} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot \color{blue}{x.im}}{\mathsf{Rewrite=>}\left(lift-*.f64, \left(y.im \cdot y.im\right)\right) + y.re \cdot y.re} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot \color{blue}{x.im}}{\mathsf{Rewrite<=}\left(lift-fma.f64, \left(\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)\right)} \]
    6. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{y.re \cdot x.im}{\left(y.im \cdot y.im\right) \cdot \frac{1}{y.re} + y.re}}{y.re}} \]
    8. Applied rewrites44.6%

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

      \[\leadsto \frac{\color{blue}{x.im + y.im \cdot \left(-1 \cdot \frac{x.re}{y.re} + -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}}{y.re} \]
    10. Step-by-step derivation
      1. lower-+.f64N/A

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

        \[\leadsto \frac{x.im + y.im \cdot \color{blue}{\left(-1 \cdot \frac{x.re}{y.re} + -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}}{y.re} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \color{blue}{\frac{x.re}{y.re}}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{\color{blue}{y.re}}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
      8. lower-pow.f6446.1%

        \[\leadsto \frac{x.im + y.im \cdot \mathsf{fma}\left(-1, \frac{x.re}{y.re}, -1 \cdot \frac{x.im \cdot y.im}{{y.re}^{2}}\right)}{y.re} \]
    11. Applied rewrites46.1%

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

    if -4.9999999999999999e146 < y.re < -1e-107 or 2.19999999999999996e-98 < y.re < 2.24999999999999995e112

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.8%

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      15. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      16. sqr-abs-revN/A

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.8%

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
    3. Applied rewrites61.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}{y.re \cdot x.im - y.im \cdot x.re}}} \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left(\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}{\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)}}} \]
      3. frac-2negN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      5. lift-fma.f64N/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im} + y.re \cdot y.re}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(y.re\right)\right) \cdot y.re}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{\color{blue}{y.re \cdot y.re}}{y.re \cdot x.im - y.im \cdot x.re}} \]
      17. lift-*.f64N/A

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{\color{blue}{y.re \cdot y.re}}{y.re \cdot x.im - y.im \cdot x.re}} \]
      18. /-rgt-identityN/A

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

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

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{y.re \cdot y.re}{\color{blue}{y.re \cdot x.im - y.im \cdot x.re}}} \]
    5. Applied rewrites67.9%

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

    if -1e-107 < y.re < 2.19999999999999996e-98

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

Alternative 2: 84.0% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\ t_1 := x.im \cdot y.re - x.re \cdot y.im\\ t_2 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{t\_1}, \frac{y.re \cdot y.re}{t\_1}\right)}\\ \mathbf{if}\;y.re \leq -4.8 \cdot 10^{+146}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq -1 \cdot 10^{-107}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y.re \leq 2.2 \cdot 10^{-98}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+109}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (+ x.im (* -1.0 (/ (* x.re y.im) y.re))) y.re))
        (t_1 (- (* x.im y.re) (* x.re y.im)))
        (t_2 (/ 1.0 (fma y.im (/ y.im t_1) (/ (* y.re y.re) t_1)))))
   (if (<= y.re -4.8e+146)
     t_0
     (if (<= y.re -1e-107)
       t_2
       (if (<= y.re 2.2e-98)
         (/ (- (/ (* y.re x.im) y.im) x.re) y.im)
         (if (<= y.re 6.8e+109) t_2 t_0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re;
	double t_1 = (x_46_im * y_46_re) - (x_46_re * y_46_im);
	double t_2 = 1.0 / fma(y_46_im, (y_46_im / t_1), ((y_46_re * y_46_re) / t_1));
	double tmp;
	if (y_46_re <= -4.8e+146) {
		tmp = t_0;
	} else if (y_46_re <= -1e-107) {
		tmp = t_2;
	} else if (y_46_re <= 2.2e-98) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else if (y_46_re <= 6.8e+109) {
		tmp = t_2;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(x_46_im + Float64(-1.0 * Float64(Float64(x_46_re * y_46_im) / y_46_re))) / y_46_re)
	t_1 = Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im))
	t_2 = Float64(1.0 / fma(y_46_im, Float64(y_46_im / t_1), Float64(Float64(y_46_re * y_46_re) / t_1)))
	tmp = 0.0
	if (y_46_re <= -4.8e+146)
		tmp = t_0;
	elseif (y_46_re <= -1e-107)
		tmp = t_2;
	elseif (y_46_re <= 2.2e-98)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
	elseif (y_46_re <= 6.8e+109)
		tmp = t_2;
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + N[(-1.0 * N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(y$46$im * N[(y$46$im / t$95$1), $MachinePrecision] + N[(N[(y$46$re * y$46$re), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -4.8e+146], t$95$0, If[LessEqual[y$46$re, -1e-107], t$95$2, If[LessEqual[y$46$re, 2.2e-98], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.8e+109], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
t_0 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\
t_1 := x.im \cdot y.re - x.re \cdot y.im\\
t_2 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{t\_1}, \frac{y.re \cdot y.re}{t\_1}\right)}\\
\mathbf{if}\;y.re \leq -4.8 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq -1 \cdot 10^{-107}:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+109}:\\
\;\;\;\;t\_2\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -4.8000000000000004e146 or 6.80000000000000013e109 < y.re

    1. Initial program 62.0%

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8%

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    4. Applied rewrites51.8%

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

    if -4.8000000000000004e146 < y.re < -1e-107 or 2.19999999999999996e-98 < y.re < 6.80000000000000013e109

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.8%

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      15. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      16. sqr-abs-revN/A

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.8%

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
    3. Applied rewrites61.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}{y.re \cdot x.im - y.im \cdot x.re}}} \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left(\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}{\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)}}} \]
      3. frac-2negN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      5. lift-fma.f64N/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im} + y.re \cdot y.re}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(y.re\right)\right) \cdot y.re}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y.re \cdot x.im - y.im \cdot x.re\right)\right)\right)\right)}} \]
      9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{\color{blue}{y.re \cdot y.re}}{y.re \cdot x.im - y.im \cdot x.re}} \]
      17. lift-*.f64N/A

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{\color{blue}{y.re \cdot y.re}}{y.re \cdot x.im - y.im \cdot x.re}} \]
      18. /-rgt-identityN/A

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

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

        \[\leadsto \frac{1}{y.im \cdot \frac{y.im}{y.re \cdot x.im - y.im \cdot x.re} + \frac{y.re \cdot y.re}{\color{blue}{y.re \cdot x.im - y.im \cdot x.re}}} \]
    5. Applied rewrites67.9%

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

    if -1e-107 < y.re < 2.19999999999999996e-98

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

Alternative 3: 80.8% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{y.re}, y.re\right) \cdot \frac{y.re}{x.im \cdot y.re - x.re \cdot y.im}}\\ t_1 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\ \mathbf{if}\;y.re \leq -5 \cdot 10^{+146}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.re \leq -8 \cdot 10^{-17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 4.2 \cdot 10^{-95}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+109}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/
          1.0
          (*
           (fma y.im (/ y.im y.re) y.re)
           (/ y.re (- (* x.im y.re) (* x.re y.im))))))
        (t_1 (/ (+ x.im (* -1.0 (/ (* x.re y.im) y.re))) y.re)))
   (if (<= y.re -5e+146)
     t_1
     (if (<= y.re -8e-17)
       t_0
       (if (<= y.re 4.2e-95)
         (/ (- (/ (* y.re x.im) y.im) x.re) y.im)
         (if (<= y.re 6.8e+109) 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 = 1.0 / (fma(y_46_im, (y_46_im / y_46_re), y_46_re) * (y_46_re / ((x_46_im * y_46_re) - (x_46_re * y_46_im))));
	double t_1 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re;
	double tmp;
	if (y_46_re <= -5e+146) {
		tmp = t_1;
	} else if (y_46_re <= -8e-17) {
		tmp = t_0;
	} else if (y_46_re <= 4.2e-95) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else if (y_46_re <= 6.8e+109) {
		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(1.0 / Float64(fma(y_46_im, Float64(y_46_im / y_46_re), y_46_re) * Float64(y_46_re / Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)))))
	t_1 = Float64(Float64(x_46_im + Float64(-1.0 * Float64(Float64(x_46_re * y_46_im) / y_46_re))) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -5e+146)
		tmp = t_1;
	elseif (y_46_re <= -8e-17)
		tmp = t_0;
	elseif (y_46_re <= 4.2e-95)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
	elseif (y_46_re <= 6.8e+109)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 / N[(N[(y$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + y$46$re), $MachinePrecision] * N[(y$46$re / N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im + N[(-1.0 * N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -5e+146], t$95$1, If[LessEqual[y$46$re, -8e-17], t$95$0, If[LessEqual[y$46$re, 4.2e-95], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.8e+109], t$95$0, t$95$1]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\mathsf{fma}\left(y.im, \frac{y.im}{y.re}, y.re\right) \cdot \frac{y.re}{x.im \cdot y.re - x.re \cdot y.im}}\\
t_1 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{if}\;y.re \leq -5 \cdot 10^{+146}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -4.9999999999999999e146 or 6.80000000000000013e109 < y.re

    1. Initial program 62.0%

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8%

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    4. Applied rewrites51.8%

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

    if -4.9999999999999999e146 < y.re < -8.00000000000000057e-17 or 4.2e-95 < y.re < 6.80000000000000013e109

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.8%

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      15. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      16. sqr-abs-revN/A

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.8%

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
    3. Applied rewrites61.8%

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

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

    if -8.00000000000000057e-17 < y.re < 4.2e-95

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

Alternative 4: 79.5% accurate, 0.7× speedup?

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

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

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

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -8.49999999999999979e22 or 6.4000000000000002e109 < y.re

    1. Initial program 62.0%

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8%

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    4. Applied rewrites51.8%

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

    if -8.49999999999999979e22 < y.re < 2.50000000000000009e-98

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

    if 2.50000000000000009e-98 < y.re < 6.4000000000000002e109

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re - \left(\mathsf{neg}\left(y.im \cdot y.im\right)\right)}} \]
      3. sub-flipN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y.im \cdot y.im\right)\right)\right)\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.im \cdot y.im}\right)\right)\right)\right)} \]
      5. sqr-abs-revN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.im\right| \cdot \left|y.im\right|}\right)\right)\right)\right)} \]
      6. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{\left(\mathsf{neg}\left(\left|y.im\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)}} \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)}} \]
      9. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right)}} \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.im\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.im\right|\right)\right)\right)\right)}\right)\right)} \]
      13. sqr-neg-revN/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.im\right| \cdot \left|y.im\right|}\right)\right)\right)\right)} \]
      14. sqr-abs-revN/A

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

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \]
      17. lower-fma.f6462.0%

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

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

Alternative 5: 77.3% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\ \mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 5.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (+ x.im (* -1.0 (/ (* x.re y.im) y.re))) y.re)))
   (if (<= y.re -8.5e+22)
     t_0
     (if (<= y.re 5.5e+17) (/ (- (/ (* y.re x.im) y.im) x.re) y.im) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re;
	double tmp;
	if (y_46_re <= -8.5e+22) {
		tmp = t_0;
	} else if (y_46_re <= 5.5e+17) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (x_46im + ((-1.0d0) * ((x_46re * y_46im) / y_46re))) / y_46re
    if (y_46re <= (-8.5d+22)) then
        tmp = t_0
    else if (y_46re <= 5.5d+17) then
        tmp = (((y_46re * x_46im) / y_46im) - x_46re) / y_46im
    else
        tmp = t_0
    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 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re;
	double tmp;
	if (y_46_re <= -8.5e+22) {
		tmp = t_0;
	} else if (y_46_re <= 5.5e+17) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re
	tmp = 0
	if y_46_re <= -8.5e+22:
		tmp = t_0
	elif y_46_re <= 5.5e+17:
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(x_46_im + Float64(-1.0 * Float64(Float64(x_46_re * y_46_im) / y_46_re))) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -8.5e+22)
		tmp = t_0;
	elseif (y_46_re <= 5.5e+17)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (x_46_im + (-1.0 * ((x_46_re * y_46_im) / y_46_re))) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -8.5e+22)
		tmp = t_0;
	elseif (y_46_re <= 5.5e+17)
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + N[(-1.0 * N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -8.5e+22], t$95$0, If[LessEqual[y$46$re, 5.5e+17], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -8.49999999999999979e22 or 5.5e17 < y.re

    1. Initial program 62.0%

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8%

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    4. Applied rewrites51.8%

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

    if -8.49999999999999979e22 < y.re < 5.5e17

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

Alternative 6: 74.2% accurate, 1.0× speedup?

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

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -9.99999999999999946e33 or 5.5e17 < y.re

    1. Initial program 62.0%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6442.8%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites42.8%

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

    if -9.99999999999999946e33 < y.re < 5.5e17

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      4. lift-*.f64N/A

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

        \[\leadsto \frac{x.im \cdot \frac{y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      6. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      8. lower-/.f64N/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. lift-neg.f6454.7%

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im} \]
    10. Applied rewrites54.7%

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 74.1% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq 5.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -8.5e+22)
   (/ x.im y.re)
   (if (<= y.re 5.5e+17)
     (/ (- (/ (* y.re x.im) y.im) 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_re <= -8.5e+22) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 5.5e+17) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	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 <= (-8.5d+22)) then
        tmp = x_46im / y_46re
    else if (y_46re <= 5.5d+17) then
        tmp = (((y_46re * x_46im) / y_46im) - 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_re <= -8.5e+22) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 5.5e+17) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - 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_re <= -8.5e+22:
		tmp = x_46_im / y_46_re
	elif y_46_re <= 5.5e+17:
		tmp = (((y_46_re * x_46_im) / y_46_im) - 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_re <= -8.5e+22)
		tmp = Float64(x_46_im / y_46_re);
	elseif (y_46_re <= 5.5e+17)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / 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_re <= -8.5e+22)
		tmp = x_46_im / y_46_re;
	elseif (y_46_re <= 5.5e+17)
		tmp = (((y_46_re * x_46_im) / y_46_im) - 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[LessEqual[y$46$re, -8.5e+22], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 5.5e+17], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x.im}{y.re}\\

\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -8.49999999999999979e22 or 5.5e17 < y.re

    1. Initial program 62.0%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6442.8%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites42.8%

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

    if -8.49999999999999979e22 < y.re < 5.5e17

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\color{blue}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)} \]
      15. distribute-lft-neg-inN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right)}} \]
      16. distribute-lft-neg-inN/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|y.re\right| \cdot \left|y.re\right|}\right)\right)\right)\right)} \]
      18. sqr-abs-revN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{y.re \cdot y.re}\right)\right)\right)\right)} \]
      19. lift-*.f64N/A

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}} \]
      21. lower-fma.f6462.0%

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

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, {y.re}^{\color{blue}{\left(1 - -1\right)}}\right)} \]
      4. pow-subN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{{y.re}^{-1}}}\right)} \]
      5. lower-unsound-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      6. lower-pow.f32N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{{y.re}^{-1}}}\right)} \]
      7. inv-powN/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{{y.re}^{1}}{\color{blue}{\frac{1}{y.re}}}\right)} \]
      8. lower-unsound-/.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \color{blue}{\frac{{y.re}^{1}}{\frac{1}{y.re}}}\right)} \]
      9. lower-unsound-pow.f64N/A

        \[\leadsto \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{fma}\left(y.im, y.im, \frac{\color{blue}{{y.re}^{1}}}{\frac{1}{y.re}}\right)} \]
      10. lower-/.f6462.0%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
      4. lower-*.f6452.9%

        \[\leadsto \frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im} \]
    8. Applied rewrites52.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, x.re, \frac{x.im \cdot y.re}{y.im}\right)}{y.im}} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + -1 \cdot x.re}{y.im} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. sub-flip-reverseN/A

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      5. lower--.f6452.9%

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
      8. lower-*.f6452.9%

        \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im} \]
    10. Applied rewrites52.9%

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

Alternative 8: 65.4% accurate, 1.7× speedup?

\[\begin{array}{l} \mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq 1.16 \cdot 10^{+17}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -8.5e+22)
   (/ x.im y.re)
   (if (<= y.re 1.16e+17) (/ (- 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_re <= -8.5e+22) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 1.16e+17) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	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 <= (-8.5d+22)) then
        tmp = x_46im / y_46re
    else if (y_46re <= 1.16d+17) 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_re <= -8.5e+22) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 1.16e+17) {
		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_re <= -8.5e+22:
		tmp = x_46_im / y_46_re
	elif y_46_re <= 1.16e+17:
		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_re <= -8.5e+22)
		tmp = Float64(x_46_im / y_46_re);
	elseif (y_46_re <= 1.16e+17)
		tmp = Float64(Float64(-x_46_re) / 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_re <= -8.5e+22)
		tmp = x_46_im / y_46_re;
	elseif (y_46_re <= 1.16e+17)
		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[LessEqual[y$46$re, -8.5e+22], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.16e+17], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y.re \leq -8.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x.im}{y.re}\\

\mathbf{elif}\;y.re \leq 1.16 \cdot 10^{+17}:\\
\;\;\;\;\frac{-x.re}{y.im}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -8.49999999999999979e22 or 1.16e17 < y.re

    1. Initial program 62.0%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6442.8%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites42.8%

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

    if -8.49999999999999979e22 < y.re < 1.16e17

    1. Initial program 62.0%

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

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

        \[\leadsto -1 \cdot \color{blue}{\frac{x.re}{y.im}} \]
      2. lower-/.f6443.5%

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

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

        \[\leadsto -1 \cdot \color{blue}{\frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{x.re}{y.im}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{x.re}{y.im}\right) \]
      4. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{\color{blue}{y.im}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{\color{blue}{y.im}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{\mathsf{neg}\left(x.re \cdot 1\right)}{y.im} \]
      7. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(x.re \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{y.im} \]
      8. distribute-rgt-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(x.re \cdot -1\right)\right)\right)}{y.im} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x.re\right)\right)\right)\right)\right)}{y.im} \]
      11. lower-neg.f64N/A

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}{y.im} \]
      13. *-commutativeN/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(x.re \cdot -1\right)\right)}{y.im} \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \frac{-x.re \cdot \left(\mathsf{neg}\left(-1\right)\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{-x.re \cdot 1}{y.im} \]
      16. *-rgt-identity43.5%

        \[\leadsto \frac{-x.re}{y.im} \]
    6. Applied rewrites43.5%

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

Alternative 9: 42.8% accurate, 4.9× speedup?

\[\frac{x.im}{y.re} \]
(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;
}
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_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]
\frac{x.im}{y.re}
Derivation
  1. Initial program 62.0%

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

    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  3. Step-by-step derivation
    1. lower-/.f6442.8%

      \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
  4. Applied rewrites42.8%

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

Reproduce

?
herbie shell --seed 2025179 
(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))))