math.cube on complex, imaginary part

Percentage Accurate: 83.0% → 99.8%
Time: 11.8s
Alternatives: 14
Speedup: 1.0×

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 14 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: 83.0% 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.1× speedup?

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

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

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


\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 91.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. Step-by-step derivation
      1. *-commutative91.5%

        \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      2. *-commutative91.5%

        \[\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 \]
      3. difference-of-squares91.5%

        \[\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 \]
      4. associate-*l*99.8%

        \[\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 \]
      5. fma-def99.8%

        \[\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)} \]
      6. *-commutative99.8%

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

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
      9. distribute-lft-out99.8%

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

      \[\leadsto \color{blue}{\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)} \]

    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. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def19.4%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in0.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+33.3%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in33.3%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+38.9%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative38.9%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative100.0%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \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}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 2: 97.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \leq \infty:\\ \;\;\;\;x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.re (+ (* x.re x.im) (* x.re x.im)))
       (* x.im (- (* x.re x.re) (* x.im x.im))))
      INFINITY)
   (- (* x.re (* (* x.re x.im) 3.0)) (pow x.im 3.0))
   (+ (+ x.im x.im) (* (+ x.re x.im) (* x.im (- x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= ((double) INFINITY)) {
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - pow(x_46_im, 3.0);
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - Math.pow(x_46_im, 3.0);
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= math.inf:
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - math.pow(x_46_im, 3.0)
	else:
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))) + Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)))) <= Inf)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) * 3.0)) - (x_46_im ^ 3.0));
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * 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 * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= Inf)
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - (x_46_im ^ 3.0);
	else
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\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 91.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. Step-by-step derivation
      1. +-commutative91.5%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative91.5%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out91.5%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*91.5%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative91.5%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out91.4%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-91.4%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--90.1%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)} \]
    3. Simplified90.2%

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg90.2%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*90.2%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*98.5%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr98.5%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\right)} \]
    6. Taylor expanded in x.re around 0 98.4%

      \[\leadsto x.re \cdot \color{blue}{\left(3 \cdot \left(x.im \cdot x.re\right)\right)} + \left(-{x.im}^{3}\right) \]
    7. Step-by-step derivation
      1. unsub-neg98.4%

        \[\leadsto \color{blue}{x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}} \]
      2. *-commutative98.4%

        \[\leadsto x.re \cdot \left(3 \cdot \color{blue}{\left(x.re \cdot x.im\right)}\right) - {x.im}^{3} \]
    8. Applied egg-rr98.4%

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

    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. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def19.4%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in0.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+33.3%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in33.3%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+38.9%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative38.9%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative100.0%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr100.0%

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

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

Alternative 3: 97.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \leq \infty:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.re (+ (* x.re x.im) (* x.re x.im)))
       (* x.im (- (* x.re x.re) (* x.im x.im))))
      INFINITY)
   (- (* x.re (* x.re (* x.im 3.0))) (pow x.im 3.0))
   (+ (+ x.im x.im) (* (+ x.re x.im) (* x.im (- x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= ((double) INFINITY)) {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - pow(x_46_im, 3.0);
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - Math.pow(x_46_im, 3.0);
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= math.inf:
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - math.pow(x_46_im, 3.0)
	else:
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)))
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))) + Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)))) <= Inf)
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0))) - (x_46_im ^ 3.0));
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * 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 * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))) <= Inf)
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - (x_46_im ^ 3.0);
	else
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\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 91.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. Step-by-step derivation
      1. +-commutative91.5%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative91.5%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out91.5%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*91.5%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative91.5%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out91.4%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-91.4%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--90.1%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)} \]
    3. Simplified90.2%

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg90.2%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*90.2%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*98.5%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr98.5%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\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. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def19.4%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in0.0%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+33.3%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in33.3%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+38.9%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative38.9%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative100.0%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr100.0%

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

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

