math.cube on complex, imaginary part

Percentage Accurate: 82.4% → 99.8%
Time: 9.9s
Alternatives: 12
Speedup: 1.1×

Specification

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

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 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: 82.4% accurate, 1.0× speedup?

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

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\end{array}

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (fma (+ x.re x.im) (* x.im (- x.re x.im)) (* x.re (* x.re (+ x.im x.im))))
   (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re + x_46_im), (x_46_im * (x_46_re - x_46_im)), (x_46_re * (x_46_re * (x_46_im + x_46_im))));
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = fma(Float64(x_46_re + x_46_im), Float64(x_46_im * Float64(x_46_re - x_46_im)), Float64(x_46_re * Float64(x_46_re * Float64(x_46_im + x_46_im))));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


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

    1. Initial program 92.6%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.8

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.8

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.8%

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

    if +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6437.0

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites37.0%

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{+291}:\\ \;\;\;\;x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, -x.im \cdot x.im\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_0 4e+291)
     (* x.im (fma (* x.re 3.0) x.re (- (* x.im x.im))))
     (if (<= t_0 INFINITY)
       (* (* x.re x.im) (* x.re 3.0))
       (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 4e+291) {
		tmp = x_46_im * fma((x_46_re * 3.0), x_46_re, -(x_46_im * x_46_im));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_0 <= 4e+291)
		tmp = Float64(x_46_im * fma(Float64(x_46_re * 3.0), x_46_re, Float64(-Float64(x_46_im * x_46_im))));
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re * 3.0));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+291], N[(x$46$im * N[(N[(x$46$re * 3.0), $MachinePrecision] * x$46$re + (-N[(x$46$im * x$46$im), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, -x.im \cdot x.im\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


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

    1. Initial program 96.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3} + {x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    4. Applied rewrites96.0%

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right) + \color{blue}{3 \cdot \left(x.re \cdot x.re\right)}\right) \]
      4. +-commutativeN/A

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

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

        \[\leadsto x.im \cdot \left(3 \cdot \color{blue}{\left(x.re \cdot x.re\right)} + x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      7. associate-*r*N/A

        \[\leadsto x.im \cdot \left(\color{blue}{\left(3 \cdot x.re\right) \cdot x.re} + x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      8. lower-fma.f64N/A

        \[\leadsto x.im \cdot \color{blue}{\mathsf{fma}\left(3 \cdot x.re, x.re, x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)} \]
      9. *-commutativeN/A

        \[\leadsto x.im \cdot \mathsf{fma}\left(\color{blue}{x.re \cdot 3}, x.re, x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      10. lower-*.f64N/A

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

        \[\leadsto x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, x.im \cdot \color{blue}{\left(\mathsf{neg}\left(x.im\right)\right)}\right) \]
      12. distribute-rgt-neg-outN/A

        \[\leadsto x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, \color{blue}{\mathsf{neg}\left(x.im \cdot x.im\right)}\right) \]
      13. lift-*.f64N/A

        \[\leadsto x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, \mathsf{neg}\left(\color{blue}{x.im \cdot x.im}\right)\right) \]
      14. lower-neg.f6496.0

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

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

    if 3.9999999999999998e291 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 82.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.9

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.9

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6434.8

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites34.8%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
      2. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)} \]
      6. associate-*l*N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right)} \cdot \left(x.re \cdot x.im\right) \]
      8. lower-*.f6451.9

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)} \]
      10. *-commutativeN/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
      11. lower-*.f6451.9

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
    9. Applied rewrites51.9%

      \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)} \]

    if +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6437.0

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites37.0%

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 4 \cdot 10^{+291}:\\ \;\;\;\;x.im \cdot \mathsf{fma}\left(x.re \cdot 3, x.re, -x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{+291}:\\ \;\;\;\;x.im \cdot \mathsf{fma}\left(x.im, -x.im, \left(x.re \cdot x.re\right) \cdot 3\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_0 4e+291)
     (* x.im (fma x.im (- x.im) (* (* x.re x.re) 3.0)))
     (if (<= t_0 INFINITY)
       (* (* x.re x.im) (* x.re 3.0))
       (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 4e+291) {
		tmp = x_46_im * fma(x_46_im, -x_46_im, ((x_46_re * x_46_re) * 3.0));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_0 <= 4e+291)
		tmp = Float64(x_46_im * fma(x_46_im, Float64(-x_46_im), Float64(Float64(x_46_re * x_46_re) * 3.0)));
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re * 3.0));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+291], N[(x$46$im * N[(x$46$im * (-x$46$im) + N[(N[(x$46$re * x$46$re), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;x.im \cdot \mathsf{fma}\left(x.im, -x.im, \left(x.re \cdot x.re\right) \cdot 3\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


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

    1. Initial program 96.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3} + {x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    4. Applied rewrites96.0%

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

    if 3.9999999999999998e291 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 82.8%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.9

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.9

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6434.8

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites34.8%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
      2. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)} \]
      6. associate-*l*N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right)} \cdot \left(x.re \cdot x.im\right) \]
      8. lower-*.f6451.9

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)} \]
      10. *-commutativeN/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
      11. lower-*.f6451.9

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
    9. Applied rewrites51.9%

      \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)} \]

    if +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6437.0

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites37.0%

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 4 \cdot 10^{+291}:\\ \;\;\;\;x.im \cdot \mathsf{fma}\left(x.im, -x.im, \left(x.re \cdot x.re\right) \cdot 3\right)\\ \mathbf{elif}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 62.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_0 -1e-319)
     (* (* x.im x.im) (- x.im))
     (if (<= t_0 INFINITY)
       (* (* x.re x.im) (* x.re 3.0))
       (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = (x_46_im * x_46_im) * -x_46_im;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_0 <= -1e-319)
		tmp = Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im));
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re * 3.0));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-319], N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < -9.99989e-320

    1. Initial program 93.1%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x.im}^{3}\right)} \]
      2. unpow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x.im \cdot x.im\right) \cdot x.im}\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{x.im}^{2}} \cdot x.im\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      8. lower-neg.f6441.7

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im\right)} \]
    5. Applied rewrites41.7%

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)} \]

    if -9.99989e-320 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 92.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.8

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.8

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.8%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6459.7

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites59.7%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
      2. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)} \]
      6. associate-*l*N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right)} \cdot \left(x.re \cdot x.im\right) \]
      8. lower-*.f6467.3

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)} \]
      10. *-commutativeN/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
      11. lower-*.f6467.3

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
    9. Applied rewrites67.3%

      \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)} \]

    if +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 0.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6437.0

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites37.0%

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6437.0

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.2%

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

