math.cube on complex, imaginary part

Percentage Accurate: 82.9% → 99.8%
Time: 8.2s
Alternatives: 16
Speedup: 0.9×

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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.2000000000000003e103 or 2.00000000000000004e95 < 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-def77.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2000000000000003e103 < x.im < 2.00000000000000004e95

    1. Initial program 87.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. +-commutative87.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. *-commutative87.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-neg87.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-in87.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+87.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-out87.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-neg87.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*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.2000000000000003e103 or 1.99999999999999992e88 < 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-def77.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2000000000000003e103 < x.im < 1.99999999999999992e88

    1. Initial program 87.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. +-commutative87.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. *-commutative87.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-neg87.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-in87.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+87.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-out87.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-neg87.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*99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.2000000000000003e103 or 2.00000000000000004e95 < 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-def77.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2000000000000003e103 < x.im < 2.00000000000000004e95

    1. Initial program 87.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. +-commutative87.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. *-commutative87.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-neg87.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-in87.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+87.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-out87.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-neg87.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*99.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{\left(3 \cdot \left(x.re \cdot x.im\right)\right)} - {x.im}^{3} \]
    5. Step-by-step derivation
      1. expm1-log1p-u82.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(3 \cdot \left(x.re \cdot x.im\right)\right)\right)} - {x.im}^{3} \]
      2. expm1-udef57.7%

        \[\leadsto x.re \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(3 \cdot \left(x.re \cdot x.im\right)\right)} - 1\right)} - {x.im}^{3} \]
    6. Applied egg-rr57.7%

      \[\leadsto x.re \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(3 \cdot \left(x.re \cdot x.im\right)\right)} - 1\right)} - {x.im}^{3} \]
    7. Step-by-step derivation
      1. expm1-def82.8%

        \[\leadsto x.re \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(3 \cdot \left(x.re \cdot x.im\right)\right)\right)} - {x.im}^{3} \]
      2. expm1-log1p99.7%

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

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

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

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

Alternative 4: 94.3% accurate, 0.5× 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)\\ \mathbf{if}\;t_0 \leq \infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.im x.re) (* x.im x.re))))))
   (if (<= t_0 INFINITY)
     t_0
     (+ (+ x.im x.im) (* x.im (* (- x.re x.im) (+ x.im x.re)))))))
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 tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + x_46_im) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + x_46_im) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	}
	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)))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = (x_46_im + x_46_im) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)))
	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))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))));
	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)));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = (x_46_im + x_46_im) + (x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)));
	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]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 90.5%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.2% accurate, 0.8× speedup?

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

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

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

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

\mathbf{elif}\;x.im \leq 2 \cdot 10^{+80}:\\
\;\;\;\;t_0 + \left(x.im + x.im\right) \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.im < -5.59999999999999968e181 or 2e80 < x.im

    1. Initial program 66.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. +-commutative66.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. *-commutative66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.59999999999999968e181 < x.im < -3.19999999999999996e-158

    1. Initial program 98.6%

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

    if -3.19999999999999996e-158 < x.im < 1.5e-89

    1. Initial program 72.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. +-commutative72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(x.re \cdot \left(x.re \cdot \left(x.im + 2 \cdot x.im\right)\right)\right)}}^{1} \]
      8. distribute-rgt1-in99.6%

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

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

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

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

    if 1.5e-89 < x.im < 2e80

    1. Initial program 97.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. *-commutative97.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. *-commutative97.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. +-inverses0.0%

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \color{blue}{\left(x.im + x.im\right)} \]
      9. distribute-lft-in81.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-rr81.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. flip-+0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -5.6 \cdot 10^{+181}:\\ \;\;\;\;\left(x.im + x.im\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq -3.2 \cdot 10^{-158}:\\ \;\;\;\;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 1.5 \cdot 10^{-89}:\\ \;\;\;\;x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right)\\ \mathbf{elif}\;x.im \leq 2 \cdot 10^{+80}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.im + x.im\right) \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \end{array} \]

Alternative 6: 86.8% accurate, 0.9× speedup?

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

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

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

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

\mathbf{elif}\;x.im \leq 100000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -5.59999999999999968e181 or 1e5 < x.im

    1. Initial program 72.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. +-commutative72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.im + x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
    6. Step-by-step derivation
      1. difference-of-squares98.1%

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

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

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

    if -5.59999999999999968e181 < x.im < -2.2000000000000001e-91 or 9e-73 < x.im < 1e5

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \color{blue}{\left(x.im + x.im\right)} \]
      9. distribute-lft-in80.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-rr80.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. *-commutative80.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-out80.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-out82.9%

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

      \[\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 -2.2000000000000001e-91 < x.im < 9e-73

    1. Initial program 77.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 77.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -5.6 \cdot 10^{+181}:\\ \;\;\;\;\left(x.im + x.im\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \mathbf{elif}\;x.im \leq -2.2 \cdot 10^{-91}:\\ \;\;\;\;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 9 \cdot 10^{-73}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im + x.im \cdot 2\right)\\ \mathbf{elif}\;x.im \leq 100000:\\ \;\;\;\;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.im + x.im\right) + x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\ \end{array} \]