Alternative 4: 94.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ t_1 := x.re \cdot x.re - x.im \cdot x.im\\ \mathbf{if}\;t_0 + x.im \cdot t_1 \leq 2 \cdot 10^{+286}:\\ \;\;\;\;t_0 + \frac{x.im}{\frac{1}{t_1}}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (+ (* x.re x.im) (* x.re x.im))))
        (t_1 (- (* x.re x.re) (* x.im x.im))))
   (if (<= (+ t_0 (* x.im t_1)) 2e+286)
     (+ t_0 (/ x.im (/ 1.0 t_1)))
     (+ (+ x.im x.im) (* (+ x.re x.im) (* x.im (- x.re x.im)))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
	double t_1 = (x_46_re * x_46_re) - (x_46_im * x_46_im);
	double tmp;
	if ((t_0 + (x_46_im * t_1)) <= 2e+286) {
		tmp = t_0 + (x_46_im / (1.0 / t_1));
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x_46re * ((x_46re * x_46im) + (x_46re * x_46im))
    t_1 = (x_46re * x_46re) - (x_46im * x_46im)
    if ((t_0 + (x_46im * t_1)) <= 2d+286) then
        tmp = t_0 + (x_46im / (1.0d0 / t_1))
    else
        tmp = (x_46im + x_46im) + ((x_46re + x_46im) * (x_46im * (x_46re - x_46im)))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
	double t_1 = (x_46_re * x_46_re) - (x_46_im * x_46_im);
	double tmp;
	if ((t_0 + (x_46_im * t_1)) <= 2e+286) {
		tmp = t_0 + (x_46_im / (1.0 / t_1));
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))
	t_1 = (x_46_re * x_46_re) - (x_46_im * x_46_im)
	tmp = 0
	if (t_0 + (x_46_im * t_1)) <= 2e+286:
		tmp = t_0 + (x_46_im / (1.0 / t_1))
	else:
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = 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_re * x_46_re) - Float64(x_46_im * x_46_im))
	tmp = 0.0
	if (Float64(t_0 + Float64(x_46_im * t_1)) <= 2e+286)
		tmp = Float64(t_0 + Float64(x_46_im / Float64(1.0 / t_1)));
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * Float64(x_46_re - x_46_im))));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
	t_1 = (x_46_re * x_46_re) - (x_46_im * x_46_im);
	tmp = 0.0;
	if ((t_0 + (x_46_im * t_1)) <= 2e+286)
		tmp = t_0 + (x_46_im / (1.0 / t_1));
	else
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(x$46$im * t$95$1), $MachinePrecision]), $MachinePrecision], 2e+286], N[(t$95$0 + N[(x$46$im / N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\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)) < 2.00000000000000007e286

    1. Initial program 92.4%

      \[\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. Step-by-step derivation
      1. difference-of-squares92.4%

        \[\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 \]
      2. flip-+92.4%

        \[\leadsto \left(\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re - x.im}} \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 \]
      3. associate-*l/82.5%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. Applied egg-rr82.5%

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Step-by-step derivation
      1. *-commutative82.5%

        \[\leadsto \color{blue}{x.im \cdot \frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      2. clear-num82.4%

        \[\leadsto x.im \cdot \color{blue}{\frac{1}{\frac{x.re - x.im}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. un-div-inv82.5%

        \[\leadsto \color{blue}{\frac{x.im}{\frac{x.re - x.im}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      4. *-un-lft-identity82.5%

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

        \[\leadsto \frac{x.im}{\color{blue}{\frac{1}{x.re \cdot x.re - x.im \cdot x.im} \cdot \frac{x.re - x.im}{x.re - x.im}}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      6. *-inverses92.4%

        \[\leadsto \frac{x.im}{\frac{1}{x.re \cdot x.re - x.im \cdot x.im} \cdot \color{blue}{1}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    5. Applied egg-rr92.4%

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

    if 2.00000000000000007e286 < (+.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 49.9%

      \[\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. Step-by-step derivation
      1. +-commutative49.9%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative49.9%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def58.4%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef49.9%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in49.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+64.4%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in64.4%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+66.8%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative66.8%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares93.3%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*94.1%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative94.1%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr94.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \leq 2 \cdot 10^{+286}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \frac{x.im}{\frac{1}{x.re \cdot x.re - x.im \cdot x.im}}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 5: 94.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{if}\;t_0 \leq 10^{+262}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.re (+ (* x.re x.im) (* x.re x.im)))
          (* x.im (- (* x.re x.re) (* x.im x.im))))))
   (if (<= t_0 1e+262)
     t_0
     (+ (+ x.im x.im) (* (+ x.re x.im) (* x.im (- x.re x.im)))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)));
	double tmp;
	if (t_0 <= 1e+262) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (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) :: t_0
    real(8) :: tmp
    t_0 = (x_46re * ((x_46re * x_46im) + (x_46re * x_46im))) + (x_46im * ((x_46re * x_46re) - (x_46im * x_46im)))
    if (t_0 <= 1d+262) then
        tmp = t_0
    else
        tmp = (x_46im + x_46im) + ((x_46re + x_46im) * (x_46im * (x_46re - x_46im)))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)));
	double tmp;
	if (t_0 <= 1e+262) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)))
	tmp = 0
	if t_0 <= 1e+262:
		tmp = t_0
	else:
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))) + Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))))
	tmp = 0.0
	if (t_0 <= 1e+262)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * Float64(x_46_re - x_46_im))));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im)));
	tmp = 0.0;
	if (t_0 <= 1e+262)
		tmp = t_0;
	else
		tmp = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+262], t$95$0, N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\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)) < 1e262

    1. Initial program 92.3%

      \[\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 \]

    if 1e262 < (+.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 50.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. Step-by-step derivation
      1. +-commutative50.5%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative50.5%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def58.8%

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

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

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

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

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

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in50.5%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+64.8%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in64.8%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+67.2%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative67.2%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares93.4%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*94.1%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative94.1%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr94.1%

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

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

Alternative 6: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{if}\;x.im \leq -49000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 6.2 \cdot 10^{-105}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 10:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (+ (+ x.im x.im) (* (+ x.re x.im) (* x.im (- x.re x.im))))))
   (if (<= x.im -49000000.0)
     t_0
     (if (<= x.im 6.2e-105)
       (* 3.0 (* (* x.re x.re) x.im))
       (if (<= x.im 10.0) (* x.im (- (* x.re x.re) (* x.im x.im))) t_0)))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	double tmp;
	if (x_46_im <= -49000000.0) {
		tmp = t_0;
	} else if (x_46_im <= 6.2e-105) {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	} else if (x_46_im <= 10.0) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_46im + x_46im) + ((x_46re + x_46im) * (x_46im * (x_46re - x_46im)))
    if (x_46im <= (-49000000.0d0)) then
        tmp = t_0
    else if (x_46im <= 6.2d-105) then
        tmp = 3.0d0 * ((x_46re * x_46re) * x_46im)
    else if (x_46im <= 10.0d0) then
        tmp = x_46im * ((x_46re * x_46re) - (x_46im * x_46im))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	double tmp;
	if (x_46_im <= -49000000.0) {
		tmp = t_0;
	} else if (x_46_im <= 6.2e-105) {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	} else if (x_46_im <= 10.0) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)))
	tmp = 0
	if x_46_im <= -49000000.0:
		tmp = t_0
	elif x_46_im <= 6.2e-105:
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im)
	elif x_46_im <= 10.0:
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * Float64(x_46_re - x_46_im))))
	tmp = 0.0
	if (x_46_im <= -49000000.0)
		tmp = t_0;
	elseif (x_46_im <= 6.2e-105)
		tmp = Float64(3.0 * Float64(Float64(x_46_re * x_46_re) * x_46_im));
	elseif (x_46_im <= 10.0)
		tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_im + x_46_im) + ((x_46_re + x_46_im) * (x_46_im * (x_46_re - x_46_im)));
	tmp = 0.0;
	if (x_46_im <= -49000000.0)
		tmp = t_0;
	elseif (x_46_im <= 6.2e-105)
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	elseif (x_46_im <= 10.0)
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -49000000.0], t$95$0, If[LessEqual[x$46$im, 6.2e-105], N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 10.0], N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\
\mathbf{if}\;x.im \leq -49000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.im \leq 6.2 \cdot 10^{-105}:\\
\;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\

