math.cube on complex, real part

Percentage Accurate: 82.7% → 96.8%
Time: 8.6s
Alternatives: 15
Speedup: 1.0×

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 15 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: 82.7% accurate, 1.0× speedup?

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

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

Alternative 1: 96.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \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), \left(-x.im\right) \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(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))))
   (pow x.re 3.0)))
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 = pow(x_46_re, 3.0);
	}
	return tmp;
}
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(Float64(-x_46_im) * Float64(x_46_re * Float64(x_46_im + x_46_im))));
	else
		tmp = x_46_re ^ 3.0;
	end
	return tmp
end
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[Power[x$46$re, 3.0], $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;{x.re}^{3}\\


\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 91.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-neg91.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-squares91.9%

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

        \[\leadsto \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      4. associate-*l*99.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-squares22.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

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

Alternative 2: 96.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \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}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \end{array} \]
(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))))
   (pow x.re 3.0)))
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 = pow(x_46_re, 3.0);
	}
	return tmp;
}
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 = Math.pow(x_46_re, 3.0);
	}
	return tmp;
}
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 = math.pow(x_46_re, 3.0)
	return tmp
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 = x_46_re ^ 3.0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_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 ^ 3.0;
	end
	tmp_2 = tmp;
end
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[Power[x$46$re, 3.0], $MachinePrecision]]
\begin{array}{l}

\\
\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}:\\
\;\;\;\;{x.re}^{3}\\


\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 91.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-neg91.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-squares91.9%

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

        \[\leadsto \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      4. associate-*l*99.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-squares22.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x.re}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.7%

    \[\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}:\\ \;\;\;\;{x.re}^{3}\\ \end{array} \]

Alternative 3: 96.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \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}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \end{array} \end{array} \]
(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.im 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_im * x_46_im);
	}
	return tmp;
}
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_im * x_46_im);
	}
	return tmp;
}
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_im * x_46_im)
	return tmp
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(x_46_re * Float64(x_46_im * x_46_im));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_re * ((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_im * x_46_im);
	end
	tmp_2 = tmp;
end
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[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\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}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot 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 91.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-neg91.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-squares91.9%

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

        \[\leadsto \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      4. associate-*l*99.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-squares22.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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}:\\ \;\;\;\;x.re \cdot \left(x.im \cdot x.im\right)\\ \end{array} \]