Alternative 7: 93.2% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.59999999999999968e181 or 2.0000000000000001e92 < x.im

    1. Initial program 66.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. +-commutative66.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. *-commutative66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.59999999999999968e181 < x.im < 2.0000000000000001e92

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 81.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4.8 \cdot 10^{-90} \lor \neg \left(x.im \leq 4.6 \cdot 10^{-72}\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 x.re\right) \cdot \left(x.im + x.im \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.8000000000000003e-90 or 4.59999999999999989e-72 < x.im

    1. Initial program 84.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 \]
    2. Step-by-step derivation
      1. *-commutative84.3%

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + x.re \cdot \color{blue}{\left(x.im + x.im\right)} \]
      9. distribute-lft-in80.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-rr80.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. Step-by-step derivation
      1. *-commutative80.1%

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

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

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

      \[\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 -4.8000000000000003e-90 < x.im < 4.59999999999999989e-72

    1. Initial program 77.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 77.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -4.8 \cdot 10^{-90} \lor \neg \left(x.im \leq 4.6 \cdot 10^{-72}\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 x.re\right) \cdot \left(x.im + x.im \cdot 2\right)\\ \end{array} \]

Alternative 9: 79.8% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -14 or 5.2e14 < x.im

    1. Initial program 80.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. *-commutative80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -14 < x.im < 5.2e14

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.8% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.75 or 5.2e14 < x.im

    1. Initial program 80.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. *-commutative80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.75 < x.im < 5.2e14

    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 68.0%

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

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

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

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

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

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

Alternative 11: 53.0% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.34999999999999997e155

    1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot x.im - \left(2 \cdot x.im\right) \cdot \left(2 \cdot x.im\right)\right)}{x.im - 2 \cdot x.im}} \]
      8. difference-of-squares9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \color{blue}{\left(\left(x.im + 2 \cdot x.im\right) \cdot \left(x.im - 2 \cdot x.im\right)\right)}}{x.im - 2 \cdot x.im} \]
      9. distribute-rgt1-in9.4%

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

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(\color{blue}{3} \cdot x.im\right) \cdot \left(x.im - 2 \cdot x.im\right)\right)}{x.im - 2 \cdot x.im} \]
      11. *-un-lft-identity9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \left(\color{blue}{1 \cdot x.im} - 2 \cdot x.im\right)\right)}{x.im - 2 \cdot x.im} \]
      12. distribute-rgt-out--9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \color{blue}{\left(x.im \cdot \left(1 - 2\right)\right)}\right)}{x.im - 2 \cdot x.im} \]
      13. metadata-eval9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \left(x.im \cdot \color{blue}{-1}\right)\right)}{x.im - 2 \cdot x.im} \]
      14. *-un-lft-identity9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \left(x.im \cdot -1\right)\right)}{\color{blue}{1 \cdot x.im} - 2 \cdot x.im} \]
      15. distribute-rgt-out--9.4%

        \[\leadsto \frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \left(x.im \cdot -1\right)\right)}{\color{blue}{x.im \cdot \left(1 - 2\right)}} \]
      16. metadata-eval9.4%

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

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re\right) \cdot \left(\left(3 \cdot x.im\right) \cdot \left(x.im \cdot -1\right)\right)}{x.im \cdot -1}} \]
    10. Simplified26.4%

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

    if -1.34999999999999997e155 < x.im

    1. Initial program 84.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. +-commutative84.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. *-commutative84.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 50.3% accurate, 2.7× speedup?

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

\\
3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)
\end{array}
Derivation
  1. Initial program 82.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. +-commutative82.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. *-commutative82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 50.3% accurate, 2.7× speedup?

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

\\
x.im \cdot \left(3 \cdot \left(x.re \cdot x.re\right)\right)
\end{array}
Derivation
  1. Initial program 82.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. +-commutative82.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. *-commutative82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 35.0% 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 82.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. *-commutative82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
  5. Step-by-step derivation
    1. *-commutative32.7%

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

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

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.re\right)} \]
  7. Final simplification32.7%

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

Alternative 15: 2.7% accurate, 19.0× speedup?

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

\\
-10
\end{array}
Derivation
  1. Initial program 82.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. +-commutative82.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. *-commutative82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\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) - {x.im}^{3} \cdot {x.im}^{3}}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}}} \]
    4. div-inv24.4%

      \[\leadsto \color{blue}{\left(\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) - {x.im}^{3} \cdot {x.im}^{3}\right) \cdot \frac{1}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}}} \]
    5. swap-sqr24.3%

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

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

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

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{\color{blue}{6}}\right) \cdot \frac{1}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    10. associate-*l*24.2%

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{x.re \cdot \color{blue}{\left(x.re \cdot \left(x.im \cdot 3\right)\right)} + {x.im}^{3}} \]
    12. fma-def24.2%

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

    \[\leadsto \color{blue}{\left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im \cdot 3\right), {x.im}^{3}\right)}} \]
  6. Simplified2.7%

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

    \[\leadsto -10 \]

Alternative 16: 15.9% accurate, 19.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 82.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. +-commutative82.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. *-commutative82.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-def84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  8. Final simplification11.6%

    \[\leadsto 0 \]

Developer target: 91.2% accurate, 1.1× speedup?

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

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

Reproduce

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