\mathbf{elif}\;x.im \leq 10:\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -4.9e7 or 10 < x.im

    1. Initial program 69.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. Step-by-step derivation
      1. +-commutative69.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative69.1%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def75.1%

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

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.im + \color{blue}{x.re \cdot x.im}, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-lft-out75.1%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef69.1%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in69.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+74.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in74.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+79.0%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative79.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares97.8%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*97.8%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative97.8%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr97.8%

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

    if -4.9e7 < x.im < 6.20000000000000029e-105

    1. Initial program 84.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. Step-by-step derivation
      1. +-commutative84.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative84.1%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out84.1%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*84.0%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative84.0%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out84.0%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-84.0%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--84.0%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)} \]
    3. Simplified84.1%

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg84.1%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*84.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*99.7%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr99.7%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\right)} \]
    6. Taylor expanded in x.re around inf 74.5%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot {x.re}^{2}\right)} \]
    7. Step-by-step derivation
      1. unpow274.5%

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

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

    if 6.20000000000000029e-105 < x.im < 10

    1. Initial program 96.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. Step-by-step derivation
      1. *-commutative96.6%

        \[\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.re \cdot x.im}\right) \cdot x.re \]
      2. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
      3. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      4. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      5. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
      6. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
      7. flip-+55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
      8. *-commutative55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
      9. distribute-lft-in55.5%

        \[\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.re \cdot x.im\right)} \]
    3. Applied egg-rr55.5%

      \[\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.re \cdot x.im\right)} \]
    4. Step-by-step derivation
      1. *-commutative55.5%

        \[\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) \]
      2. rem-cbrt-cube55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\sqrt[3]{{x.im}^{3}}} \cdot x.re\right) \]
      3. add-sqr-sqrt55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3}} \cdot \sqrt{{x.im}^{3}}}} \cdot x.re\right) \]
      4. sqrt-unprod55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3} \cdot {x.im}^{3}}}} \cdot x.re\right) \]
      5. sqr-neg55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\sqrt{\color{blue}{\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right)}}} \cdot x.re\right) \]
      6. sqrt-unprod0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{-{x.im}^{3}} \cdot \sqrt{-{x.im}^{3}}}} \cdot x.re\right) \]
      7. add-sqr-sqrt66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-{x.im}^{3}}} \cdot x.re\right) \]
      8. neg-mul-166.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-1 \cdot {x.im}^{3}}} \cdot x.re\right) \]
      9. cbrt-prod66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(\sqrt[3]{-1} \cdot \sqrt[3]{{x.im}^{3}}\right)} \cdot x.re\right) \]
      10. metadata-eval66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{1 \cdot -1}} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      11. metadata-eval66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{\left(-1 \cdot -1\right)} \cdot -1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      12. add-cbrt-cube66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\color{blue}{-1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      13. rem-cbrt-cube76.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(-1 \cdot \color{blue}{x.im}\right) \cdot x.re\right) \]
      14. neg-mul-176.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(-x.im\right)} \cdot x.re\right) \]
      15. cancel-sign-sub-inv76.1%

        \[\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)} \]
      16. *-commutative76.1%

        \[\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.re \cdot x.im}\right) \]
      17. +-inverses76.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{0} \]
    5. Applied egg-rr76.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -49000000:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 6.2 \cdot 10^{-105}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 10:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 7: 85.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\
\mathbf{if}\;x.im \leq -1350000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.im \leq 1.2 \cdot 10^{-102}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.re \cdot x.re\right) \cdot x.im\\