Alternative 4: 64.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x.re \leq 2.8 \cdot 10^{+153}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re - x.im\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 x.im\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.3000000000000001e144

    1. Initial program 42.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-neg42.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-squares62.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-neg62.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*62.5%

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

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

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

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

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

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

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

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

        \[\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-def62.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. *-commutative62.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-rr62.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 30.7%

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

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

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

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

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

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

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

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

    if -2.3000000000000001e144 < x.re < 2.79999999999999985e153

    1. Initial program 90.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-neg90.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-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*99.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.79999999999999985e153 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 5: 88.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 89.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-neg89.5%

        \[\leadsto \left(\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)} - 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. *-commutative89.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, \left(x.im \cdot x.im\right) \cdot \left(\color{blue}{-1 \cdot x.re} + \left(-x.re\right)\right)\right) \]
      13. neg-mul-189.5%

        \[\leadsto \mathsf{fma}\left(x.re, x.re \cdot x.re - x.im \cdot x.im, \left(x.im \cdot x.im\right) \cdot \left(-1 \cdot x.re + \color{blue}{-1 \cdot x.re}\right)\right) \]
      14. distribute-rgt-out89.5%

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

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

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

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

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

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

    if 1.49999999999999995e35 < x.im

    1. Initial program 52.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-neg52.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-squares56.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-neg56.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*71.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-neg71.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-neg71.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. +-commutative71.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. *-commutative71.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. *-commutative71.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-out71.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. Simplified71.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-inv71.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-def71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.1% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.49999999999999967e-31 < x.im

    1. Initial program 56.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares60.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-neg60.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*73.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-neg73.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-neg73.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. +-commutative73.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. *-commutative73.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. *-commutative73.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-out73.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. Simplified73.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-inv73.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-def73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 64.3% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -6.60000000000000054e145

    1. Initial program 42.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-neg42.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-squares62.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-neg62.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*62.5%

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

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

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

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

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

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

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

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

        \[\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-def62.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. *-commutative62.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-rr62.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 30.7%

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

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

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

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

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

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

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

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

    if -6.60000000000000054e145 < x.re < 1.50000000000000013e154

    1. Initial program 90.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-neg90.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-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*99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.50000000000000013e154 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 8: 62.9% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.05e202

    1. Initial program 36.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares53.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-neg53.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*53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05e202 < x.re < 6.20000000000000007e141

    1. Initial program 88.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-neg88.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.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-neg90.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.3%

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

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

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

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

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

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

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

      \[\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}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-out--64.4%

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

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

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

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

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

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

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

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

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

    if 6.20000000000000007e141 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 9: 62.9% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -3.59999999999999976e201

    1. Initial program 36.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares53.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-neg53.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*53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999976e201 < x.re < 7.4999999999999997e140

    1. Initial program 88.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-neg88.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.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-neg90.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.3%

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

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

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

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

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

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

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

      \[\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}{x.re \cdot \left(-1 \cdot {x.im}^{2} - 2 \cdot {x.im}^{2}\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-out--64.4%

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

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

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

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

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

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

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

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

    if 7.4999999999999997e140 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 10: 63.6% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.89999999999999988e141

    1. Initial program 42.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-neg42.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-squares62.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-neg62.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*62.5%

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

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

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

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

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

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

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

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

        \[\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-def62.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. *-commutative62.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-rr62.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 30.7%

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

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

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

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

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

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

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

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

    if -1.89999999999999988e141 < x.re < 5.20000000000000012e150

    1. Initial program 90.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-neg90.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-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*99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000012e150 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 11: 63.7% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.4499999999999999e143

    1. Initial program 42.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-neg42.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-squares62.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-neg62.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*62.5%

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

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

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

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

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

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

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

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

        \[\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-def62.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. *-commutative62.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-rr62.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 30.7%

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

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

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

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

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

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

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

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

    if -1.4499999999999999e143 < x.re < 5.20000000000000028e146

    1. Initial program 90.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-neg90.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-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*99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000028e146 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 12: 42.7% accurate, 1.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.05e202

    1. Initial program 36.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares53.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-neg53.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*53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05e202 < x.re < 1.20000000000000005e151

    1. Initial program 88.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-neg88.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.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-neg90.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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.re\right) - \color{blue}{x.re \cdot \left(x.im \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.im}^{2} \cdot x.re\right)} - x.re \cdot \left(x.im \cdot \left(x.im + x.im\right)\right) \]
    8. Step-by-step derivation
      1. associate-*r*64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-x.re \cdot \left(x.im \cdot x.im\right)} \]
    12. Step-by-step derivation
      1. distribute-lft-neg-in42.8%

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

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

    if 1.20000000000000005e151 < x.re

    1. Initial program 58.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-neg58.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-squares58.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-neg58.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*58.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-neg58.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-neg58.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. +-commutative58.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. *-commutative58.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. *-commutative58.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-out58.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. Simplified58.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. Taylor expanded in x.re around 0 15.4%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 69.0%

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

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

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

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

Alternative 13: 31.1% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -3.6 \cdot 10^{+201}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.im\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.re < -3.59999999999999976e201

    1. Initial program 36.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares53.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-neg53.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*53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999976e201 < x.re

    1. Initial program 85.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-neg85.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-squares86.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-neg86.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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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. Taylor expanded in x.re around 0 66.1%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 30.6%

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

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

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

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

Alternative 14: 31.1% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -4.8 \cdot 10^{+203}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.im\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.re < -4.8000000000000002e203

    1. Initial program 36.7%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares53.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-neg53.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*53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.8000000000000002e203 < x.re

    1. Initial program 85.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-neg85.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-squares86.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-neg86.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*94.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-neg94.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-neg94.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. +-commutative94.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. *-commutative94.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. *-commutative94.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-out94.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. Simplified94.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. Taylor expanded in x.re around 0 66.1%

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

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

      \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 30.6%

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

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

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

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

Alternative 15: 31.9% accurate, 3.8× speedup?

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

\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 79.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-neg79.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-squares82.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-neg82.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*89.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x.re - x.im\right) \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. Taylor expanded in x.re around inf 32.1%

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

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

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

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

Developer target: 87.1% 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 2023291 
(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)))