Alternative 5: 59.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im)))))
        (t_1 (* (* x.im x.im) (- x.im))))
   (if (<= t_0 -1e-319)
     t_1
     (if (<= t_0 INFINITY) (* (* x.re x.im) (* x.re 3.0)) t_1))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	t_1 = (x_46_im * x_46_im) * -x_46_im
	tmp = 0
	if t_0 <= -1e-319:
		tmp = t_1
	elif t_0 <= math.inf:
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0)
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	t_1 = Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im))
	tmp = 0.0
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re * 3.0));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	t_1 = (x_46_im * x_46_im) * -x_46_im;
	tmp = 0.0;
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-319], t$95$1, If[LessEqual[t$95$0, Infinity], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < -9.99989e-320 or +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 72.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x.im}^{3}\right)} \]
      2. unpow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x.im \cdot x.im\right) \cdot x.im}\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{x.im}^{2}} \cdot x.im\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      8. lower-neg.f6446.4

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im\right)} \]
    5. Applied rewrites46.4%

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)} \]

    if -9.99989e-320 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 92.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.8

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.8

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.8%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6459.7

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites59.7%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
      2. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.re} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x.re \cdot \left(3 \cdot \left(x.re \cdot x.im\right)\right)} \]
      6. associate-*l*N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right)} \cdot \left(x.re \cdot x.im\right) \]
      8. lower-*.f6467.3

        \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.re \cdot x.im\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)} \]
      10. *-commutativeN/A

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
      11. lower-*.f6467.3

        \[\leadsto \left(x.re \cdot 3\right) \cdot \color{blue}{\left(x.im \cdot x.re\right)} \]
    9. Applied rewrites67.3%

      \[\leadsto \color{blue}{\left(x.re \cdot 3\right) \cdot \left(x.im \cdot x.re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-319}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 59.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im)))))
        (t_1 (* (* x.im x.im) (- x.im))))
   (if (<= t_0 -1e-319)
     t_1
     (if (<= t_0 INFINITY) (* 3.0 (* x.re (* x.re x.im))) t_1))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	t_1 = (x_46_im * x_46_im) * -x_46_im
	tmp = 0
	if t_0 <= -1e-319:
		tmp = t_1
	elif t_0 <= math.inf:
		tmp = 3.0 * (x_46_re * (x_46_re * x_46_im))
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	t_1 = Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im))
	tmp = 0.0
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_re * x_46_im)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	t_1 = (x_46_im * x_46_im) * -x_46_im;
	tmp = 0.0;
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-319], t$95$1, If[LessEqual[t$95$0, Infinity], N[(3.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < -9.99989e-320 or +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 72.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x.im}^{3}\right)} \]
      2. unpow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x.im \cdot x.im\right) \cdot x.im}\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{x.im}^{2}} \cdot x.im\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      8. lower-neg.f6446.4

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im\right)} \]
    5. Applied rewrites46.4%

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)} \]

    if -9.99989e-320 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 92.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.8

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.8

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.8%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6459.7

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites59.7%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
      2. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      3. lift-*.f64N/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      4. lower-*.f6467.3

        \[\leadsto 3 \cdot \color{blue}{\left(\left(x.re \cdot x.im\right) \cdot x.re\right)} \]
      5. lift-*.f64N/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re\right) \]
      6. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re\right) \]
      7. lower-*.f6467.3

        \[\leadsto 3 \cdot \left(\color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re\right) \]
    9. Applied rewrites67.3%

      \[\leadsto 3 \cdot \color{blue}{\left(\left(x.im \cdot x.re\right) \cdot x.re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-319}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 57.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im)))))
        (t_1 (* (* x.im x.im) (- x.im))))
   (if (<= t_0 -1e-319)
     t_1
     (if (<= t_0 INFINITY) (* 3.0 (* (* x.re x.re) x.im)) t_1))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double t_1 = (x_46_im * x_46_im) * -x_46_im;
	double tmp;
	if (t_0 <= -1e-319) {
		tmp = t_1;
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	t_1 = (x_46_im * x_46_im) * -x_46_im
	tmp = 0
	if t_0 <= -1e-319:
		tmp = t_1
	elif t_0 <= math.inf:
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im)
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	t_1 = Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im))
	tmp = 0.0
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = Float64(3.0 * Float64(Float64(x_46_re * x_46_re) * x_46_im));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	t_1 = (x_46_im * x_46_im) * -x_46_im;
	tmp = 0.0;
	if (t_0 <= -1e-319)
		tmp = t_1;
	elseif (t_0 <= Inf)
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-319], t$95$1, If[LessEqual[t$95$0, Infinity], N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
t_1 := \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-319}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < -9.99989e-320 or +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 72.5%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x.im}^{3}\right)} \]
      2. unpow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x.im \cdot x.im\right) \cdot x.im}\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{x.im}^{2}} \cdot x.im\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      8. lower-neg.f6446.4

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im\right)} \]
    5. Applied rewrites46.4%

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)} \]

    if -9.99989e-320 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 92.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6499.8

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6499.8

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites99.8%

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

        \[\leadsto {x.re}^{2} \cdot \left(\color{blue}{3} \cdot x.im\right) \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(3 \cdot x.im\right) \cdot {x.re}^{2}} \]
      4. associate-*r*N/A

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

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

        \[\leadsto 3 \cdot \color{blue}{\left(x.im \cdot {x.re}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
      8. lower-*.f6459.7

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    7. Applied rewrites59.7%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification53.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-319}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 93.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 1e+100)
   (fma (* x.re 3.0) (* x.re x.im) (* (* x.im x.im) (- x.im)))
   (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 1e+100) {
		tmp = fma((x_46_re * 3.0), (x_46_re * x_46_im), ((x_46_im * x_46_im) * -x_46_im));
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 1e+100)
		tmp = fma(Float64(x_46_re * 3.0), Float64(x_46_re * x_46_im), Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im)));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1e+100], N[(N[(x$46$re * 3.0), $MachinePrecision] * N[(x$46$re * x$46$im), $MachinePrecision] + N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 1.00000000000000002e100

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3} + {x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    4. Applied rewrites90.3%

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right) + \color{blue}{3 \cdot \left(x.re \cdot x.re\right)}\right) \]
      4. +-commutativeN/A

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

        \[\leadsto \color{blue}{x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right) + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)} \]
      6. *-commutativeN/A

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

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

        \[\leadsto \left(3 \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \cdot x.im + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      9. associate-*r*N/A

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

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

        \[\leadsto \left(3 \cdot x.re\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)} + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(3 \cdot x.re, x.re \cdot x.im, x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)\right)} \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re \cdot 3}, x.re \cdot x.im, x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)\right) \]
      14. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, x.im \cdot \left(x.im \cdot \color{blue}{\left(\mathsf{neg}\left(x.im\right)\right)}\right)\right) \]
      16. distribute-rgt-neg-outN/A

        \[\leadsto \mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, x.im \cdot \color{blue}{\left(\mathsf{neg}\left(x.im \cdot x.im\right)\right)}\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, x.im \cdot \left(\mathsf{neg}\left(\color{blue}{x.im \cdot x.im}\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, \mathsf{neg}\left(\color{blue}{x.im \cdot \left(x.im \cdot x.im\right)}\right)\right) \]
      20. lower-neg.f6492.4

        \[\leadsto \mathsf{fma}\left(x.re \cdot 3, x.re \cdot x.im, \color{blue}{-x.im \cdot \left(x.im \cdot x.im\right)}\right) \]
    6. Applied rewrites92.4%

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

    if 1.00000000000000002e100 < x.im

    1. Initial program 69.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6482.1

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6482.1

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6482.1

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.6%

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

Alternative 9: 93.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, \left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 1e+100)
   (fma (* x.im (* x.re 3.0)) x.re (* (* x.im x.im) (- x.im)))
   (fma (- x.re x.im) (* x.im (+ x.re x.im)) (+ x.im x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 1e+100) {
		tmp = fma((x_46_im * (x_46_re * 3.0)), x_46_re, ((x_46_im * x_46_im) * -x_46_im));
	} else {
		tmp = fma((x_46_re - x_46_im), (x_46_im * (x_46_re + x_46_im)), (x_46_im + x_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 1e+100)
		tmp = fma(Float64(x_46_im * Float64(x_46_re * 3.0)), x_46_re, Float64(Float64(x_46_im * x_46_im) * Float64(-x_46_im)));
	else
		tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re + x_46_im)), Float64(x_46_im + x_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1e+100], N[(N[(x$46$im * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision] * x$46$re + N[(N[(x$46$im * x$46$im), $MachinePrecision] * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.re + x.im\right), x.im + x.im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 1.00000000000000002e100

    1. Initial program 85.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3} + {x.re}^{2} \cdot \left(x.im + 2 \cdot x.im\right)} \]
    4. Applied rewrites90.3%

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right) + \color{blue}{3 \cdot \left(x.re \cdot x.re\right)}\right) \]
      4. +-commutativeN/A

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

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

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

        \[\leadsto x.im \cdot \left(3 \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto x.im \cdot \color{blue}{\left(\left(3 \cdot x.re\right) \cdot x.re\right)} + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      9. associate-*r*N/A

        \[\leadsto \color{blue}{\left(x.im \cdot \left(3 \cdot x.re\right)\right) \cdot x.re} + x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right) \]
      10. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.im \cdot \left(3 \cdot x.re\right), x.re, x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.im \cdot \left(3 \cdot x.re\right)}, x.re, x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.im \cdot \color{blue}{\left(x.re \cdot 3\right)}, x.re, x.im \cdot \left(x.im \cdot \left(\mathsf{neg}\left(x.im\right)\right)\right)\right) \]
      13. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, x.im \cdot \left(x.im \cdot \color{blue}{\left(\mathsf{neg}\left(x.im\right)\right)}\right)\right) \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, x.im \cdot \color{blue}{\left(\mathsf{neg}\left(x.im \cdot x.im\right)\right)}\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, x.im \cdot \left(\mathsf{neg}\left(\color{blue}{x.im \cdot x.im}\right)\right)\right) \]
      17. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, \color{blue}{\mathsf{neg}\left(x.im \cdot \left(x.im \cdot x.im\right)\right)}\right) \]
      18. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, \mathsf{neg}\left(\color{blue}{x.im \cdot \left(x.im \cdot x.im\right)}\right)\right) \]
      19. lower-neg.f6492.4

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 3\right), x.re, \color{blue}{-x.im \cdot \left(x.im \cdot x.im\right)}\right) \]
    6. Applied rewrites92.4%

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

    if 1.00000000000000002e100 < x.im

    1. Initial program 69.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6482.1

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6482.1

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(x.re - x.im\right) \cdot x.im\right)} + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      4. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} \]
      16. lower-*.f6482.1

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.im \cdot x.re}\right)\right) \]
      20. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    6. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.im + x.im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.5%

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