\mathbf{elif}\;x.im \leq 10:\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -1.35e9 or 10 < x.im

    1. Initial program 69.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. Step-by-step derivation
      1. +-commutative69.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative69.1%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def75.1%

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

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.im + \color{blue}{x.re \cdot x.im}, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-lft-out75.1%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef69.1%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in69.1%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      3. flip-+0.0%

        \[\leadsto x.re \cdot \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      4. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      5. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      6. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      7. +-inverses0.0%

        \[\leadsto x.re \cdot \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+74.7%

        \[\leadsto x.re \cdot \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      9. distribute-lft-in74.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      10. flip-+0.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      11. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      12. +-inverses0.0%

        \[\leadsto \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      13. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      14. +-inverses0.0%

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      15. flip-+79.0%

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. *-commutative79.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      17. difference-of-squares97.8%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      18. associate-*r*97.8%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \]
      19. *-commutative97.8%

        \[\leadsto \left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(x.re - x.im\right)\right)} \]
    5. Applied egg-rr97.8%

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

    if -1.35e9 < x.im < 1.2e-102

    1. Initial program 84.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. Step-by-step derivation
      1. difference-of-squares84.1%

        \[\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 \]
      2. flip-+84.1%

        \[\leadsto \left(\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re - x.im}} \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 \]
      3. associate-*l/73.7%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. Applied egg-rr73.7%

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Taylor expanded in x.re around inf 74.6%

      \[\leadsto \color{blue}{{x.re}^{2}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    5. Simplified74.6%

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

    if 1.2e-102 < x.im < 10

    1. Initial program 96.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. Step-by-step derivation
      1. *-commutative96.6%

        \[\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.re \cdot x.im}\right) \cdot x.re \]
      2. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
      3. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      4. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      5. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
      6. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
      7. flip-+55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
      8. *-commutative55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
      9. distribute-lft-in55.5%

        \[\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.re \cdot x.im\right)} \]
    3. Applied egg-rr55.5%

      \[\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.re \cdot x.im\right)} \]
    4. Step-by-step derivation
      1. *-commutative55.5%

        \[\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) \]
      2. rem-cbrt-cube55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\sqrt[3]{{x.im}^{3}}} \cdot x.re\right) \]
      3. add-sqr-sqrt55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3}} \cdot \sqrt{{x.im}^{3}}}} \cdot x.re\right) \]
      4. sqrt-unprod55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3} \cdot {x.im}^{3}}}} \cdot x.re\right) \]
      5. sqr-neg55.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\sqrt{\color{blue}{\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right)}}} \cdot x.re\right) \]
      6. sqrt-unprod0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{-{x.im}^{3}} \cdot \sqrt{-{x.im}^{3}}}} \cdot x.re\right) \]
      7. add-sqr-sqrt66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-{x.im}^{3}}} \cdot x.re\right) \]
      8. neg-mul-166.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-1 \cdot {x.im}^{3}}} \cdot x.re\right) \]
      9. cbrt-prod66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(\sqrt[3]{-1} \cdot \sqrt[3]{{x.im}^{3}}\right)} \cdot x.re\right) \]
      10. metadata-eval66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{1 \cdot -1}} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      11. metadata-eval66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{\left(-1 \cdot -1\right)} \cdot -1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      12. add-cbrt-cube66.7%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\color{blue}{-1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      13. rem-cbrt-cube76.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(-1 \cdot \color{blue}{x.im}\right) \cdot x.re\right) \]
      14. neg-mul-176.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(-x.im\right)} \cdot x.re\right) \]
      15. cancel-sign-sub-inv76.1%

        \[\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)} \]
      16. *-commutative76.1%

        \[\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.re \cdot x.im}\right) \]
      17. +-inverses76.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{0} \]
    5. Applied egg-rr76.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1350000000:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 1.2 \cdot 10^{-102}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.re \cdot x.re\right) \cdot x.im\\ \mathbf{elif}\;x.im \leq 10:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 8: 81.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.3 \cdot 10^{-101} \lor \neg \left(x.im \leq 5 \cdot 10^{-103}\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -3.3e-101) (not (<= x.im 5e-103)))
   (* x.im (- (* x.re x.re) (* x.im x.im)))
   (* 3.0 (* (* x.re x.re) x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -3.3e-101) || !(x_46_im <= 5e-103)) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = 3.0 * ((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_46im <= (-3.3d-101)) .or. (.not. (x_46im <= 5d-103))) then
        tmp = x_46im * ((x_46re * x_46re) - (x_46im * x_46im))
    else
        tmp = 3.0d0 * ((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_im <= -3.3e-101) || !(x_46_im <= 5e-103)) {
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	} else {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -3.3e-101) or not (x_46_im <= 5e-103):
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))
	else:
		tmp = 3.0 * ((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_im <= -3.3e-101) || !(x_46_im <= 5e-103))
		tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)));
	else
		tmp = Float64(3.0 * Float64(Float64(x_46_re * 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_im <= -3.3e-101) || ~((x_46_im <= 5e-103)))
		tmp = x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	else
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -3.3e-101], N[Not[LessEqual[x$46$im, 5e-103]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.3 \cdot 10^{-101} \lor \neg \left(x.im \leq 5 \cdot 10^{-103}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.29999999999999984e-101 or 4.99999999999999966e-103 < x.im

    1. Initial program 76.7%

      \[\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. Step-by-step derivation
      1. *-commutative76.7%

        \[\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.re \cdot x.im}\right) \cdot x.re \]
      2. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
      3. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      4. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      5. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
      6. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
      7. flip-+69.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
      8. *-commutative69.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
      9. distribute-lft-in69.4%

        \[\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.re \cdot x.im\right)} \]
    3. Applied egg-rr69.4%

      \[\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.re \cdot x.im\right)} \]
    4. Step-by-step derivation
      1. *-commutative69.4%

        \[\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) \]
      2. rem-cbrt-cube53.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\sqrt[3]{{x.im}^{3}}} \cdot x.re\right) \]
      3. add-sqr-sqrt23.8%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3}} \cdot \sqrt{{x.im}^{3}}}} \cdot x.re\right) \]
      4. sqrt-unprod43.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{{x.im}^{3} \cdot {x.im}^{3}}}} \cdot x.re\right) \]
      5. sqr-neg43.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\sqrt{\color{blue}{\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right)}}} \cdot x.re\right) \]
      6. sqrt-unprod28.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{\sqrt{-{x.im}^{3}} \cdot \sqrt{-{x.im}^{3}}}} \cdot x.re\right) \]
      7. add-sqr-sqrt51.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-{x.im}^{3}}} \cdot x.re\right) \]
      8. neg-mul-151.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \sqrt[3]{\color{blue}{-1 \cdot {x.im}^{3}}} \cdot x.re\right) \]
      9. cbrt-prod51.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(\sqrt[3]{-1} \cdot \sqrt[3]{{x.im}^{3}}\right)} \cdot x.re\right) \]
      10. metadata-eval51.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{1 \cdot -1}} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      11. metadata-eval51.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\sqrt[3]{\color{blue}{\left(-1 \cdot -1\right)} \cdot -1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      12. add-cbrt-cube51.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(\color{blue}{-1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot x.re\right) \]
      13. rem-cbrt-cube69.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \left(-1 \cdot \color{blue}{x.im}\right) \cdot x.re\right) \]
      14. neg-mul-169.4%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + \color{blue}{\left(-x.im\right)} \cdot x.re\right) \]
      15. cancel-sign-sub-inv69.4%

        \[\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)} \]
      16. *-commutative69.4%

        \[\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.re \cdot x.im}\right) \]
      17. +-inverses76.3%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{0} \]
    5. Applied egg-rr76.3%

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

    if -3.29999999999999984e-101 < x.im < 4.99999999999999966e-103

    1. Initial program 82.7%

      \[\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. Step-by-step derivation
      1. +-commutative82.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative82.7%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out82.7%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*82.7%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative82.7%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out82.7%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-82.7%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--82.7%

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

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg82.7%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*82.7%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*99.7%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr99.7%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\right)} \]
    6. Taylor expanded in x.re around inf 82.7%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot {x.re}^{2}\right)} \]
    7. Step-by-step derivation
      1. unpow282.7%

        \[\leadsto 3 \cdot \left(x.im \cdot \color{blue}{\left(x.re \cdot x.re\right)}\right) \]
    8. Simplified82.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 simplification78.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.3 \cdot 10^{-101} \lor \neg \left(x.im \leq 5 \cdot 10^{-103}\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \end{array} \]

