math.cube on complex, real part

Percentage Accurate: 83.3% → 98.3%
Time: 9.8s
Alternatives: 11
Speedup: 2.1×

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 11 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.3% 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: 98.3% accurate, 0.1× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (-
       (* x.re (- (* x.re x.re) (* x.im x.im)))
       (* x.im (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (fma
    (- x.re x.im)
    (* x.re (+ x.re x.im))
    (* x.im (* x.re (- (- x.im) x.im))))
   (* (* x.re x.re) (- x.re x.im))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		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))));
	} else {
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	}
	return tmp;
}
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = fma(Float64(x_46_re - x_46_im), 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))));
	else
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im));
	end
	return tmp
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re - x$46$im), $MachinePrecision] * 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], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\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)\\

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


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

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.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. Step-by-step derivation
      1. sqr-neg0.0%

        \[\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-squares38.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-neg38.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*38.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-neg38.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-neg38.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. +-commutative38.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. *-commutative38.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. *-commutative38.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-out38.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. Simplified38.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 inf 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (-
       (* x.re (- (* x.re x.re) (* x.im x.im)))
       (* x.im (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (- (* (- x.re x.im) (* x.re (+ x.re x.im))) (* x.im (* x.re (+ x.im x.im))))
   (* (* x.re x.re) (- x.re x.im))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		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)));
	} else {
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	}
	return tmp;
}
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		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)));
	} else {
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= math.inf:
		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)))
	else:
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im)
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		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))));
	else
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Inf)
		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)));
	else
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], 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], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\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)\\

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


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

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.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. Step-by-step derivation
      1. sqr-neg0.0%

        \[\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-squares38.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-neg38.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*38.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-neg38.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-neg38.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. +-commutative38.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. *-commutative38.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. *-commutative38.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-out38.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. Simplified38.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 inf 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.8% accurate, 1.2× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq 7.8 \cdot 10^{+153}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re + \left(x.im \cdot x.im\right) \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;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)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 7.8e+153)
   (* x.re (+ (* x.re x.re) (* (* x.im x.im) -3.0)))
   (- (* x.im (* x.re (- (- x.im) x.im))) (* x.im (* x.re x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 7.8e+153) {
		tmp = x_46_re * ((x_46_re * x_46_re) + ((x_46_im * x_46_im) * -3.0));
	} else {
		tmp = (x_46_im * (x_46_re * (-x_46_im - x_46_im))) - (x_46_im * (x_46_re * x_46_im));
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46im <= 7.8d+153) then
        tmp = x_46re * ((x_46re * x_46re) + ((x_46im * x_46im) * (-3.0d0)))
    else
        tmp = (x_46im * (x_46re * (-x_46im - x_46im))) - (x_46im * (x_46re * x_46im))
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 7.8e+153) {
		tmp = x_46_re * ((x_46_re * x_46_re) + ((x_46_im * x_46_im) * -3.0));
	} else {
		tmp = (x_46_im * (x_46_re * (-x_46_im - x_46_im))) - (x_46_im * (x_46_re * x_46_im));
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= 7.8e+153:
		tmp = x_46_re * ((x_46_re * x_46_re) + ((x_46_im * x_46_im) * -3.0))
	else:
		tmp = (x_46_im * (x_46_re * (-x_46_im - x_46_im))) - (x_46_im * (x_46_re * x_46_im))
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 7.8e+153)
		tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(Float64(x_46_im * x_46_im) * -3.0)));
	else
		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)));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= 7.8e+153)
		tmp = x_46_re * ((x_46_re * x_46_re) + ((x_46_im * x_46_im) * -3.0));
	else
		tmp = (x_46_im * (x_46_re * (-x_46_im - x_46_im))) - (x_46_im * (x_46_re * x_46_im));
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 7.8e+153], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(N[(x$46$im * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7.8 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + \left(x.im \cdot x.im\right) \cdot -3\right)\\

\mathbf{else}:\\
\;\;\;\;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)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 7.79999999999999966e153

    1. Initial program 88.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. Step-by-step derivation
      1. sqr-neg88.0%

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

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.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. *-commutative94.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-rr94.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. Step-by-step derivation
      1. fma-udef94.4%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999966e153 < x.im

    1. Initial program 49.3%

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

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

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

        \[\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*78.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-neg78.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-neg78.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. +-commutative78.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. *-commutative78.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. *-commutative78.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-out78.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. Simplified78.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 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x.im \cdot \left(-x.im \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 simplification90.3%

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

Alternative 4: 96.8% accurate, 1.5× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 7.79999999999999966e153

    1. Initial program 88.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. Step-by-step derivation
      1. sqr-neg88.0%

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

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.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. *-commutative94.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-rr94.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. Step-by-step derivation
      1. fma-udef94.4%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999966e153 < x.im

    1. Initial program 49.3%

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

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

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

        \[\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*78.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-neg78.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-neg78.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. +-commutative78.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. *-commutative78.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. *-commutative78.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-out78.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. Simplified78.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-inv78.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-def78.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. *-commutative78.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-rr78.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 64.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 83.4% accurate, 1.7× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq -7 \cdot 10^{-86}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{elif}\;x.re \leq 4.8 \cdot 10^{+14}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right)\\ \end{array} \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.re -7e-86)
   (* x.re (* x.re x.re))
   (if (<= x.re 4.8e+14)
     (* (* x.re x.im) (* x.im -3.0))
     (* (* x.re x.re) (- x.re x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -7e-86) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else if (x_46_re <= 4.8e+14) {
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	}
	return tmp;
}
NOTE: x.im should be positive before calling this function
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 <= (-7d-86)) then
        tmp = x_46re * (x_46re * x_46re)
    else if (x_46re <= 4.8d+14) then
        tmp = (x_46re * x_46im) * (x_46im * (-3.0d0))
    else
        tmp = (x_46re * x_46re) * (x_46re - x_46im)
    end if
    code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_re <= -7e-86) {
		tmp = x_46_re * (x_46_re * x_46_re);
	} else if (x_46_re <= 4.8e+14) {
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	} else {
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	}
	return tmp;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_re <= -7e-86:
		tmp = x_46_re * (x_46_re * x_46_re)
	elif x_46_re <= 4.8e+14:
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0)
	else:
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im)
	return tmp
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_re <= -7e-86)
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_re));
	elseif (x_46_re <= 4.8e+14)
		tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0));
	else
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im));
	end
	return tmp
