math.cube on complex, real part

Percentage Accurate: 83.1% → 96.4%
Time: 8.1s
Alternatives: 9
Speedup: 0.9×

Specification

?
\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (- (* x.re x.re) (* x.im x.im)) x.re)
  (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
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_re) - (((x_46_re * x_46_im) + (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_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (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_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
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_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * 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 * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
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$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\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 9 alternatives:

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

Initial Program: 83.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (- (* x.re x.re) (* x.im x.im)) x.re)
  (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
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_re) - (((x_46_re * x_46_im) + (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_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (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_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im):
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
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_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * 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 * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
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$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 96.4% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -6.8 \cdot 10^{+225} \lor \neg \left(x.re \leq 1.3 \cdot 10^{+205}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -6.80000000000000037e225 or 1.2999999999999999e205 < x.re

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.80000000000000037e225 < x.re < 1.2999999999999999e205

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -6.8 \cdot 10^{+225} \lor \neg \left(x.re \leq 1.3 \cdot 10^{+205}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.re + x.im\right), x.im \cdot \left(x.re \cdot \left(\left(-x.im\right) - x.im\right)\right)\right)\\ \end{array} \]

Alternative 2: 95.1% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x.re \leq -2.4 \cdot 10^{-94}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x.re \leq 1.3 \cdot 10^{+205}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.44999999999999992e224 or 1.2999999999999999e205 < x.re

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.44999999999999992e224 < x.re < -2.4e-94 or 3.5000000000000003e-160 < x.re < 1.2999999999999999e205

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4e-94 < x.re < 3.5000000000000003e-160

    1. Initial program 78.9%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.re\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-inv99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.45 \cdot 10^{+224}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{elif}\;x.re \leq -2.4 \cdot 10^{-94}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.re \cdot \left(x.re + x.im\right)\right) - \left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot 2\\ \mathbf{elif}\;x.re \leq 3.5 \cdot 10^{-160}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 1.3 \cdot 10^{+205}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.re \cdot \left(x.re + x.im\right)\right) - \left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \end{array} \]

Alternative 3: 87.9% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x.re \leq -1.4 \cdot 10^{-44}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x.re \leq 1.2 \cdot 10^{+102}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.1e118 or 1.19999999999999997e102 < x.re

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1e118 < x.re < -1.4e-44 or 3.5e-72 < x.re < 1.19999999999999997e102

    1. Initial program 99.8%

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

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

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

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

    if -1.4e-44 < x.re < 3.5e-72

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.1 \cdot 10^{+118}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{elif}\;x.re \leq -1.4 \cdot 10^{-44}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 3.5 \cdot 10^{-72}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(\left(-x.im\right) - x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.re \leq 1.2 \cdot 10^{+102}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \end{array} \]

Alternative 4: 96.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -3.7 \cdot 10^{+224} \lor \neg \left(x.re \leq 1.4 \cdot 10^{+205}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -3.70000000000000003e224 or 1.39999999999999996e205 < x.re

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.70000000000000003e224 < x.re < 1.39999999999999996e205

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -3.7 \cdot 10^{+224} \lor \neg \left(x.re \leq 1.4 \cdot 10^{+205}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{else}:\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.re \cdot \left(x.re + x.im\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\ \end{array} \]

Alternative 5: 70.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{if}\;x.im \leq 1.36 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 480000000:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot -3\\ \mathbf{elif}\;x.im \leq 2.45 \cdot 10^{+68}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (+ (* x.re (* x.re x.re)) (* 0.0 x.im))))
   (if (<= x.im 1.36e-24)
     t_0
     (if (<= x.im 480000000.0)
       (* (* x.re (* x.im x.im)) -3.0)
       (if (<= x.im 2.45e+68) t_0 (* x.im (* -3.0 (* x.re x.im))))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * (x_46_re * x_46_re)) + (0.0 * x_46_im);
	double tmp;
	if (x_46_im <= 1.36e-24) {
		tmp = t_0;
	} else if (x_46_im <= 480000000.0) {
		tmp = (x_46_re * (x_46_im * x_46_im)) * -3.0;
	} else if (x_46_im <= 2.45e+68) {
		tmp = t_0;
	} else {
		tmp = x_46_im * (-3.0 * (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_46re * (x_46re * x_46re)) + (0.0d0 * x_46im)
    if (x_46im <= 1.36d-24) then
        tmp = t_0
    else if (x_46im <= 480000000.0d0) then
        tmp = (x_46re * (x_46im * x_46im)) * (-3.0d0)
    else if (x_46im <= 2.45d+68) then
        tmp = t_0
    else
        tmp = x_46im * ((-3.0d0) * (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_re * (x_46_re * x_46_re)) + (0.0 * x_46_im);
	double tmp;
	if (x_46_im <= 1.36e-24) {
		tmp = t_0;
	} else if (x_46_im <= 480000000.0) {
		tmp = (x_46_re * (x_46_im * x_46_im)) * -3.0;
	} else if (x_46_im <= 2.45e+68) {
		tmp = t_0;
	} else {
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re * (x_46_re * x_46_re)) + (0.0 * x_46_im)
	tmp = 0
	if x_46_im <= 1.36e-24:
		tmp = t_0
	elif x_46_im <= 480000000.0:
		tmp = (x_46_re * (x_46_im * x_46_im)) * -3.0
	elif x_46_im <= 2.45e+68:
		tmp = t_0
	else:
		tmp = x_46_im * (-3.0 * (x_46_re * x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re * Float64(x_46_re * x_46_re)) + Float64(0.0 * x_46_im))
	tmp = 0.0
	if (x_46_im <= 1.36e-24)
		tmp = t_0;
	elseif (x_46_im <= 480000000.0)
		tmp = Float64(Float64(x_46_re * Float64(x_46_im * x_46_im)) * -3.0);
	elseif (x_46_im <= 2.45e+68)
		tmp = t_0;
	else
		tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_re * (x_46_re * x_46_re)) + (0.0 * x_46_im);
	tmp = 0.0;
	if (x_46_im <= 1.36e-24)
		tmp = t_0;
	elseif (x_46_im <= 480000000.0)
		tmp = (x_46_re * (x_46_im * x_46_im)) * -3.0;
	elseif (x_46_im <= 2.45e+68)
		tmp = t_0;
	else
		tmp = x_46_im * (-3.0 * (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$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] + N[(0.0 * x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 1.36e-24], t$95$0, If[LessEqual[x$46$im, 480000000.0], N[(N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision], If[LessEqual[x$46$im, 2.45e+68], t$95$0, N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < 1.36000000000000001e-24 or 4.8e8 < x.im < 2.44999999999999989e68

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.36000000000000001e-24 < x.im < 4.8e8

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.re\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-inv99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.44999999999999989e68 < x.im

    1. Initial program 63.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.re\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-inv90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 1.36 \cdot 10^{-24}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{elif}\;x.im \leq 480000000:\\ \;\;\;\;\left(x.re \cdot \left(x.im \cdot x.im\right)\right) \cdot -3\\ \mathbf{elif}\;x.im \leq 2.45 \cdot 10^{+68}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right) + 0 \cdot x.im\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]

Alternative 6: 59.8% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.19999999999999996e201 or 1.7e205 < x.re

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. distribute-rgt-neg-in0.5%

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
    7. Step-by-step derivation
      1. distribute-lft-out--0.5%

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} - x.re \cdot \left(x.im + x.im\right)\right) \]
      4. sqr-neg35.7%

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

        \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} - x.re \cdot \left(x.im + x.im\right)\right) \]
      6. add-sqr-sqrt0.5%

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im - x.re \cdot \left(x.im + x.im\right)\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-out--0.5%

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} \cdot x.im - x.im\right)\right) \]
      7. mul0-lft0.5%

        \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} - x.im\right)\right) \]
      8. neg-sub00.5%

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

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

        \[\leadsto x.im \cdot \left(-\color{blue}{x.im \cdot x.re}\right) \]
      11. distribute-rgt-neg-in0.5%

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)\right)} - 1} \]
      3. add-sqr-sqrt0.3%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)}\right)\right)} - 1 \]
      4. sqrt-unprod45.2%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}\right)\right)} - 1 \]
      5. sqr-neg45.2%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \sqrt{\color{blue}{x.re \cdot x.re}}\right)\right)} - 1 \]
      6. sqrt-unprod17.5%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)}\right)\right)} - 1 \]
      7. add-sqr-sqrt17.8%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{x.re}\right)\right)} - 1 \]
      8. *-commutative17.8%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \color{blue}{\left(x.re \cdot x.im\right)}\right)} - 1 \]
    12. Applied egg-rr17.8%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot x.im\right)\right)\right)} \]
      2. expm1-log1p36.1%

        \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im\right)} \]
    14. Simplified36.1%

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

    if -1.19999999999999996e201 < x.re < 1.7e205

    1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 59.7% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.35 \cdot 10^{+209} \lor \neg \left(x.re \leq 2.4 \cdot 10^{+205}\right):\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot 3\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.35e209 or 2.39999999999999986e205 < x.re

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-\left(x.im \cdot x.im\right) \cdot x.re\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
    7. Step-by-step derivation
      1. cancel-sign-sub-inv0.5%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left(x.im \cdot x.im\right) \cdot x.re} \cdot \sqrt{\left(x.im \cdot x.im\right) \cdot x.re}} + \left(-x.im\right) \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      6. add-sqr-sqrt0.5%

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot x.im\right) + \color{blue}{\sqrt{\left(-x.im\right) \cdot \left(-x.im\right)}} \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      10. sqr-neg18.7%

        \[\leadsto x.re \cdot \left(x.im \cdot x.im\right) + \sqrt{\color{blue}{x.im \cdot x.im}} \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      11. sqrt-prod18.5%

        \[\leadsto x.re \cdot \left(x.im \cdot x.im\right) + \color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      12. add-sqr-sqrt36.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35e209 < x.re < 2.39999999999999986e205

    1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 39.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -4.25 \cdot 10^{+204} \lor \neg \left(x.re \leq 7.2 \cdot 10^{+205}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -4.25e204 or 7.20000000000000003e205 < x.re

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. distribute-rgt-neg-in0.5%

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
    7. Step-by-step derivation
      1. distribute-lft-out--0.5%

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} - x.re \cdot \left(x.im + x.im\right)\right) \]
      4. sqr-neg35.7%

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

        \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} - x.re \cdot \left(x.im + x.im\right)\right) \]
      6. add-sqr-sqrt0.5%

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im - x.re \cdot \left(x.im + x.im\right)\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-out--0.5%

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

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

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

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

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

        \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} \cdot x.im - x.im\right)\right) \]
      7. mul0-lft0.5%

        \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} - x.im\right)\right) \]
      8. neg-sub00.5%

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

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

        \[\leadsto x.im \cdot \left(-\color{blue}{x.im \cdot x.re}\right) \]
      11. distribute-rgt-neg-in0.5%

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)\right)} - 1} \]
      3. add-sqr-sqrt0.3%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)}\right)\right)} - 1 \]
      4. sqrt-unprod45.2%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}\right)\right)} - 1 \]
      5. sqr-neg45.2%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \sqrt{\color{blue}{x.re \cdot x.re}}\right)\right)} - 1 \]
      6. sqrt-unprod17.5%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)}\right)\right)} - 1 \]
      7. add-sqr-sqrt17.8%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{x.re}\right)\right)} - 1 \]
      8. *-commutative17.8%

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \color{blue}{\left(x.re \cdot x.im\right)}\right)} - 1 \]
    12. Applied egg-rr17.8%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot x.im\right)\right)\right)} \]
      2. expm1-log1p36.1%

        \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im\right)} \]
    14. Simplified36.1%

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

    if -4.25e204 < x.re < 7.20000000000000003e205

    1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
      2. distribute-rgt-neg-in63.5%

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
    7. Step-by-step derivation
      1. distribute-lft-out--72.2%

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

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

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

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

        \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} - x.re \cdot \left(x.im + x.im\right)\right) \]
      6. add-sqr-sqrt38.1%

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im - x.re \cdot \left(x.im + x.im\right)\right)} \]
    9. Step-by-step derivation
      1. distribute-lft-out--44.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(-\color{blue}{x.im \cdot x.re}\right) \]
      11. distribute-rgt-neg-in44.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -4.25 \cdot 10^{+204} \lor \neg \left(x.re \leq 7.2 \cdot 10^{+205}\right):\\ \;\;\;\;x.im \cdot \left(x.re \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 9: 23.3% accurate, 3.8× speedup?

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

\\
x.im \cdot \left(x.re \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)} - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) \]
  7. Step-by-step derivation
    1. distribute-lft-out--60.4%

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

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

      \[\leadsto x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} - x.re \cdot \left(x.im + x.im\right)\right) \]
    4. sqr-neg47.8%

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

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

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

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

    \[\leadsto \color{blue}{x.im \cdot \left(x.re \cdot x.im - x.re \cdot \left(x.im + x.im\right)\right)} \]
  9. Step-by-step derivation
    1. distribute-lft-out--37.4%

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

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

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

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

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

      \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} \cdot x.im - x.im\right)\right) \]
    7. mul0-lft37.4%

      \[\leadsto x.im \cdot \left(x.re \cdot \left(\color{blue}{0} - x.im\right)\right) \]
    8. neg-sub037.4%

      \[\leadsto x.im \cdot \left(x.re \cdot \color{blue}{\left(-x.im\right)}\right) \]
    9. distribute-rgt-neg-in37.4%

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

      \[\leadsto x.im \cdot \left(-\color{blue}{x.im \cdot x.re}\right) \]
    11. distribute-rgt-neg-in37.4%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \left(-x.re\right)\right)\right)} - 1} \]
    3. add-sqr-sqrt14.3%

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)}\right)\right)} - 1 \]
    4. sqrt-unprod33.1%

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}}\right)\right)} - 1 \]
    5. sqr-neg33.1%

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

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)}\right)\right)} - 1 \]
    7. add-sqr-sqrt20.6%

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.im \cdot \color{blue}{x.re}\right)\right)} - 1 \]
    8. *-commutative20.6%

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

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

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

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

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

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

Developer target: 87.5% accurate, 1.1× speedup?

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

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

Reproduce

?
herbie shell --seed 2023293 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))