Alternative 9: 55.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.9 \cdot 10^{+183} \lor \neg \left(x.im \leq 2.4 \cdot 10^{+176}\right):\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -3.9e+183) (not (<= x.im 2.4e+176)))
   (* (* x.re x.re) (- x.im))
   (* 3.0 (* (* x.re x.re) x.im))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -3.9e+183) || !(x_46_im <= 2.4e+176)) {
		tmp = (x_46_re * x_46_re) * -x_46_im;
	} else {
		tmp = 3.0 * ((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_46im <= (-3.9d+183)) .or. (.not. (x_46im <= 2.4d+176))) then
        tmp = (x_46re * x_46re) * -x_46im
    else
        tmp = 3.0d0 * ((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_im <= -3.9e+183) || !(x_46_im <= 2.4e+176)) {
		tmp = (x_46_re * x_46_re) * -x_46_im;
	} else {
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -3.9e+183) or not (x_46_im <= 2.4e+176):
		tmp = (x_46_re * x_46_re) * -x_46_im
	else:
		tmp = 3.0 * ((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_im <= -3.9e+183) || !(x_46_im <= 2.4e+176))
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(-x_46_im));
	else
		tmp = Float64(3.0 * Float64(Float64(x_46_re * 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_im <= -3.9e+183) || ~((x_46_im <= 2.4e+176)))
		tmp = (x_46_re * x_46_re) * -x_46_im;
	else
		tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -3.9e+183], N[Not[LessEqual[x$46$im, 2.4e+176]], $MachinePrecision]], N[(N[(x$46$re * x$46$re), $MachinePrecision] * (-x$46$im)), $MachinePrecision], N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.9 \cdot 10^{+183} \lor \neg \left(x.im \leq 2.4 \cdot 10^{+176}\right):\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.8999999999999999e183 or 2.4000000000000001e176 < x.im

    1. Initial program 46.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. Step-by-step derivation
      1. difference-of-squares54.0%

        \[\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 \]
      2. flip-+46.0%

        \[\leadsto \left(\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re - x.im}} \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 \]
      3. associate-*l/46.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. Applied egg-rr46.0%

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Taylor expanded in x.im around 0 8.4%

      \[\leadsto \color{blue}{x.im \cdot \left(2 \cdot {x.re}^{2} + {x.re}^{2}\right)} \]
    5. Simplified47.6%

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

    if -3.8999999999999999e183 < x.im < 2.4000000000000001e176

    1. Initial program 86.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. Step-by-step derivation
      1. +-commutative86.5%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative86.5%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out86.5%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*86.5%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative86.5%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out87.4%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-87.4%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--85.0%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)} \]
    3. Simplified85.1%

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg85.1%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*85.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*94.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr94.0%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\right)} \]
    6. Taylor expanded in x.re around inf 58.3%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot {x.re}^{2}\right)} \]
    7. Step-by-step derivation
      1. unpow258.3%

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

      \[\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 simplification56.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.9 \cdot 10^{+183} \lor \neg \left(x.im \leq 2.4 \cdot 10^{+176}\right):\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \end{array} \]

