math.cube on complex, imaginary part

Percentage Accurate: 83.1% → 99.8%
Time: 8.3s
Alternatives: 13
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 83.1% 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.2× speedup?

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

\mathbf{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 < -5e103 or 2e101 < x.im

    1. Initial program 70.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. +-commutative70.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. *-commutative70.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-def76.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. *-commutative76.0%

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

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

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

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

        \[\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-in70.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 - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e103 < x.im < 2e101

    1. Initial program 91.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. +-commutative91.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. *-commutative91.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 93.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. *-commutative93.0%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def18.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. *-commutative18.2%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.im + \color{blue}{x.re \cdot x.im}, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-lft-out18.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. *-commutative18.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. Simplified18.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-udef0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.6% accurate, 0.2× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -5e103 or 2e101 < x.im

    1. Initial program 70.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. +-commutative70.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. *-commutative70.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-def76.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. *-commutative76.0%

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

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

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

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

        \[\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-in70.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 - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e103 < x.im < -1.45000000000000001e-95 or 2.6e-151 < x.im < 2e101

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

    if -1.45000000000000001e-95 < x.im < 2.6e-151

    1. Initial program 79.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -5 \cdot 10^{+103}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq -1.45 \cdot 10^{-95}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right) - {x.im}^{3}\\ \mathbf{elif}\;x.im \leq 2.6 \cdot 10^{-151}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 2 \cdot 10^{+101}:\\ \;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 4: 98.1% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;x.im \leq -1.45 \cdot 10^{-95}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x.im \leq 2 \cdot 10^{+63}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -5.00000000000000024e148 or 2.00000000000000012e63 < x.im

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

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot x.im + x.im \cdot x.re\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
      3. fma-def77.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. *-commutative77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000024e148 < x.im < -1.45000000000000001e-95 or 7.2e-152 < x.im < 2.00000000000000012e63

    1. Initial program 98.9%

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

    if -1.45000000000000001e-95 < x.im < 7.2e-152

    1. Initial program 79.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. *-commutative79.6%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -5 \cdot 10^{+148}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq -1.45 \cdot 10^{-95}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 7.2 \cdot 10^{-152}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 2 \cdot 10^{+63}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 5: 91.4% accurate, 1.0× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -1250 or 4e11 < x.im

    1. Initial program 82.7%

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

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

        \[\leadsto \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-def85.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. *-commutative85.8%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.im + \color{blue}{x.re \cdot x.im}, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-lft-out85.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. *-commutative85.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. Simplified85.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-udef81.9%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in82.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 - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1250 < x.im < 1.8e-112

    1. Initial program 85.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. *-commutative85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e-112 < x.im < 4e11

    1. Initial program 95.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. *-commutative95.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 91.4% accurate, 1.0× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -5500 or 4e11 < x.im

    1. Initial program 82.7%

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

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

        \[\leadsto \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-def85.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. *-commutative85.8%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.im + \color{blue}{x.re \cdot x.im}, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-lft-out85.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. *-commutative85.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. Simplified85.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-udef81.9%

        \[\leadsto \color{blue}{x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)} \]
      2. distribute-lft-in82.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 - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. flip-+77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5500 < x.im < 1.8e-112

    1. Initial program 85.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. *-commutative85.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e-112 < x.im < 4e11

    1. Initial program 95.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. *-commutative95.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.0% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 90.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. *-commutative90.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.7e58 < x.re

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 67.6% accurate, 2.1× speedup?

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

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

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


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

    1. Initial program 90.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. *-commutative90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5000000000000001e58 < x.re

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 70.3% accurate, 2.1× speedup?

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

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

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


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

    1. Initial program 90.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. *-commutative90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55e58 < x.re

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 65.0% accurate, 2.4× speedup?

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

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

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


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

    1. Initial program 89.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. *-commutative89.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.40000000000000012e100 < x.re

    1. Initial program 60.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. *-commutative60.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 35.7% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 85.0%

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

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

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

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

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

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

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

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

      \[\leadsto -3 + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \cdot x.re \]
    7. flip-+8.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -3 + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{0}}} \]
    19. +-inverses0.0%

      \[\leadsto -3 + \frac{1}{\frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}}} \]
    20. flip-+2.8%

      \[\leadsto -3 + \frac{1}{\color{blue}{x.im + x.im}} \]
  5. Applied egg-rr2.8%

    \[\leadsto -3 + \color{blue}{\frac{1}{x.im + x.im}} \]
  6. Taylor expanded in x.im around inf 2.7%

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

    \[\leadsto -3 \]

Alternative 13: 2.7% accurate, 19.0× speedup?

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

\\
-2.6
\end{array}
Derivation
  1. Initial program 85.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. +-commutative85.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. *-commutative85.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -2.6 \]

Developer target: 91.3% 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 2023271 
(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)))