math.cube on complex, imaginary part

Percentage Accurate: 82.9% → 98.5%
Time: 7.1s
Alternatives: 13
Speedup: 1.3×

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 13 alternatives:

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

Initial Program: 82.9% 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: 98.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
t_1 := \left(x.im + 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 -1 \cdot 10^{+119}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x.im \leq -1.5 \cdot 10^{-109}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.im \leq 9 \cdot 10^{+33}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -9.99999999999999944e118 or 9.0000000000000001e33 < x.im

    1. Initial program 61.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. +-commutative61.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. *-commutative61.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-def75.0%

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

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

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

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

      \[\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. *-commutative75.0%

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. 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}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. +-inverses0.0%

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

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

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{0}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      8. metadata-eval0.0%

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      9. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      10. metadata-eval0.0%

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

        \[\leadsto \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      12. distribute-lft-out--0.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      18. 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 \]
      19. associate-*l*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)} \]
    5. Applied egg-rr100.0%

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

    if -9.99999999999999944e118 < x.im < -1.50000000000000011e-109 or 5.99999999999999985e-145 < x.im < 9.0000000000000001e33

    1. Initial program 98.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 \]

    if -1.50000000000000011e-109 < x.im < 5.99999999999999985e-145

    1. Initial program 80.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. Taylor expanded in x.re around inf 80.5%

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

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative80.5%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp56.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log56.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr56.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative56.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp80.5%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \left(\color{blue}{1 \cdot x.im} + 2 \cdot x.im\right) \]
      13. distribute-rgt-out80.6%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot \left(1 + 2\right)\right)} \]
      14. metadata-eval80.6%

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1 \cdot 10^{+119}:\\ \;\;\;\;\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.5 \cdot 10^{-109}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 6 \cdot 10^{-145}:\\ \;\;\;\;\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\\ \mathbf{elif}\;x.im \leq 9 \cdot 10^{+33}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{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.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.re \cdot x.im\right), 3, -{x.im}^{3}\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} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (fma (* x.re (* x.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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re * (x_46_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;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = fma(Float64(x_46_re * Float64(x_46_re * x_46_im)), 3.0, Float64(-(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
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] * 3.0 + (-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.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.re \cdot x.im\right), 3, -{x.im}^{3}\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 92.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. +-commutative92.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. *-commutative92.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      13. metadata-eval97.9%

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      16. associate-*r*97.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      17. cube-unmult98.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re \cdot \left(x.re \cdot x.im\right), 3, -{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-def34.3%

        \[\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. *-commutative34.3%

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

        \[\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. *-commutative34.3%

        \[\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. Simplified34.3%

      \[\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. *-commutative34.3%

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. 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}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. +-inverses0.0%

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

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

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{0}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      8. metadata-eval0.0%

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      9. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      10. metadata-eval0.0%

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

        \[\leadsto \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      12. distribute-lft-out--0.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      18. 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 \]
      19. associate-*l*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)} \]
    5. Applied egg-rr100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.re \cdot x.im\right), 3, -{x.im}^{3}\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 3: 97.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;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.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re 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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = (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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 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_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = 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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 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$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * 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.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;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 92.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. +-commutative92.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. *-commutative92.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      13. metadata-eval97.9%

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      16. associate-*r*97.9%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      17. cube-unmult98.0%

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

      \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\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-def34.3%

        \[\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. *-commutative34.3%

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

        \[\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. *-commutative34.3%

        \[\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. Simplified34.3%

      \[\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. *-commutative34.3%

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. 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}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. +-inverses0.0%

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

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

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{0}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      8. metadata-eval0.0%

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      9. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      10. metadata-eval0.0%

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

        \[\leadsto \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      12. distribute-lft-out--0.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      18. 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 \]
      19. associate-*l*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)} \]
    5. Applied egg-rr100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \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: 88.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re + x.re\right)\right)\\ \mathbf{if}\;x.im \leq -5.8 \cdot 10^{-53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 5.5 \cdot 10^{-82}:\\ \;\;\;\;\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\\ \mathbf{elif}\;x.im \leq 1.32 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 10^{-7}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\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} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (+ (- (* x.re x.re) (* x.im x.im)) (+ x.re x.re)))))
   (if (<= x.im -5.8e-53)
     t_0
     (if (<= x.im 5.5e-82)
       (* (* x.re (* x.re x.im)) 3.0)
       (if (<= x.im 1.32e-11)
         t_0
         (if (<= x.im 1e-7)
           (* (* x.re x.im) (* x.re 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 t_0 = x_46_im * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) + (x_46_re + x_46_re));
	double tmp;
	if (x_46_im <= -5.8e-53) {
		tmp = t_0;
	} else if (x_46_im <= 5.5e-82) {
		tmp = (x_46_re * (x_46_re * x_46_im)) * 3.0;
	} else if (x_46_im <= 1.32e-11) {
		tmp = t_0;
	} else if (x_46_im <= 1e-7) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 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;
}
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_46re * x_46re) - (x_46im * x_46im)) + (x_46re + x_46re))
    if (x_46im <= (-5.8d-53)) then
        tmp = t_0
    else if (x_46im <= 5.5d-82) then
        tmp = (x_46re * (x_46re * x_46im)) * 3.0d0
    else if (x_46im <= 1.32d-11) then
        tmp = t_0
    else if (x_46im <= 1d-7) then
        tmp = (x_46re * x_46im) * (x_46re * 3.0d0)
    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_im * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) + (x_46_re + x_46_re));
	double tmp;
	if (x_46_im <= -5.8e-53) {
		tmp = t_0;
	} else if (x_46_im <= 5.5e-82) {
		tmp = (x_46_re * (x_46_re * x_46_im)) * 3.0;
	} else if (x_46_im <= 1.32e-11) {
		tmp = t_0;
	} else if (x_46_im <= 1e-7) {
		tmp = (x_46_re * x_46_im) * (x_46_re * 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):
	t_0 = x_46_im * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) + (x_46_re + x_46_re))
	tmp = 0
	if x_46_im <= -5.8e-53:
		tmp = t_0
	elif x_46_im <= 5.5e-82:
		tmp = (x_46_re * (x_46_re * x_46_im)) * 3.0
	elif x_46_im <= 1.32e-11:
		tmp = t_0
	elif x_46_im <= 1e-7:
		tmp = (x_46_re * x_46_im) * (x_46_re * 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)
	t_0 = Float64(x_46_im * Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) + Float64(x_46_re + x_46_re)))
	tmp = 0.0
	if (x_46_im <= -5.8e-53)
		tmp = t_0;
	elseif (x_46_im <= 5.5e-82)
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * x_46_im)) * 3.0);
	elseif (x_46_im <= 1.32e-11)
		tmp = t_0;
	elseif (x_46_im <= 1e-7)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re * 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)
	t_0 = x_46_im * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) + (x_46_re + x_46_re));
	tmp = 0.0;
	if (x_46_im <= -5.8e-53)
		tmp = t_0;
	elseif (x_46_im <= 5.5e-82)
		tmp = (x_46_re * (x_46_re * x_46_im)) * 3.0;
	elseif (x_46_im <= 1.32e-11)
		tmp = t_0;
	elseif (x_46_im <= 1e-7)
		tmp = (x_46_re * x_46_im) * (x_46_re * 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_] := Block[{t$95$0 = N[(x$46$im * N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -5.8e-53], t$95$0, If[LessEqual[x$46$im, 5.5e-82], N[(N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision], If[LessEqual[x$46$im, 1.32e-11], t$95$0, If[LessEqual[x$46$im, 1e-7], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 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}
t_0 := x.im \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re + x.re\right)\right)\\
\mathbf{if}\;x.im \leq -5.8 \cdot 10^{-53}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.im \leq 1.32 \cdot 10^{-11}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x.im \leq 10^{-7}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\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}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.im < -5.7999999999999996e-53 or 5.4999999999999998e-82 < x.im < 1.32e-11

    1. Initial program 81.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. *-commutative81.5%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + 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}} \]
      4. +-inverses0.0%

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. associate-*r/0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} \]
      11. distribute-lft-out--0.0%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{\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)}}{\log 1} \]
      14. metadata-eval0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{0}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{x.re \cdot x.im - x.re \cdot x.im}} \]
      16. flip-+78.6%

        \[\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-rr78.6%

      \[\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. *-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.re \cdot x.im\right) \]
      2. distribute-rgt-out78.6%

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

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

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

    if -5.7999999999999996e-53 < x.im < 5.4999999999999998e-82

    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. Taylor expanded in x.re around inf 80.1%

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp80.1%

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity80.2%

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

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

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*95.8%

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

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

    if 1.32e-11 < x.im < 9.9999999999999995e-8

    1. Initial program 99.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Taylor expanded in x.re around inf 99.2%

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

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative99.2%

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \]
      4. add-log-exp51.6%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp50.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log50.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr52.3%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative52.3%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp99.2%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \left(\color{blue}{1 \cdot x.im} + 2 \cdot x.im\right) \]
      13. distribute-rgt-out98.0%

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

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*99.2%

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

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

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

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

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

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

    if 9.9999999999999995e-8 < x.im

    1. Initial program 69.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Step-by-step derivation
      1. +-commutative69.2%

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

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

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

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

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

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

      \[\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. *-commutative75.3%

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      4. 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}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      5. +-inverses0.0%

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

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

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{0}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      8. metadata-eval0.0%

        \[\leadsto x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      9. associate-*r/0.0%

        \[\leadsto \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      10. metadata-eval0.0%

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

        \[\leadsto \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      12. distribute-lft-out--0.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.im + x.im\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      18. difference-of-squares98.7%

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

        \[\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)} \]
    5. Applied egg-rr98.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -5.8 \cdot 10^{-53}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 5.5 \cdot 10^{-82}:\\ \;\;\;\;\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\\ \mathbf{elif}\;x.im \leq 1.32 \cdot 10^{-11}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 10^{-7}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\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 5: 86.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -8.2 \cdot 10^{-53} \lor \neg \left(x.im \leq 2.9 \cdot 10^{-79}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -8.2000000000000001e-53 or 2.9000000000000001e-79 < x.im

    1. Initial program 76.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. *-commutative76.5%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + 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}} \]
      4. +-inverses0.0%

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. associate-*r/0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} \]
      11. distribute-lft-out--0.0%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{\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)}}{\log 1} \]
      14. metadata-eval0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{0}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{x.re \cdot x.im - x.re \cdot x.im}} \]
      16. flip-+74.6%

        \[\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-rr74.6%

      \[\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. *-commutative74.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.re \cdot x.im\right) \]
      2. distribute-rgt-out74.6%

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

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

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

    if -8.2000000000000001e-53 < x.im < 2.9000000000000001e-79

    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. Taylor expanded in x.re around inf 80.1%

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative53.1%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp80.1%

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity80.2%

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

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

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*95.8%

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

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

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