Alternative 10: 55.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x.re \cdot x.re\right) \cdot x.im\\ \mathbf{if}\;x.im \leq -3.8 \cdot 10^{+182}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;x.im \leq 2.7 \cdot 10^{+176}:\\ \;\;\;\;3 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;-1 - t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* (* x.re x.re) x.im)))
   (if (<= x.im -3.8e+182)
     (* (* x.re x.re) (- x.im))
     (if (<= x.im 2.7e+176) (* 3.0 t_0) (- -1.0 t_0)))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * x_46_re) * x_46_im;
	double tmp;
	if (x_46_im <= -3.8e+182) {
		tmp = (x_46_re * x_46_re) * -x_46_im;
	} else if (x_46_im <= 2.7e+176) {
		tmp = 3.0 * t_0;
	} else {
		tmp = -1.0 - t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_46re * x_46re) * x_46im
    if (x_46im <= (-3.8d+182)) then
        tmp = (x_46re * x_46re) * -x_46im
    else if (x_46im <= 2.7d+176) then
        tmp = 3.0d0 * t_0
    else
        tmp = (-1.0d0) - t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * x_46_re) * x_46_im;
	double tmp;
	if (x_46_im <= -3.8e+182) {
		tmp = (x_46_re * x_46_re) * -x_46_im;
	} else if (x_46_im <= 2.7e+176) {
		tmp = 3.0 * t_0;
	} else {
		tmp = -1.0 - t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re * x_46_re) * x_46_im
	tmp = 0
	if x_46_im <= -3.8e+182:
		tmp = (x_46_re * x_46_re) * -x_46_im
	elif x_46_im <= 2.7e+176:
		tmp = 3.0 * t_0
	else:
		tmp = -1.0 - t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re * x_46_re) * x_46_im)
	tmp = 0.0
	if (x_46_im <= -3.8e+182)
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(-x_46_im));
	elseif (x_46_im <= 2.7e+176)
		tmp = Float64(3.0 * t_0);
	else
		tmp = Float64(-1.0 - t_0);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_re * x_46_re) * x_46_im;
	tmp = 0.0;
	if (x_46_im <= -3.8e+182)
		tmp = (x_46_re * x_46_re) * -x_46_im;
	elseif (x_46_im <= 2.7e+176)
		tmp = 3.0 * t_0;
	else
		tmp = -1.0 - t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]}, If[LessEqual[x$46$im, -3.8e+182], N[(N[(x$46$re * x$46$re), $MachinePrecision] * (-x$46$im)), $MachinePrecision], If[LessEqual[x$46$im, 2.7e+176], N[(3.0 * t$95$0), $MachinePrecision], N[(-1.0 - t$95$0), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;x.im \leq 2.7 \cdot 10^{+176}:\\
\;\;\;\;3 \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;-1 - t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -3.80000000000000013e182

    1. Initial program 51.9%

      \[\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. Step-by-step derivation
      1. difference-of-squares55.6%

        \[\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 \]
      2. flip-+51.9%

        \[\leadsto \left(\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re - x.im}} \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 \]
      3. associate-*l/51.9%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. Applied egg-rr51.9%

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Taylor expanded in x.im around 0 4.2%

      \[\leadsto \color{blue}{x.im \cdot \left(2 \cdot {x.re}^{2} + {x.re}^{2}\right)} \]
    5. Simplified46.1%

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

    if -3.80000000000000013e182 < x.im < 2.6999999999999998e176

    1. Initial program 86.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. Step-by-step derivation
      1. +-commutative86.5%

        \[\leadsto \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
      2. *-commutative86.5%

        \[\leadsto \left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. distribute-lft-out86.5%

        \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. associate-*l*86.5%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. *-commutative86.5%

        \[\leadsto x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      6. distribute-lft-out87.4%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
      7. associate-+r-87.4%

        \[\leadsto x.im \cdot \color{blue}{\left(\left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot x.im\right)} \]
      8. distribute-lft-out--85.0%

        \[\leadsto \color{blue}{x.im \cdot \left(\left(x.re + x.re\right) \cdot x.re + x.re \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right)} \]
    3. Simplified85.1%

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 - {x.im}^{3}} \]
    4. Step-by-step derivation
      1. sub-neg85.1%

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3 + \left(-{x.im}^{3}\right)} \]
      2. associate-*l*85.1%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)} + \left(-{x.im}^{3}\right) \]
      3. associate-*l*94.0%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)} + \left(-{x.im}^{3}\right) \]
    5. Applied egg-rr94.0%

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) + \left(-{x.im}^{3}\right)} \]
    6. Taylor expanded in x.re around inf 58.3%

      \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot {x.re}^{2}\right)} \]
    7. Step-by-step derivation
      1. unpow258.3%

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

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

    if 2.6999999999999998e176 < x.im

    1. Initial program 39.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. Step-by-step derivation
      1. *-commutative39.1%

        \[\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.re \cdot x.im}\right) \cdot x.re \]
      2. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
      3. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      4. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      5. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
      6. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
      7. flip-+60.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
      8. *-commutative60.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
      9. distribute-rgt-in60.9%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im \cdot x.re + x.im \cdot x.re\right)} \]
      10. *-commutative60.9%

        \[\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) \]
      11. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}{x.re \cdot x.im - x.im \cdot x.re}} \]
      12. clear-num0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{\frac{x.re \cdot x.im - x.im \cdot x.re}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}}} \]
      13. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.re \cdot x.im - \color{blue}{x.re \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      14. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{0}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      16. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.im \cdot x.re\right)}} \]
      17. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)}}} \]
      18. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}}} \]
      19. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
      20. flip-+69.6%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\color{blue}{x.im + x.im}} \]
    3. Applied egg-rr69.6%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{x.im + x.im}} \]
    4. Taylor expanded in x.im around inf 39.1%

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3} + x.im \cdot {x.re}^{2}} \]
    5. Simplified13.7%

      \[\leadsto \color{blue}{-1 + x.im \cdot \left(x.re \cdot x.re\right)} \]
    6. Step-by-step derivation
      1. rem-cbrt-cube13.0%

        \[\leadsto -1 + \color{blue}{\sqrt[3]{{x.im}^{3}}} \cdot \left(x.re \cdot x.re\right) \]
      2. add-sqr-sqrt13.0%

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

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

        \[\leadsto -1 + \sqrt[3]{\sqrt{\color{blue}{\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right)}}} \cdot \left(x.re \cdot x.re\right) \]
      5. sqrt-unprod0.0%

        \[\leadsto -1 + \sqrt[3]{\color{blue}{\sqrt{-{x.im}^{3}} \cdot \sqrt{-{x.im}^{3}}}} \cdot \left(x.re \cdot x.re\right) \]
      6. add-sqr-sqrt78.3%

        \[\leadsto -1 + \sqrt[3]{\color{blue}{-{x.im}^{3}}} \cdot \left(x.re \cdot x.re\right) \]
      7. neg-mul-178.3%

        \[\leadsto -1 + \sqrt[3]{\color{blue}{-1 \cdot {x.im}^{3}}} \cdot \left(x.re \cdot x.re\right) \]
      8. cbrt-prod78.3%

        \[\leadsto -1 + \color{blue}{\left(\sqrt[3]{-1} \cdot \sqrt[3]{{x.im}^{3}}\right)} \cdot \left(x.re \cdot x.re\right) \]
      9. metadata-eval78.3%

        \[\leadsto -1 + \left(\sqrt[3]{\color{blue}{1 \cdot -1}} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot \left(x.re \cdot x.re\right) \]
      10. metadata-eval78.3%

        \[\leadsto -1 + \left(\sqrt[3]{\color{blue}{\left(-1 \cdot -1\right)} \cdot -1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot \left(x.re \cdot x.re\right) \]
      11. add-cbrt-cube78.3%

        \[\leadsto -1 + \left(\color{blue}{-1} \cdot \sqrt[3]{{x.im}^{3}}\right) \cdot \left(x.re \cdot x.re\right) \]
      12. rem-cbrt-cube49.5%

        \[\leadsto -1 + \left(-1 \cdot \color{blue}{x.im}\right) \cdot \left(x.re \cdot x.re\right) \]
      13. neg-mul-149.5%

        \[\leadsto -1 + \color{blue}{\left(-x.im\right)} \cdot \left(x.re \cdot x.re\right) \]
      14. cancel-sign-sub-inv49.5%

        \[\leadsto \color{blue}{-1 - x.im \cdot \left(x.re \cdot x.re\right)} \]
      15. *-commutative49.5%

        \[\leadsto -1 - \color{blue}{\left(x.re \cdot x.re\right) \cdot x.im} \]
      16. associate-*l*49.5%

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

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

        \[\leadsto -1 - \color{blue}{\left(x.re \cdot x.re\right) \cdot x.im} \]
      2. *-commutative49.5%

        \[\leadsto -1 - \color{blue}{x.im \cdot \left(x.re \cdot x.re\right)} \]
    9. Simplified49.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.8 \cdot 10^{+182}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{elif}\;x.im \leq 2.7 \cdot 10^{+176}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;-1 - \left(x.re \cdot x.re\right) \cdot x.im\\ \end{array} \]

Alternative 11: 39.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -9 \cdot 10^{+186} \lor \neg \left(x.im \leq 2.5 \cdot 10^{+176}\right):\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot x.im\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -9e+186) (not (<= x.im 2.5e+176)))
   (* (* x.re x.re) (- x.im))
   (* (* x.re x.re) x.im)))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -9e+186) || !(x_46_im <= 2.5e+176)) {
		tmp = (x_46_re * x_46_re) * -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_46im <= (-9d+186)) .or. (.not. (x_46im <= 2.5d+176))) then
        tmp = (x_46re * x_46re) * -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_im <= -9e+186) || !(x_46_im <= 2.5e+176)) {
		tmp = (x_46_re * x_46_re) * -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_im <= -9e+186) or not (x_46_im <= 2.5e+176):
		tmp = (x_46_re * x_46_re) * -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_im <= -9e+186) || !(x_46_im <= 2.5e+176))
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(-x_46_im));
	else
		tmp = Float64(Float64(x_46_re * 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_im <= -9e+186) || ~((x_46_im <= 2.5e+176)))
		tmp = (x_46_re * x_46_re) * -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[Or[LessEqual[x$46$im, -9e+186], N[Not[LessEqual[x$46$im, 2.5e+176]], $MachinePrecision]], N[(N[(x$46$re * x$46$re), $MachinePrecision] * (-x$46$im)), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -9 \cdot 10^{+186} \lor \neg \left(x.im \leq 2.5 \cdot 10^{+176}\right):\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -9.0000000000000009e186 or 2.5e176 < x.im

    1. Initial program 46.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. Step-by-step derivation
      1. difference-of-squares54.0%

        \[\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 \]
      2. flip-+46.0%

        \[\leadsto \left(\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re - x.im}} \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 \]
      3. associate-*l/46.0%

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. Applied egg-rr46.0%

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)}{x.re - x.im}} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Taylor expanded in x.im around 0 8.4%

      \[\leadsto \color{blue}{x.im \cdot \left(2 \cdot {x.re}^{2} + {x.re}^{2}\right)} \]
    5. Simplified47.6%

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

    if -9.0000000000000009e186 < x.im < 2.5e176

    1. Initial program 86.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. Step-by-step derivation
      1. *-commutative86.5%

        \[\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.re \cdot x.im}\right) \cdot x.re \]
      2. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
      3. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      4. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
      5. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
      6. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
      7. flip-+60.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
      8. *-commutative60.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
      9. distribute-rgt-in60.5%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im \cdot x.re + x.im \cdot x.re\right)} \]
      10. *-commutative60.5%

        \[\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) \]
      11. flip-+0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}{x.re \cdot x.im - x.im \cdot x.re}} \]
      12. clear-num0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{\frac{x.re \cdot x.im - x.im \cdot x.re}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}}} \]
      13. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.re \cdot x.im - \color{blue}{x.re \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      14. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{0}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
      16. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.im \cdot x.re\right)}} \]
      17. *-commutative0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)}}} \]
      18. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}}} \]
      19. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
      20. flip-+41.1%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\color{blue}{x.im + x.im}} \]
    3. Applied egg-rr41.1%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{x.im + x.im}} \]
    4. Taylor expanded in x.re around inf 39.2%

      \[\leadsto \color{blue}{x.im \cdot {x.re}^{2}} \]
    5. Simplified39.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -9 \cdot 10^{+186} \lor \neg \left(x.im \leq 2.5 \cdot 10^{+176}\right):\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot x.im\\ \end{array} \]