Alternative 10: 64.6% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 3.6 \cdot 10^{+141}:\\
\;\;\;\;\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)\\

\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 3.6000000000000001e141

    1. Initial program 86.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x.im}^{3}\right)} \]
      2. unpow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x.im \cdot x.im\right) \cdot x.im}\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{x.im}^{2}} \cdot x.im\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{{x.im}^{2} \cdot \left(\mathsf{neg}\left(x.im\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.im\right)} \cdot \left(\mathsf{neg}\left(x.im\right)\right) \]
      8. lower-neg.f6463.3

        \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(-x.im\right)} \]
    5. Applied rewrites63.3%

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.im\right)} \]

    if 3.6000000000000001e141 < x.re

    1. Initial program 68.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      11. difference-of-squaresN/A

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

        \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      13. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
      16. lower--.f6495.4

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
      19. lower-*.f6495.4

        \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    4. Applied rewrites95.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)} \]
    5. Applied rewrites4.4%

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

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

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

        \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
      3. lower-*.f6475.1

        \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    8. Applied rewrites75.1%

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot x.re} \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re \]
      3. lift-*.f6477.3

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

        \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re \]
      6. lower-*.f6477.3

        \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re \]
    10. Applied rewrites77.3%

      \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot x.re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.8%

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

Alternative 11: 34.7% accurate, 3.6× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 82.8%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    11. difference-of-squaresN/A

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

      \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    13. lower-fma.f64N/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
    15. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
    16. lower--.f6493.2

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

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    19. lower-*.f6493.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)} \]
  5. Applied rewrites15.8%

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    3. lower-*.f6438.9

      \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  8. Applied rewrites38.9%

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re\right)} \]
  9. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right) \cdot x.re} \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re \]
    3. lift-*.f6439.6

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

      \[\leadsto \color{blue}{\left(x.im \cdot x.re\right)} \cdot x.re \]
    5. *-commutativeN/A

      \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re \]
    6. lower-*.f6439.6

      \[\leadsto \color{blue}{\left(x.re \cdot x.im\right)} \cdot x.re \]
  10. Applied rewrites39.6%

    \[\leadsto \color{blue}{\left(x.re \cdot x.im\right) \cdot x.re} \]
  11. Final simplification39.6%

    \[\leadsto x.re \cdot \left(x.re \cdot x.im\right) \]
  12. Add Preprocessing

Alternative 12: 34.0% accurate, 3.6× speedup?

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

\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 82.8%

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - \color{blue}{x.im \cdot x.im}\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    11. difference-of-squaresN/A

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

      \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    13. lower-fma.f64N/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{x.re + x.im}, \left(x.re - x.im\right) \cdot x.im, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
    15. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{\left(x.re - x.im\right) \cdot x.im}, \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right) \]
    16. lower--.f6493.2

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

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)}\right) \]
    19. lower-*.f6493.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.re + x.im, \left(x.re - x.im\right) \cdot x.im, x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)} \]
  5. Applied rewrites15.8%

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    3. lower-*.f6438.9

      \[\leadsto x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  8. Applied rewrites38.9%

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re\right)} \]
  9. Final simplification38.9%

    \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im \]
  10. Add Preprocessing

Developer Target 1: 91.4% accurate, 1.1× speedup?

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

\\
\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)
\end{array}

Reproduce

?
herbie shell --seed 2024210 
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"
  :precision binary64

  :alt
  (! :herbie-platform default (+ (* (* x.re x.im) (* 2 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im))))

  (+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))