Alternative 6: 84.2% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -170000000 \lor \neg \left(x.im \leq 10^{-7}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + -2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.7e8 or 9.9999999999999995e-8 < x.im

    1. Initial program 71.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. *-commutative71.5%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + 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}} \]
      4. +-inverses0.0%

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. associate-*r/0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} \]
      11. distribute-lft-out--0.0%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{\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)}}{\log 1} \]
      14. metadata-eval0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{0}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{x.re \cdot x.im - x.re \cdot x.im}} \]
      16. flip-+75.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-rr75.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. expm1-log1p-u44.2%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.re \cdot x.im + x.re \cdot x.im\right)\right)} \]
      2. expm1-udef44.2%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\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}}\right)} - 1\right) \]
      4. +-inverses0.0%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0}{0}\right)} - 1\right)} \]
    6. Simplified85.3%

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

    if -1.7e8 < x.im < 9.9999999999999995e-8

    1. Initial program 87.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. Taylor expanded in x.re around inf 71.8%

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

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative71.8%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp46.6%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log46.6%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr46.7%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative46.7%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp71.8%

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity71.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \left(\color{blue}{1 \cdot x.im} + 2 \cdot x.im\right) \]
      13. distribute-rgt-out71.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot \left(1 + 2\right)\right)} \]
      14. metadata-eval71.8%

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*84.5%

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

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

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