Alternative 12: 34.4% accurate, 3.8× 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 78.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. Step-by-step derivation
    1. *-commutative78.6%

      \[\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.re \cdot x.im}\right) \cdot x.re \]
    2. flip-+0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}{x.re \cdot x.im - x.re \cdot x.im}} \cdot x.re \]
    3. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
    4. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{x.re \cdot x.im - x.re \cdot x.im} \cdot x.re \]
    5. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}} \cdot x.re \]
    6. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
    7. flip-+61.6%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im + x.im\right)} \cdot x.re \]
    8. *-commutative61.6%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.re \cdot \left(x.im + x.im\right)} \]
    9. distribute-rgt-in61.6%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(x.im \cdot x.re + x.im \cdot x.re\right)} \]
    10. *-commutative61.6%

      \[\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) \]
    11. flip-+0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}{x.re \cdot x.im - x.im \cdot x.re}} \]
    12. clear-num0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{\frac{x.re \cdot x.im - x.im \cdot x.re}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}}} \]
    13. *-commutative0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.re \cdot x.im - \color{blue}{x.re \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
    14. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{0}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
    15. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{\color{blue}{x.im \cdot x.im - x.im \cdot x.im}}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.im \cdot x.re\right) \cdot \left(x.im \cdot x.re\right)}} \]
    16. *-commutative0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \color{blue}{\left(x.re \cdot x.im\right)} \cdot \left(x.im \cdot x.re\right)}} \]
    17. *-commutative0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \color{blue}{\left(x.re \cdot x.im\right)}}} \]
    18. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}}} \]
    19. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
    20. flip-+46.8%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{1}{\color{blue}{x.im + x.im}} \]
  3. Applied egg-rr46.8%

    \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{1}{x.im + x.im}} \]
  4. Taylor expanded in x.re around inf 33.2%

    \[\leadsto \color{blue}{x.im \cdot {x.re}^{2}} \]
  5. Simplified33.2%

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

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

