math.cube on complex, imaginary part

Percentage Accurate: 83.2% → 99.7%
Time: 11.2s
Alternatives: 12
Speedup: 1.1×

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

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

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

Alternative 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re - x.im\right)\\ \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re + 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) + t_0 \cdot \left(x.re + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (- x.re x.im))))
   (if (<=
        (+
         (* x.im (- (* x.re x.re) (* x.im x.im)))
         (* x.re (+ (* x.re x.im) (* x.re x.im))))
        INFINITY)
     (fma (+ x.re x.im) t_0 (* x.re (* x.re (+ x.im x.im))))
     (+ (+ x.im x.im) (* t_0 (+ x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_re - x_46_im);
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re + x_46_im), t_0, (x_46_re * (x_46_re * (x_46_im + x_46_im))));
	} else {
		tmp = (x_46_im + x_46_im) + (t_0 * (x_46_re + x_46_im));
	}
	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_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = fma(Float64(x_46_re + 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(t_0 * Float64(x_46_re + x_46_im)));
	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$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re + 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[(t$95$0 * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re - x.im\right)\\
\mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re + 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) + t_0 \cdot \left(x.re + x.im\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. 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-+26.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-in26.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + t_0 \leq \infty:\\ \;\;\;\;t_0 + \frac{x.re + x.im}{\frac{\frac{1}{x.im}}{x.re - x.im}}\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.re (+ (* x.re x.im) (* x.re x.im)))))
   (if (<= (+ (* x.im (- (* x.re x.re) (* x.im x.im))) t_0) INFINITY)
     (+ t_0 (/ (+ x.re x.im) (/ (/ 1.0 x.im) (- x.re x.im))))
     (+ (+ x.im x.im) (* (* x.im (- x.re x.im)) (+ x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0) <= ((double) INFINITY)) {
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / (x_46_re - x_46_im)));
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	}
	return tmp;
}
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 tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / (x_46_re - x_46_im)));
	} else {
		tmp = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))
	tmp = 0
	if ((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0) <= math.inf:
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / (x_46_re - x_46_im)))
	else:
		tmp = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + t_0) <= Inf)
		tmp = Float64(t_0 + Float64(Float64(x_46_re + x_46_im) / Float64(Float64(1.0 / x_46_im) / Float64(x_46_re - x_46_im))));
	else
		tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_im * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
	tmp = 0.0;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0) <= Inf)
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / (x_46_re - x_46_im)));
	else
		tmp = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], Infinity], N[(t$95$0 + N[(N[(x$46$re + x$46$im), $MachinePrecision] / N[(N[(1.0 / x$46$im), $MachinePrecision] / N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im + x$46$im), $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}

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

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


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

    1. Initial program 91.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. difference-of-squares91.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Step-by-step derivation
      1. expm1-log1p-u58.3%

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. associate-/l*50.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im + x.im\right), x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)} \]
    4. Step-by-step derivation
      1. 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-+26.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-in26.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.9% accurate, 0.7× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -1e152 or 9.9999999999999996e81 < x.im

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e152 < x.im < -4.5000000000000002e-71 or 1.17999999999999994e-125 < x.im < 9.9999999999999996e81

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

    if -4.5000000000000002e-71 < x.im < 1.17999999999999994e-125

    1. Initial program 79.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Step-by-step derivation
      1. expm1-log1p-u62.2%

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. associate-/l*49.6%

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x.re \cdot x.re - x.im \cdot x.im}{\frac{x.re - x.im}{x.im \cdot \left(x.re - x.im\right)}}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    6. Step-by-step derivation
      1. expm1-def64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(x.im \cdot 3\right) \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 -1 \cdot 10^{+152}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \mathbf{elif}\;x.im \leq -4.5 \cdot 10^{-71}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 1.18 \cdot 10^{-125}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.im \leq 10^{+82}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \end{array} \]

