math.cube on complex, real part

Percentage Accurate: 83.5% → 96.6%
Time: 11.2s
Alternatives: 8
Speedup: 1.5×

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 8 alternatives:

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

Initial Program: 83.5% 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.6% 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 \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\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)
   (fma
    (- x.re x.im)
    (* x.re (+ x.re x.im))
    (* (- x.im) (* x.re (+ x.im x.im))))
   (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re - x_46_im), (x_46_re * (x_46_re + x_46_im)), (-x_46_im * (x_46_re * (x_46_im + x_46_im))));
	} else {
		tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
	}
	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 = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re)));
	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[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $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:\\
\;\;\;\;\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 \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\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 93.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-neg93.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-squares93.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-neg93.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)} \]

    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. Step-by-step derivation
      1. sub-neg22.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq 3.2 \cdot 10^{+164}:\\ \;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 3.2e+164)
   (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))
   (* x.im (* x.im (* x.re -3.0)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 3.2e+164) {
		tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
	} else {
		tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
	}
	return tmp;
}
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= 3.2e+164)
		tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re)));
	else
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)));
	end
	return tmp
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 3.2e+164], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 83.8%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares85.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-neg85.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*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1999999999999998e164 < x.im

    1. Initial program 56.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-neg56.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-squares69.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-neg69.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*86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(x.im \cdot \color{blue}{\left(x.im \cdot \left(x.re \cdot -3\right)\right)}\right)}^{1} \]
    10. Applied egg-rr86.2%

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

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

Alternative 3: 92.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq 4.5 \cdot 10^{+152}:\\ \;\;\;\;x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.im + x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im 4.5e+152)
   (* x.re (- (- (* x.re x.re) (* x.im x.im)) (* x.im (+ x.im x.im))))
   (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= 4.5e+152) {
		tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
	} else {
		tmp = 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 <= 4.5d+152) then
        tmp = x_46re * (((x_46re * x_46re) - (x_46im * x_46im)) - (x_46im * (x_46im + x_46im)))
    else
        tmp = 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 <= 4.5e+152) {
		tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
	} else {
		tmp = 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 <= 4.5e+152:
		tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)))
	else:
		tmp = 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 <= 4.5e+152)
		tmp = Float64(x_46_re * Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) - Float64(x_46_im * Float64(x_46_im + x_46_im))));
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re * 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 <= 4.5e+152)
		tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
	else
		tmp = 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, 4.5e+152], N[(x$46$re * N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 83.8%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares85.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-neg85.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*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e152 < x.im

    1. Initial program 56.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-neg56.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-squares69.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-neg69.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*86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 92.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 83.8%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares85.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-neg85.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*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e152 < x.im

    1. Initial program 56.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-neg56.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-squares69.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-neg69.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*86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(x.im \cdot \color{blue}{\left(x.im \cdot \left(x.re \cdot -3\right)\right)}\right)}^{1} \]
    10. Applied egg-rr86.2%

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

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

Alternative 5: 92.6% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 83.8%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares85.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-neg85.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*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e152 < x.im

    1. Initial program 56.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-neg56.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-squares69.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-neg69.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*86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 92.6% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 83.8%

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

        \[\leadsto \left(x.re \cdot x.re - \color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      2. difference-of-squares85.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-neg85.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*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e152 < x.im

    1. Initial program 56.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-neg56.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-squares69.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-neg69.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*86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 80.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -8.8 \cdot 10^{+16} \lor \neg \left(x.re \leq 6 \cdot 10^{-28}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -8.8e16 or 6.00000000000000005e-28 < x.re

    1. Initial program 74.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-neg74.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-squares80.2%

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

        \[\leadsto \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
      4. associate-*l*80.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-neg80.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-neg80.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. +-commutative80.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. *-commutative80.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. *-commutative80.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-out80.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. Simplified80.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. sub-neg80.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 \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)} \]
      2. *-commutative80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.8e16 < x.re < 6.00000000000000005e-28

    1. Initial program 88.0%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Simplified88.0%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 58.6% accurate, 3.8× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 80.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-neg80.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-squares83.8%

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

      \[\leadsto \left(\color{blue}{\left(x.re - x.im\right)} \cdot \left(x.re - \left(-x.im\right)\right)\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    4. associate-*l*89.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-neg89.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-neg89.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. +-commutative89.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. *-commutative89.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. *-commutative89.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-out89.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. Simplified89.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. sub-neg89.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 \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)} \]
    2. *-commutative89.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  16. Final simplification59.4%

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

Developer target: 87.5% accurate, 1.1× speedup?

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

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

Reproduce

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