Alternative 7: 60.7% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -8.5 \cdot 10^{+118} \lor \neg \left(x.im \leq 6 \cdot 10^{+167}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -8.50000000000000033e118 or 6.00000000000000023e167 < x.im

    1. Initial program 56.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Step-by-step derivation
      1. +-commutative56.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{2 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      12. distribute-lft1-in54.8%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      13. metadata-eval54.8%

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      16. associate-*r*54.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(-x.re \cdot x.re\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out37.4%

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.re \cdot x.im\right)} \]
    9. Applied egg-rr37.4%

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

    if -8.50000000000000033e118 < x.im < 6.00000000000000023e167

    1. Initial program 88.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. Taylor expanded in x.re around inf 63.3%

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

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative63.3%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp63.3%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \left(\color{blue}{1 \cdot x.im} + 2 \cdot x.im\right) \]
      13. distribute-rgt-out63.4%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot \left(1 + 2\right)\right)} \]
      14. metadata-eval63.4%

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*72.5%

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

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

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

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

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

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

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

Alternative 8: 60.7% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -8 \cdot 10^{+118} \lor \neg \left(x.im \leq 3.4 \cdot 10^{+167}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -7.99999999999999973e118 or 3.4e167 < x.im

    1. Initial program 56.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Step-by-step derivation
      1. +-commutative56.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{2 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      12. distribute-lft1-in54.8%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      13. metadata-eval54.8%

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      16. associate-*r*54.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(-x.re \cdot x.re\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out37.4%

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.re \cdot x.im\right)} \]
    9. Applied egg-rr37.4%

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

    if -7.99999999999999973e118 < x.im < 3.4e167

    1. Initial program 88.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. Taylor expanded in x.re around inf 63.3%

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

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative63.3%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\color{blue}{\log \left(e^{x.im}\right)} + x.im\right)\right) \]
      5. add-log-exp42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \left(\log \left(e^{x.im}\right) + \color{blue}{\log \left(e^{x.im}\right)}\right)\right) \]
      6. sum-log42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \color{blue}{\log \left(e^{x.im} \cdot e^{x.im}\right)}\right) \]
      7. exp-lft-sqr42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \color{blue}{\left(e^{x.im \cdot 2}\right)}\right) \]
      8. *-commutative42.8%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + x.re \cdot \left(x.re \cdot \log \left(e^{\color{blue}{2 \cdot x.im}}\right)\right) \]
      9. add-log-exp63.3%

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

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

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

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \left(\color{blue}{1 \cdot x.im} + 2 \cdot x.im\right) \]
      13. distribute-rgt-out63.4%

        \[\leadsto \left(x.re \cdot x.re\right) \cdot \color{blue}{\left(x.im \cdot \left(1 + 2\right)\right)} \]
      14. metadata-eval63.4%

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

        \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3} \]
      16. associate-*r*72.5%

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

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

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