Alternative 13: 18.6% accurate, 4.8× speedup?

\[\begin{array}{l} \\ x.re \cdot \left(-x.re\right) \end{array} \]
(FPCore (x.re x.im) :precision binary64 (* x.re (- x.re)))
double code(double x_46_re, double x_46_im) {
	return 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
end function
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * -x_46_re;
}
def code(x_46_re, x_46_im):
	return x_46_re * -x_46_re
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(-x_46_re))
end
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * -x_46_re;
end
code[x$46$re_, x$46$im_] := N[(x$46$re * (-x$46$re)), $MachinePrecision]
\begin{array}{l}

\\
x.re \cdot \left(-x.re\right)
\end{array}
Derivation
  1. Initial program 78.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. Step-by-step derivation
    1. *-commutative78.6%

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. *-commutative78.6%

      \[\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 \]
    3. difference-of-squares82.5%

      \[\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 \]
    4. associate-*l*89.7%

      \[\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 \]
    5. fma-def89.7%

      \[\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)} \]
    6. *-commutative89.7%

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

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

      \[\leadsto \mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
    9. distribute-lft-out89.7%

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

    \[\leadsto \color{blue}{\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)} \]
  4. Step-by-step derivation
    1. add-cube-cbrt89.3%

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

      \[\leadsto \mathsf{fma}\left(x.re + x.im, \color{blue}{{\left(\sqrt[3]{x.im \cdot \left(x.re - x.im\right)}\right)}^{3}}, x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right) \]
  5. Applied egg-rr89.3%

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

    \[\leadsto \color{blue}{2 \cdot \left(x.im \cdot {x.re}^{2}\right)} \]
  7. Simplified20.4%

    \[\leadsto \color{blue}{-x.re \cdot x.re} \]
  8. Final simplification20.4%

    \[\leadsto x.re \cdot \left(-x.re\right) \]

Alternative 14: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} \\ -3 \end{array} \]
(FPCore (x.re x.im) :precision binary64 -3.0)
double code(double x_46_re, double x_46_im) {
	return -3.0;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -3.0d0
end function
public static double code(double x_46_re, double x_46_im) {
	return -3.0;
}
def code(x_46_re, x_46_im):
	return -3.0
function code(x_46_re, x_46_im)
	return -3.0
end
function tmp = code(x_46_re, x_46_im)
	tmp = -3.0;
end
code[x$46$re_, x$46$im_] := -3.0
\begin{array}{l}

\\
-3
\end{array}
Derivation
  1. Initial program 78.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. Taylor expanded in x.re around 0 57.9%

    \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
  3. Simplified2.7%

    \[\leadsto \color{blue}{-3} \]
  4. Final simplification2.7%

    \[\leadsto -3 \]

Developer target: 91.8% 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 2023279 
(FPCore (x.re x.im)
  :name "math.cube on complex, imaginary part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.im) (* 2.0 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)))