math.cube on complex, imaginary part

Percentage Accurate: 82.3% → 99.7%
Time: 7.0s
Alternatives: 16
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 16 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.4 \cdot 10^{+103} \lor \neg \left(x.im \leq 2 \cdot 10^{+87}\right):\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.im \cdot x.re\right), 3, -{x.im}^{3}\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -3.4e+103) (not (<= x.im 2e+87)))
   (+ (+ x.im x.im) (* (+ x.im x.re) (* x.im (- x.re x.im))))
   (fma (* x.re (* x.im x.re)) 3.0 (- (pow x.im 3.0)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -3.4e+103) || !(x_46_im <= 2e+87)) {
		tmp = (x_46_im + x_46_im) + ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im)));
	} else {
		tmp = fma((x_46_re * (x_46_im * x_46_re)), 3.0, -pow(x_46_im, 3.0));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -3.4e+103) || !(x_46_im <= 2e+87))
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_im + x_46_re) * Float64(x_46_im * Float64(x_46_re - x_46_im))));
	else
		tmp = fma(Float64(x_46_re * Float64(x_46_im * x_46_re)), 3.0, Float64(-(x_46_im ^ 3.0)));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -3.4e+103], N[Not[LessEqual[x$46$im, 2e+87]], $MachinePrecision]], N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * 3.0 + (-N[Power[x$46$im, 3.0], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.3999999999999998e103 or 1.9999999999999999e87 < x.im

    1. Initial program 71.8%

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

        \[\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. *-commutative71.8%

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

        \[\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. *-commutative76.5%

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

        \[\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. *-commutative76.5%

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

      \[\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. *-commutative76.5%

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

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

        \[\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-+83.5%

        \[\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 -3.3999999999999998e103 < x.im < 1.9999999999999999e87

    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 \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. *-commutative88.9%

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

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

        \[\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+88.9%

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

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

        \[\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*99.7%

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

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

        \[\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-299.7%

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

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

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

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

        \[\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*99.7%

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

        \[\leadsto x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - \color{blue}{{x.im}^{3}} \]
    3. Simplified99.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*99.8%

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

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

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

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

Alternative 2: 99.7% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.3999999999999998e103 or 1.9999999999999999e87 < x.im

    1. Initial program 71.8%

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

        \[\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. *-commutative71.8%

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

        \[\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. *-commutative76.5%

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

        \[\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. *-commutative76.5%

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

      \[\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. *-commutative76.5%

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

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

        \[\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-+83.5%

        \[\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 -3.3999999999999998e103 < x.im < 1.9999999999999999e87

    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 \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. *-commutative88.9%

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

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

        \[\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+88.9%

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

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

        \[\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*99.7%

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

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

        \[\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-299.7%

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

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

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

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

        \[\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*99.7%

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

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

      \[\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 99.8%

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

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

Alternative 3: 99.8% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.3999999999999998e103 or 1.9999999999999999e87 < x.im

    1. Initial program 71.8%

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

        \[\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. *-commutative71.8%

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

        \[\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. *-commutative76.5%

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

        \[\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. *-commutative76.5%

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

      \[\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. *-commutative76.5%

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

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

        \[\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-+83.5%

        \[\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 -3.3999999999999998e103 < x.im < 1.9999999999999999e87

    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 \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. *-commutative88.9%

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

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

        \[\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+88.9%

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

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

        \[\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*99.7%

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

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

        \[\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-299.7%

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

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

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

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

        \[\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*99.7%

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

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

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

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

Alternative 4: 98.0% 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.im \cdot x.re + x.im \cdot x.re\right)\\ t_1 := \left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{if}\;x.im \leq -1.5 \cdot 10^{+137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq -1.12 \cdot 10^{-107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 2.7 \cdot 10^{-73}:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right)\right) \cdot 3\\ \mathbf{elif}\;x.im \leq 10^{+58}:\\ \;\;\;\;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.im x.re) (* x.im x.re)))))
        (t_1 (+ (+ x.im x.im) (* (+ x.im x.re) (* x.im (- x.re x.im))))))
   (if (<= x.im -1.5e+137)
     t_1
     (if (<= x.im -1.12e-107)
       t_0
       (if (<= x.im 2.7e-73)
         (* (* x.re (* x.im x.re)) 3.0)
         (if (<= x.im 1e+58) 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_im * x_46_re) + (x_46_im * x_46_re)));
	double t_1 = (x_46_im + x_46_im) + ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im)));
	double tmp;
	if (x_46_im <= -1.5e+137) {
		tmp = t_1;
	} else if (x_46_im <= -1.12e-107) {
		tmp = t_0;
	} else if (x_46_im <= 2.7e-73) {
		tmp = (x_46_re * (x_46_im * x_46_re)) * 3.0;
	} else if (x_46_im <= 1e+58) {
		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_46im * x_46re) + (x_46im * x_46re)))
    t_1 = (x_46im + x_46im) + ((x_46im + x_46re) * (x_46im * (x_46re - x_46im)))
    if (x_46im <= (-1.5d+137)) then
        tmp = t_1
    else if (x_46im <= (-1.12d-107)) then
        tmp = t_0
    else if (x_46im <= 2.7d-73) then
        tmp = (x_46re * (x_46im * x_46re)) * 3.0d0
    else if (x_46im <= 1d+58) 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_im * x_46_re) + (x_46_im * x_46_re)));
	double t_1 = (x_46_im + x_46_im) + ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im)));
	double tmp;
	if (x_46_im <= -1.5e+137) {
		tmp = t_1;
	} else if (x_46_im <= -1.12e-107) {
		tmp = t_0;
	} else if (x_46_im <= 2.7e-73) {
		tmp = (x_46_re * (x_46_im * x_46_re)) * 3.0;
	} else if (x_46_im <= 1e+58) {
		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_im * x_46_re) + (x_46_im * x_46_re)))
	t_1 = (x_46_im + x_46_im) + ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im)))
	tmp = 0
	if x_46_im <= -1.5e+137:
		tmp = t_1
	elif x_46_im <= -1.12e-107:
		tmp = t_0
	elif x_46_im <= 2.7e-73:
		tmp = (x_46_re * (x_46_im * x_46_re)) * 3.0
	elif x_46_im <= 1e+58:
		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_im * x_46_re) + Float64(x_46_im * x_46_re))))
	t_1 = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_im + x_46_re) * Float64(x_46_im * Float64(x_46_re - x_46_im))))
	tmp = 0.0
	if (x_46_im <= -1.5e+137)
		tmp = t_1;
	elseif (x_46_im <= -1.12e-107)
		tmp = t_0;
	elseif (x_46_im <= 2.7e-73)
		tmp = Float64(Float64(x_46_re * Float64(x_46_im * x_46_re)) * 3.0);
	elseif (x_46_im <= 1e+58)
		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_im * x_46_re) + (x_46_im * x_46_re)));
	t_1 = (x_46_im + x_46_im) + ((x_46_im + x_46_re) * (x_46_im * (x_46_re - x_46_im)));
	tmp = 0.0;
	if (x_46_im <= -1.5e+137)
		tmp = t_1;
	elseif (x_46_im <= -1.12e-107)
		tmp = t_0;
	elseif (x_46_im <= 2.7e-73)
		tmp = (x_46_re * (x_46_im * x_46_re)) * 3.0;
	elseif (x_46_im <= 1e+58)
		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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -1.5e+137], t$95$1, If[LessEqual[x$46$im, -1.12e-107], t$95$0, If[LessEqual[x$46$im, 2.7e-73], N[(N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision], If[LessEqual[x$46$im, 1e+58], 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.im \cdot x.re + x.im \cdot x.re\right)\\
t_1 := \left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\
\mathbf{if}\;x.im \leq -1.5 \cdot 10^{+137}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;x.im \leq 10^{+58}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -1.5e137 or 9.99999999999999944e57 < x.im

    1. Initial program 70.4%

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

        \[\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. *-commutative70.4%

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

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

        \[\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-+82.7%

        \[\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 -1.5e137 < x.im < -1.12e-107 or 2.69999999999999994e-73 < x.im < 9.99999999999999944e57

    1. Initial program 97.3%

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

    if -1.12e-107 < x.im < 2.69999999999999994e-73

    1. Initial program 83.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 83.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. Simplified83.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. *-commutative83.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. *-commutative83.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-out83.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-exp62.7%

        \[\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-exp62.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-log62.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-sqr62.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. *-commutative62.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-exp83.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*83.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-in83.4%

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity83.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-out83.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.5 \cdot 10^{+137}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq -1.12 \cdot 10^{-107}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{elif}\;x.im \leq 2.7 \cdot 10^{-73}:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right)\right) \cdot 3\\ \mathbf{elif}\;x.im \leq 10^{+58}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 5: 91.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x.im \leq -1.38 \cdot 10^{-83}:\\
\;\;\;\;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 10000000:\\
\;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right)\right) \cdot 3\\

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


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

    1. Initial program 73.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. +-commutative73.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. *-commutative73.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-def77.5%

        \[\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. *-commutative77.5%

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

        \[\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. *-commutative77.5%

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

      \[\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. *-commutative77.5%

        \[\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-def73.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-in73.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-+83.3%

        \[\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-squares99.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*99.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-rr99.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.99999999999999921e133 < x.im < -1.37999999999999997e-83

    1. Initial program 97.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. *-commutative97.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. *-commutative97.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-+90.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-rr90.4%

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

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

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

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

      \[\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 -1.37999999999999997e-83 < x.im < 1e7

    1. Initial program 85.4%

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

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

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

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

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

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

        \[\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-exp57.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-log57.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-sqr57.6%

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity80.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-out80.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1 \cdot 10^{+134}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq -1.38 \cdot 10^{-83}:\\ \;\;\;\;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 10000000:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right)\right) \cdot 3\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im + x.re\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 6: 85.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.3 \cdot 10^{-82} \lor \neg \left(x.im \leq 1.25 \cdot 10^{-40}\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.im \cdot x.re\right)\right) \cdot 3\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.3e-82 or 1.24999999999999991e-40 < x.im

    1. Initial program 82.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. *-commutative82.2%

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

        \[\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-+81.0%

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

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

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

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

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

      \[\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 -1.3e-82 < x.im < 1.24999999999999991e-40

    1. Initial program 84.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 82.9%

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

      \[\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. *-commutative82.9%

        \[\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. *-commutative82.9%

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

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

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

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

        \[\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-sqr58.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. *-commutative58.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-exp82.9%

        \[\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*82.8%

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

        \[\leadsto \color{blue}{\left(x.re \cdot x.re\right) \cdot \left(x.im + 2 \cdot x.im\right)} \]
      12. *-un-lft-identity82.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-out82.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.3 \cdot 10^{-82} \lor \neg \left(x.im \leq 1.25 \cdot 10^{-40}\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.im \cdot x.re\right)\right) \cdot 3\\ \end{array} \]

Alternative 7: 84.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -31000000 \lor \neg \left(x.im \leq 8000\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + -3\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.re\right)\right) \cdot 3\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -31000000.0) (not (<= x.im 8000.0)))
   (+ (* x.im (- (* x.re x.re) (* x.im x.im))) -3.0)
   (* (* x.re (* x.im x.re)) 3.0)))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -31000000.0) || !(x_46_im <= 8000.0)) {
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + -3.0;
	} 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 <= (-31000000.0d0)) .or. (.not. (x_46im <= 8000.0d0))) then
        tmp = (x_46im * ((x_46re * x_46re) - (x_46im * x_46im))) + (-3.0d0)
    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 <= -31000000.0) || !(x_46_im <= 8000.0)) {
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + -3.0;
	} 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 <= -31000000.0) or not (x_46_im <= 8000.0):
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + -3.0
	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 <= -31000000.0) || !(x_46_im <= 8000.0))
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + -3.0);
	else
		tmp = Float64(Float64(x_46_re * Float64(x_46_im * 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 <= -31000000.0) || ~((x_46_im <= 8000.0)))
		tmp = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + -3.0;
	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, -31000000.0], N[Not[LessEqual[x$46$im, 8000.0]], $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] + -3.0), $MachinePrecision], N[(N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -31000000 \lor \neg \left(x.im \leq 8000\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.1e7 or 8e3 < x.im

    1. Initial program 78.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. *-commutative78.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. *-commutative78.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-+81.7%

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

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

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

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

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

    if -3.1e7 < x.im < 8e3

    1. Initial program 86.8%

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

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

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

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

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

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

        \[\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-exp55.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-log55.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-sqr55.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. *-commutative55.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-exp76.7%

        \[\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*76.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-in76.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right)} \cdot 3 \]
    5. Applied egg-rr89.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 simplification88.5%

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

Alternative 8: 59.9% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.39999999999999996e192 or 1.59999999999999992e248 < x.im

    1. Initial program 58.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. +-commutative58.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. *-commutative58.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-neg58.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-in58.1%

        \[\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+58.1%

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

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

        \[\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*58.1%

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

        \[\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. *-commutative58.1%

        \[\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-258.1%

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

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

        \[\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. *-commutative58.1%

        \[\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. *-commutative58.1%

        \[\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*58.1%

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

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

      \[\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*58.1%

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

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

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

      \[\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 0.6%

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

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

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

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

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

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

    if -3.39999999999999996e192 < x.im < 1.59999999999999992e248

    1. Initial program 86.7%

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

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

      \[\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. *-commutative58.9%

        \[\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. *-commutative58.9%

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

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

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

        \[\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-log45.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-sqr45.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. *-commutative45.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-exp58.9%

        \[\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*58.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 59.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -6.9 \cdot 10^{+187} \lor \neg \left(x.im \leq 1.6 \cdot 10^{+248}\right):\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -6.8999999999999997e187 or 1.59999999999999992e248 < x.im

    1. Initial program 58.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. +-commutative58.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. *-commutative58.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-neg58.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-in58.1%

        \[\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+58.1%

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

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

        \[\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*58.1%

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

        \[\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. *-commutative58.1%

        \[\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-258.1%

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

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

        \[\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. *-commutative58.1%

        \[\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. *-commutative58.1%

        \[\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*58.1%

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

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

      \[\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*58.1%

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

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

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

      \[\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 0.6%

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

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

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

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

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

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

    if -6.8999999999999997e187 < x.im < 1.59999999999999992e248

    1. Initial program 86.7%

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

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

      \[\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. *-commutative58.9%

        \[\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. *-commutative58.9%

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

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

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

        \[\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-log45.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-sqr45.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. *-commutative45.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-exp58.9%

        \[\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*58.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 59.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.8 \cdot 10^{+190} \lor \neg \left(x.im \leq 1.65 \cdot 10^{+248}\right):\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(-x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.79999999999999989e190 or 1.6500000000000001e248 < x.im

    1. Initial program 58.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. +-commutative58.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. *-commutative58.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-neg58.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-in58.1%

        \[\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+58.1%

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

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

        \[\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*58.1%

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

        \[\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. *-commutative58.1%

        \[\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-258.1%

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

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

        \[\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. *-commutative58.1%

        \[\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. *-commutative58.1%

        \[\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*58.1%

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

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

      \[\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*58.1%

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

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

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

      \[\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 0.6%

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

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

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

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

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

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

    if -1.79999999999999989e190 < x.im < 1.6500000000000001e248

    1. Initial program 86.7%

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

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

      \[\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. *-commutative58.9%

        \[\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. *-commutative58.9%

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

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

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

        \[\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-log45.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-sqr45.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. *-commutative45.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-exp58.9%

        \[\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*58.9%

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

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

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

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

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

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

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

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

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

Alternative 11: 39.1% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.9999999999999998e187 or 1.59999999999999992e248 < x.im

    1. Initial program 58.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. +-commutative58.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. *-commutative58.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-neg58.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-in58.1%

        \[\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+58.1%

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

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

        \[\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*58.1%

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

        \[\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. *-commutative58.1%

        \[\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-258.1%

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

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

        \[\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. *-commutative58.1%

        \[\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. *-commutative58.1%

        \[\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*58.1%

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

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

      \[\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*58.1%

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

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

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

      \[\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 0.6%

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

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

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

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

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

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

    if -5.9999999999999998e187 < x.im < 1.59999999999999992e248

    1. Initial program 86.7%

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

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

        \[\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-+66.1%

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

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

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

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

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

Alternative 12: 34.3% accurate, 3.8× speedup?

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

\\
x.im \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 83.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. *-commutative83.2%

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

      \[\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-+66.7%

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

    \[\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 39.4%

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

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

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

Alternative 13: 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 83.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 51.9%

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

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

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

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

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

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

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

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

Alternative 14: 3.6% accurate, 6.3× speedup?

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

\\
x.re + x.re
\end{array}
Derivation
  1. Initial program 83.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 51.9%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3 \cdot x.re} \]
  8. Simplified3.9%

    \[\leadsto \color{blue}{x.re + x.re} \]
  9. Final simplification3.9%

    \[\leadsto x.re + x.re \]

Alternative 15: 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 83.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. +-commutative83.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. *-commutative83.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-neg83.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-in80.1%

      \[\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+80.1%

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

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

      \[\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*87.3%

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

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

      \[\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-287.3%

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

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

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

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

      \[\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*87.3%

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

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

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

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

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

    \[\leadsto -3 \]

Alternative 16: 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 83.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. +-commutative83.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. *-commutative83.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-neg83.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-in80.1%

      \[\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+80.1%

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

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

      \[\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*87.3%

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

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

      \[\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-287.3%

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

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

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

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

      \[\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*87.3%

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

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

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

      \[\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*87.3%

      \[\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*87.4%

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

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

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

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

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

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

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

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

    \[\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.1% 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 2023182 
(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)))