Alternative 9: 39.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -9 \cdot 10^{+118} \lor \neg \left(x.im \leq 2.35 \cdot 10^{+169}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\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+118) (not (<= x.im 2.35e+169)))
   (* 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+118) || !(x_46_im <= 2.35e+169)) {
		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+118)) .or. (.not. (x_46im <= 2.35d+169))) 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+118) || !(x_46_im <= 2.35e+169)) {
		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+118) or not (x_46_im <= 2.35e+169):
		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+118) || !(x_46_im <= 2.35e+169))
		tmp = Float64(x_46_re * Float64(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+118) || ~((x_46_im <= 2.35e+169)))
		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+118], N[Not[LessEqual[x$46$im, 2.35e+169]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * (-x$46$im)), $MachinePrecision]), $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^{+118} \lor \neg \left(x.im \leq 2.35 \cdot 10^{+169}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\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.00000000000000004e118 or 2.3499999999999999e169 < x.im

    1. Initial program 56.2%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    2. Step-by-step derivation
      1. +-commutative56.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{2 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      12. distribute-lft1-in54.8%

        \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
      13. metadata-eval54.8%

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

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

        \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
      16. associate-*r*54.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(-x.re \cdot x.re\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out37.4%

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.re \cdot x.im\right)} \]
    9. Applied egg-rr37.4%

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

    if -9.00000000000000004e118 < x.im < 2.3499999999999999e169

    1. Initial program 88.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. *-commutative88.9%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + 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}} \]
      4. +-inverses0.0%

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
      8. associate-*r/0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} \]
      9. metadata-eval0.0%

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} \]
      11. distribute-lft-out--0.0%

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{\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)}}{\log 1} \]
      14. metadata-eval0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{0}} \]
      15. +-inverses0.0%

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{x.re \cdot x.im - x.re \cdot x.im}} \]
      16. flip-+60.3%

        \[\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-rr60.3%

      \[\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. Taylor expanded in x.re around inf 42.9%

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

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

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

Alternative 10: 34.5% 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 79.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. *-commutative79.5%

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + 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}} \]
    4. +-inverses0.0%

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \frac{\log 1}{\color{blue}{\log 1}} \]
    8. associate-*r/0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{x.re \cdot \log 1}{\log 1}} \]
    9. metadata-eval0.0%

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.re \cdot \color{blue}{\left(x.im - x.im\right)}}{\log 1} \]
    11. distribute-lft-out--0.0%

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{\color{blue}{\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)}}{\log 1} \]
    14. metadata-eval0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{0}} \]
    15. +-inverses0.0%

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \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)}{\color{blue}{x.re \cdot x.im - x.re \cdot x.im}} \]
    16. flip-+63.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-rr63.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. Taylor expanded in x.re around inf 33.5%

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

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

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