end
x.im = abs(x.im)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_re <= -7e-86)
		tmp = x_46_re * (x_46_re * x_46_re);
	elseif (x_46_re <= 4.8e+14)
		tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
	else
		tmp = (x_46_re * x_46_re) * (x_46_re - x_46_im);
	end
	tmp_2 = tmp;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -7e-86], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 4.8e+14], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -7 \cdot 10^{-86}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -7.00000000000000041e-86

    1. Initial program 76.5%

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

        \[\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-squares82.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-neg82.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*82.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-neg82.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-neg82.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. +-commutative82.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. *-commutative82.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. *-commutative82.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-out82.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. Simplified82.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-inv82.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-def82.6%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef82.6%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow272.6%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified72.6%

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

    if -7.00000000000000041e-86 < x.re < 4.8e14

    1. Initial program 88.3%

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

        \[\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-squares88.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-neg88.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*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.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 82.1%

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

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

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

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

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

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

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

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

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

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

    if 4.8e14 < x.re

    1. Initial program 82.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-neg82.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-squares92.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-neg92.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*92.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-neg92.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-neg92.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. +-commutative92.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. *-commutative92.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. *-commutative92.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-out92.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. Simplified92.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 inf 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 77.8% accurate, 2.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 1.75e-12

    1. Initial program 86.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-neg86.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-squares90.5%

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.2%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef94.2%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow269.2%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified69.2%

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

    if 1.75e-12 < x.im

    1. Initial program 70.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-neg70.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-squares78.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-neg78.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*86.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-neg86.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-neg86.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. +-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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-inv86.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-def86.5%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef86.4%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 83.4% accurate, 2.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 1.75e-12

    1. Initial program 86.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-neg86.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-squares90.5%

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.2%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef94.2%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow269.2%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified69.2%

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

    if 1.75e-12 < x.im

    1. Initial program 70.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-neg70.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-squares78.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-neg78.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*86.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-neg86.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-neg86.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. +-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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 66.9%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 83.4% accurate, 2.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 1.32e-12

    1. Initial program 86.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-neg86.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-squares90.5%

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.2%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef94.2%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow269.2%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified69.2%

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

    if 1.32e-12 < x.im

    1. Initial program 70.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-neg70.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-squares78.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-neg78.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*86.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-neg86.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-neg86.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. +-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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 66.9%

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

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

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

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

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

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

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

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

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

Alternative 9: 83.4% accurate, 2.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 8.39999999999999955e-13

    1. Initial program 86.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-neg86.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-squares90.5%

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

        \[\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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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-inv94.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-def94.2%

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

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

      \[\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. Step-by-step derivation
      1. fma-udef94.2%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*94.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow269.2%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified69.2%

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

    if 8.39999999999999955e-13 < x.im

    1. Initial program 70.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-neg70.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-squares78.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-neg78.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*86.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-neg86.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-neg86.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. +-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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-inv86.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-def86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 61.3% accurate, 2.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < 2.1999999999999999e180

    1. Initial program 84.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-neg84.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-squares88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. Step-by-step derivation
      1. fma-udef93.0%

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

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

        \[\leadsto \color{blue}{\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)} \]
      2. associate-*r*93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    11. Step-by-step derivation
      1. unpow263.4%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
    12. Simplified63.4%

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

    if 2.1999999999999999e180 < x.im

    1. Initial program 63.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-neg63.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-squares82.0%

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

        \[\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*86.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-neg86.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-neg86.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. +-commutative86.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. *-commutative86.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. *-commutative86.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-out86.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. Simplified86.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 inf 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 30.6% accurate, 3.8× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ \left(x.re \cdot x.re\right) \cdot x.im \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* (* x.re x.re) x.im))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return (x_46_re * x_46_re) * x_46_im;
}
NOTE: x.im should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = (x_46re * x_46re) * x_46im
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return (x_46_re * x_46_re) * x_46_im;
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return (x_46_re * x_46_re) * x_46_im
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return Float64(Float64(x_46_re * x_46_re) * x_46_im)
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = (x_46_re * x_46_re) * x_46_im;
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 83.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. Step-by-step derivation
    1. sqr-neg83.0%

      \[\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-squares87.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-neg87.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*92.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-neg92.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-neg92.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. +-commutative92.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. *-commutative92.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. *-commutative92.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-out92.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. Simplified92.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 inf 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 87.7% 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 2023279 
(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)))