Alternative 4: 97.9% 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 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + t_0\\ t_2 := \left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \mathbf{if}\;x.im \leq -8.5 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x.im \leq -4.5 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq 10^{-125}:\\ \;\;\;\;t_0 + \frac{x.re + x.im}{\frac{\frac{1}{x.im}}{x.re}}\\ \mathbf{elif}\;x.im \leq 10^{+81}:\\ \;\;\;\;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 (+ (* x.im (- (* x.re x.re) (* x.im x.im))) t_0))
        (t_2 (+ (+ x.im x.im) (* (* x.im (- x.re x.im)) (+ x.re x.im)))))
   (if (<= x.im -8.5e+151)
     t_2
     (if (<= x.im -4.5e-71)
       t_1
       (if (<= x.im 1e-125)
         (+ t_0 (/ (+ x.re x.im) (/ (/ 1.0 x.im) x.re)))
         (if (<= x.im 1e+81) 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 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0;
	double t_2 = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	double tmp;
	if (x_46_im <= -8.5e+151) {
		tmp = t_2;
	} else if (x_46_im <= -4.5e-71) {
		tmp = t_1;
	} else if (x_46_im <= 1e-125) {
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / x_46_re));
	} else if (x_46_im <= 1e+81) {
		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 = (x_46im * ((x_46re * x_46re) - (x_46im * x_46im))) + t_0
    t_2 = (x_46im + x_46im) + ((x_46im * (x_46re - x_46im)) * (x_46re + x_46im))
    if (x_46im <= (-8.5d+151)) then
        tmp = t_2
    else if (x_46im <= (-4.5d-71)) then
        tmp = t_1
    else if (x_46im <= 1d-125) then
        tmp = t_0 + ((x_46re + x_46im) / ((1.0d0 / x_46im) / x_46re))
    else if (x_46im <= 1d+81) 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 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0;
	double t_2 = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	double tmp;
	if (x_46_im <= -8.5e+151) {
		tmp = t_2;
	} else if (x_46_im <= -4.5e-71) {
		tmp = t_1;
	} else if (x_46_im <= 1e-125) {
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / x_46_re));
	} else if (x_46_im <= 1e+81) {
		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 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0
	t_2 = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im))
	tmp = 0
	if x_46_im <= -8.5e+151:
		tmp = t_2
	elif x_46_im <= -4.5e-71:
		tmp = t_1
	elif x_46_im <= 1e-125:
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / x_46_re))
	elif x_46_im <= 1e+81:
		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(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + t_0)
	t_2 = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_im * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im)))
	tmp = 0.0
	if (x_46_im <= -8.5e+151)
		tmp = t_2;
	elseif (x_46_im <= -4.5e-71)
		tmp = t_1;
	elseif (x_46_im <= 1e-125)
		tmp = Float64(t_0 + Float64(Float64(x_46_re + x_46_im) / Float64(Float64(1.0 / x_46_im) / x_46_re)));
	elseif (x_46_im <= 1e+81)
		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 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + t_0;
	t_2 = (x_46_im + x_46_im) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
	tmp = 0.0;
	if (x_46_im <= -8.5e+151)
		tmp = t_2;
	elseif (x_46_im <= -4.5e-71)
		tmp = t_1;
	elseif (x_46_im <= 1e-125)
		tmp = t_0 + ((x_46_re + x_46_im) / ((1.0 / x_46_im) / x_46_re));
	elseif (x_46_im <= 1e+81)
		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[(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), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x$46$im + x$46$im), $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]}, If[LessEqual[x$46$im, -8.5e+151], t$95$2, If[LessEqual[x$46$im, -4.5e-71], t$95$1, If[LessEqual[x$46$im, 1e-125], N[(t$95$0 + N[(N[(x$46$re + x$46$im), $MachinePrecision] / N[(N[(1.0 / x$46$im), $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1e+81], 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 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + t_0\\
t_2 := \left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\
\mathbf{if}\;x.im \leq -8.5 \cdot 10^{+151}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x.im \leq 10^{-125}:\\
\;\;\;\;t_0 + \frac{x.re + x.im}{\frac{\frac{1}{x.im}}{x.re}}\\

\mathbf{elif}\;x.im \leq 10^{+81}:\\
\;\;\;\;t_1\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.50000000000000051e151 < x.im < -4.5000000000000002e-71 or 1.00000000000000001e-125 < x.im < 9.99999999999999921e80

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

    if -4.5000000000000002e-71 < x.im < 1.00000000000000001e-125

    1. Initial program 79.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    4. Step-by-step derivation
      1. expm1-log1p-u62.2%

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. associate-/l*49.6%

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x.re \cdot x.re - x.im \cdot x.im}{\frac{x.re - x.im}{x.im \cdot \left(x.re - x.im\right)}}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    6. Step-by-step derivation
      1. expm1-def64.9%

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

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

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

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

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

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

      \[\leadsto \frac{x.im + x.re}{\color{blue}{\frac{1}{x.im \cdot x.re}}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    9. Step-by-step derivation
      1. associate-/r*97.9%

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

      \[\leadsto \frac{x.im + x.re}{\color{blue}{\frac{\frac{1}{x.im}}{x.re}}} + \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 -8.5 \cdot 10^{+151}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \mathbf{elif}\;x.im \leq -4.5 \cdot 10^{-71}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 10^{-125}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \frac{x.re + x.im}{\frac{\frac{1}{x.im}}{x.re}}\\ \mathbf{elif}\;x.im \leq 10^{+81}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\\ \end{array} \]

Alternative 5: 83.8% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -370 or 420 < x.im

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

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

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

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

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

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

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

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

    if -370 < x.im < 420

    1. Initial program 85.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. difference-of-squares85.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. associate-/l*49.6%

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x.re \cdot x.re - x.im \cdot x.im}{\frac{x.re - x.im}{x.im \cdot \left(x.re - x.im\right)}}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    6. Step-by-step derivation
      1. expm1-def69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 90.3% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -185 or 900 < x.im

    1. Initial program 84.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. +-commutative84.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. *-commutative84.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-def88.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. *-commutative88.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-out88.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. *-commutative88.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. Simplified88.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-udef84.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-in84.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-+77.0%

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

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

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

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

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

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

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

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

    if -185 < x.im < 900

    1. Initial program 85.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. difference-of-squares85.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      3. associate-/l*49.6%

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x.re \cdot x.re - x.im \cdot x.im}{\frac{x.re - x.im}{x.im \cdot \left(x.re - x.im\right)}}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    6. Step-by-step derivation
      1. expm1-def69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 50.2% accurate, 2.7× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
    4. associate-*l*84.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. *-commutative84.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-out86.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-86.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--79.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 56.0% accurate, 2.7× speedup?

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

\\
x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)
\end{array}
Derivation
  1. Initial program 84.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. difference-of-squares85.6%

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

      \[\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 \]
    3. *-commutative93.1%

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

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

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

    \[\leadsto \color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  4. Step-by-step derivation
    1. expm1-log1p-u53.9%

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)}{x.re - x.im}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    3. associate-/l*47.0%

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

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x.re \cdot x.re - x.im \cdot x.im}{\frac{x.re - x.im}{x.im \cdot \left(x.re - x.im\right)}}\right)} - 1\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  6. Step-by-step derivation
    1. expm1-def57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 34.8% accurate, 3.8× speedup?

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

\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 84.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. *-commutative84.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-+64.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. *-commutative64.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-in64.3%

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

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

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

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

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

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

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

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

Alternative 10: 2.7% accurate, 19.0× speedup?

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

\\
-3.25
\end{array}
Derivation
  1. Initial program 84.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. +-commutative84.8%

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
    4. associate-*l*84.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. *-commutative84.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-out86.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-86.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--79.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -3.25 \]

Alternative 11: 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 84.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -3 \]

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
3.25
\end{array}
Derivation
  1. Initial program 84.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. +-commutative84.8%

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

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

      \[\leadsto \color{blue}{\left(x.im \cdot \left(x.re + x.re\right)\right)} \cdot x.re + \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im \]
    4. associate-*l*84.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. *-commutative84.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-out86.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-86.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--79.7%

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

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

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

      \[\leadsto \color{blue}{\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) \cdot \frac{1}{\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)}} \]
    3. *-commutative12.2%

      \[\leadsto \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) \cdot \frac{1}{\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)} \]
    4. unpow-prod-down12.2%

      \[\leadsto \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) \cdot \frac{1}{\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)} \]
    5. metadata-eval12.2%

      \[\leadsto \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) \cdot \frac{1}{\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)} \]
    6. associate-*l*12.2%

      \[\leadsto \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) \cdot \frac{1}{\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)} \]
    7. pow-pow12.2%

      \[\leadsto \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) \cdot \frac{1}{\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)} \]
    8. metadata-eval12.2%

      \[\leadsto \left(27 \cdot {\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{3} - {x.im}^{\color{blue}{9}}\right) \cdot \frac{1}{\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)} \]
    9. associate-+r+12.2%

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

    \[\leadsto \color{blue}{\left(27 \cdot {\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{3} - {x.im}^{9}\right) \cdot \frac{1}{\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)}} \]
  6. Simplified2.8%

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

    \[\leadsto 3.25 \]

Developer target: 92.1% accurate, 1.1× speedup?

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

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

Reproduce

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