Alternative 11: 3.6% accurate, 6.3× speedup?

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

\\
x.re \cdot -3
\end{array}
Derivation
  1. Initial program 79.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. Taylor expanded in x.re around inf 48.1%

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

    \[\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 \]
  4. Step-by-step derivation
    1. expm1-log1p-u37.3%

      \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.re \cdot x.im + x.im \cdot x.re\right)\right)} \cdot x.re \]
    2. expm1-udef27.8%

      \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot x.im + x.im \cdot x.re\right)} - 1\right)} \cdot x.re \]
    3. *-commutative27.8%

      \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.im \cdot x.re} + x.im \cdot x.re\right)} - 1\right) \cdot x.re \]
    4. flip-+0.0%

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

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

      \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\frac{0}{\color{blue}{0}}\right)} - 1\right) \cdot x.re \]
  5. Applied egg-rr0.0%

    \[\leadsto \left(x.re \cdot x.re\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0}{0}\right)} - 1\right)} \cdot x.re \]
  6. Simplified17.6%

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

    \[\leadsto \color{blue}{-3 \cdot x.re} \]
  8. Final simplification3.7%

    \[\leadsto x.re \cdot -3 \]

Alternative 12: 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 79.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. +-commutative79.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. *-commutative79.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
    13. metadata-eval84.5%

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

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

      \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
    16. associate-*r*84.5%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
    17. cube-unmult84.6%

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

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

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

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

    \[\leadsto -3 \]

Alternative 13: 2.7% accurate, 19.0× speedup?

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

\\
0.1
\end{array}
Derivation
  1. Initial program 79.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. +-commutative79.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. *-commutative79.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \left(x.im \cdot x.re\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
    13. metadata-eval84.5%

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

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

      \[\leadsto x.re \cdot \left(\color{blue}{\left(x.re \cdot x.im\right)} \cdot 3\right) - x.im \cdot \left(x.im \cdot x.im\right) \]
    16. associate-*r*84.5%

      \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} - x.im \cdot \left(x.im \cdot x.im\right) \]
    17. cube-unmult84.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{{\color{blue}{\left(\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\right)}}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    7. unpow-prod-down8.0%

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

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

      \[\leadsto \frac{\color{blue}{{x.re}^{\left(2 \cdot 3\right)}} \cdot {\left(x.im \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    10. metadata-eval8.0%

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

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

    \[\leadsto \color{blue}{0.1} \]
  7. Final simplification2.7%

    \[\leadsto 0.1 \]

Developer target: 91.2% 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 2023188 
(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)))