math.cube on complex, imaginary part

Percentage Accurate: 83.0% → 99.8%
Time: 11.4s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 83.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} 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) + \left(x.re + x.im\right) \cdot t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (- x.re x.im))))
   (if (<=
        (+
         (* x.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) (* (+ x.re x.im) t_0)))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_re - x_46_im);
	double tmp;
	if (((x_46_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) + ((x_46_re + x_46_im) * t_0);
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_re - x_46_im))
	tmp = 0.0
	if (Float64(Float64(x_46_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(Float64(x_46_re + x_46_im) * t_0));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x$46$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[(N[(x$46$re + x$46$im), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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


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

    1. Initial program 93.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+42.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) \]
      17. *-commutative42.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} \]
      18. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      19. associate-*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)} \]
      20. *-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.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 2: 93.6% accurate, 0.5× speedup?

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

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


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

    1. Initial program 95.1%

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

    if 4.99999999999999976e246 < (+.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 58.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 5 \cdot 10^{+246}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 3: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 93.9%

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

        \[\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-+93.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/90.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-rr90.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. *-un-lft-identity90.7%

        \[\leadsto \color{blue}{1 \cdot \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 \]
      2. associate-/l*93.8%

        \[\leadsto 1 \cdot \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 \]
    5. Applied egg-rr93.8%

      \[\leadsto \color{blue}{1 \cdot \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 \]
    6. Step-by-step derivation
      1. associate-/r/93.8%

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

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

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

    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-def12.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+42.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) \]
      17. *-commutative42.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} \]
      18. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      19. associate-*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)} \]
      20. *-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) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 4: 85.3% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 67.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. +-commutative67.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. *-commutative67.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-def71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+78.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) \]
      17. *-commutative78.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} \]
      18. difference-of-squares97.4%

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

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

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

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

    if -3.49999999999999985e155 < x.im < -2.7999999999999997e-23 or 1.59999999999999988e-64 < x.im < 5e6

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7999999999999997e-23 < x.im < 1.59999999999999988e-64

    1. Initial program 87.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. +-commutative87.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. *-commutative87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.5 \cdot 10^{+155}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.im \leq -2.8 \cdot 10^{-23}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 1.6 \cdot 10^{-64}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3\right)\\ \mathbf{elif}\;x.im \leq 5000000:\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.im + x.im\right) + \left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 5: 75.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x.im \leq -30 \lor \neg \left(x.im \leq 2.45 \cdot 10^{+31}\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.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3\right)\\


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

    1. Initial program 55.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. +-commutative55.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. *-commutative55.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-def61.1%

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

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

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

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

      \[\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-udef55.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-in55.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 \cdot x.im - x.im \cdot x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      8. associate-*r/0.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+69.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) \]
      17. *-commutative69.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} \]
      18. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      19. associate-*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)} \]
      20. *-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)} \]
    6. Taylor expanded in x.im around 0 50.7%

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

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

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

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

    if -3.49999999999999985e155 < x.im < -30 or 2.44999999999999998e31 < x.im

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} \]
      16. flip-+89.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)} \]
    3. Applied egg-rr89.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)} \]

    if -30 < x.im < 2.44999999999999998e31

    1. Initial program 89.8%

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

        \[\leadsto \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. *-commutative89.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-out89.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*89.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. *-commutative89.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-out89.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-89.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--89.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.5 \cdot 10^{+155}:\\ \;\;\;\;\left(x.im + x.im\right) + x.re \cdot \left(x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq -30 \lor \neg \left(x.im \leq 2.45 \cdot 10^{+31}\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.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3\right)\\ \end{array} \]

Alternative 6: 84.1% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -17 or 2.44999999999999998e31 < x.im

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+83.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) \]
      17. *-commutative83.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} \]
      18. difference-of-squares98.9%

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

        \[\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)} \]
      20. *-commutative98.9%

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

      \[\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 -17 < x.im < 2.44999999999999998e31

    1. Initial program 89.8%

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

        \[\leadsto \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. *-commutative89.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-out89.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*89.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. *-commutative89.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-out89.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-89.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--89.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 53.1% accurate, 1.7× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+73.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) \]
      17. *-commutative73.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} \]
      18. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      19. associate-*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)} \]
      20. *-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)} \]
    6. Taylor expanded in x.im around 0 47.8%

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

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

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

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

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

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

    if -8.50000000000000027e164 < x.im

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 inf 57.9%

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

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

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

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

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

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

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

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

Alternative 8: 54.2% accurate, 1.7× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot x.im - x.im \cdot x.im}{\color{blue}{x.im - x.im}} + x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) \]
      16. flip-+73.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) \]
      17. *-commutative73.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} \]
      18. difference-of-squares100.0%

        \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im \]
      19. associate-*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)} \]
      20. *-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)} \]
    6. Taylor expanded in x.im around 0 47.8%

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

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

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

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

    if -2.20000000000000006e164 < x.im

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 inf 57.9%

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

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

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

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

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

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

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

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

Alternative 9: 49.7% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

    \[\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 inf 52.2%

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

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

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

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

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

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

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

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

Alternative 10: 34.9% 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 81.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. *-commutative81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 3.1% accurate, 6.3× speedup?

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

\\
x.im + x.im
\end{array}
Derivation
  1. Initial program 81.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. +-commutative81.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. *-commutative81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.im + x.im\right) + \color{blue}{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \]
    18. difference-of-squares61.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 \]
    19. associate-*r*61.8%

      \[\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)} \]
    20. *-commutative61.8%

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

    \[\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)} \]
  6. Taylor expanded in x.im around 0 34.2%

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

    \[\leadsto \color{blue}{2 \cdot x.im} \]
  8. Step-by-step derivation
    1. count-23.0%

      \[\leadsto \color{blue}{x.im + x.im} \]
  9. Simplified3.0%

    \[\leadsto \color{blue}{x.im + x.im} \]
  10. Final simplification3.0%

    \[\leadsto x.im + x.im \]

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 81.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 55.6%

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

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

    \[\leadsto -3 \]

Alternative 13: 2.7% accurate, 19.0× speedup?

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

\\
2.6
\end{array}
Derivation
  1. Initial program 81.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. +-commutative81.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. *-commutative81.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-out81.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*81.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. *-commutative81.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-out87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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}{2.6} \]
  7. Final simplification2.8%

    \[\leadsto 2.6 \]

Developer target: 91.8% 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 2023274 
(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)))