math.cube on complex, imaginary part

Percentage Accurate: 82.6% → 94.1%
Time: 6.0s
Alternatives: 12
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 82.6% accurate, 1.0× speedup?

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

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

Alternative 1: 94.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;-{x.im}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (- (* x.re (* x.re (* x.im 3.0))) (pow x.im 3.0))
   (- (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - pow(x_46_im, 3.0);
	} else {
		tmp = -pow(x_46_im, 3.0);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - Math.pow(x_46_im, 3.0);
	} else {
		tmp = -Math.pow(x_46_im, 3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= math.inf:
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - math.pow(x_46_im, 3.0)
	else:
		tmp = -math.pow(x_46_im, 3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 3.0))) - (x_46_im ^ 3.0));
	else
		tmp = Float64(-(x_46_im ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Inf)
		tmp = (x_46_re * (x_46_re * (x_46_im * 3.0))) - (x_46_im ^ 3.0);
	else
		tmp = -(x_46_im ^ 3.0);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], (-N[Power[x$46$im, 3.0], $MachinePrecision])]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;-{x.im}^{3}\\


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

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    7. Step-by-step derivation
      1. mul-1-neg73.1%

        \[\leadsto \color{blue}{-{x.im}^{3}} \]
    8. Simplified73.1%

      \[\leadsto \color{blue}{-{x.im}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.2%

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

Alternative 2: 94.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right) - {x.im}^{3}\\ \mathbf{else}:\\ \;\;\;\;-{x.im}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (- (* x.re (* (* x.re x.im) 3.0)) (pow x.im 3.0))
   (- (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - pow(x_46_im, 3.0);
	} else {
		tmp = -pow(x_46_im, 3.0);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.POSITIVE_INFINITY) {
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - Math.pow(x_46_im, 3.0);
	} else {
		tmp = -Math.pow(x_46_im, 3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if ((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= math.inf:
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - math.pow(x_46_im, 3.0)
	else:
		tmp = -math.pow(x_46_im, 3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) * 3.0)) - (x_46_im ^ 3.0));
	else
		tmp = Float64(-(x_46_im ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Inf)
		tmp = (x_46_re * ((x_46_re * x_46_im) * 3.0)) - (x_46_im ^ 3.0);
	else
		tmp = -(x_46_im ^ 3.0);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision], (-N[Power[x$46$im, 3.0], $MachinePrecision])]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;-{x.im}^{3}\\


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

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
    7. Step-by-step derivation
      1. mul-1-neg73.1%

        \[\leadsto \color{blue}{-{x.im}^{3}} \]
    8. Simplified73.1%

      \[\leadsto \color{blue}{-{x.im}^{3}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.2%

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

Alternative 3: 86.8% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 6.99999999999999996e93

    1. Initial program 88.6%

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

    if 6.99999999999999996e93 < x.re

    1. Initial program 57.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot 3\right)} \cdot x.im \]
    5. Step-by-step derivation
      1. add-log-exp43.0%

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

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right)} \]
      3. log-prod43.0%

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

        \[\leadsto \color{blue}{0} + \log \left(e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right) \]
      5. add-log-exp65.9%

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

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

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

        \[\leadsto 0 + x.re \cdot \left(x.re \cdot \color{blue}{\left(x.im \cdot 3\right)}\right) \]
    6. Applied egg-rr80.9%

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

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

Alternative 4: 85.9% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.9000000000000001e-56 or 9.4999999999999997e-68 < x.im

    1. Initial program 83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9000000000000001e-56 < x.im < 9.4999999999999997e-68

    1. Initial program 85.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(x.re \cdot x.re\right) \cdot 3\right)} \cdot x.im \]
    5. Step-by-step derivation
      1. add-log-exp42.7%

        \[\leadsto \color{blue}{\log \left(e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right)} \]
      2. *-un-lft-identity42.7%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right)} \]
      3. log-prod42.7%

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

        \[\leadsto \color{blue}{0} + \log \left(e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right) \]
      5. add-log-exp79.7%

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

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

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

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

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

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

Alternative 5: 55.0% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.3e186 or 1e152 < x.im

    1. Initial program 65.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-{x.re}^{2} \cdot x.im} \]
      2. distribute-rgt-neg-in30.8%

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

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

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

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

    if -4.3e186 < x.im < 1e152

    1. Initial program 90.1%

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

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

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

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

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

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

Alternative 6: 60.6% accurate, 1.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x.re \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 < -7.8000000000000002e186 or 2.2999999999999999e147 < x.im

    1. Initial program 65.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-{x.re}^{2} \cdot x.im} \]
      2. distribute-rgt-neg-in30.8%

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

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

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

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

    if -7.8000000000000002e186 < x.im < 2.2999999999999999e147

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 60.7% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.19999999999999993e187 or 1e152 < x.im

    1. Initial program 65.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-{x.re}^{2} \cdot x.im} \]
      2. distribute-rgt-neg-in30.8%

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

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

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

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

    if -3.19999999999999993e187 < x.im < 1e152

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\left(\left(x.re \cdot x.re\right) \cdot 3\right) \cdot x.im}\right)} \]
      3. log-prod34.9%

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

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

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

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

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

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

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

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

Alternative 8: 40.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.65 \cdot 10^{+186} \lor \neg \left(x.im \leq 9.2 \cdot 10^{+151}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.65000000000000012e186 or 9.2000000000000003e151 < x.im

    1. Initial program 65.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-{x.re}^{2} \cdot x.im} \]
      2. distribute-rgt-neg-in30.8%

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

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

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

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

    if -1.65000000000000012e186 < x.im < 9.2000000000000003e151

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.65 \cdot 10^{+186} \lor \neg \left(x.im \leq 9.2 \cdot 10^{+151}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\ \end{array} \]

Alternative 9: 35.2% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 2.7% accurate, 19.0× speedup?

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

\\
-10
\end{array}
Derivation
  1. Initial program 84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{\color{blue}{6}}\right) \cdot \frac{1}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    10. associate-*l*24.1%

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{\color{blue}{x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)} + {x.im}^{3}} \]
    11. associate-*r*24.1%

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

      \[\leadsto \left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im \cdot 3\right), {x.im}^{3}\right)}} \]
  5. Applied egg-rr24.1%

    \[\leadsto \color{blue}{\left({\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{2} \cdot 9 - {x.im}^{6}\right) \cdot \frac{1}{\mathsf{fma}\left(x.re, x.re \cdot \left(x.im \cdot 3\right), {x.im}^{3}\right)}} \]
  6. Simplified2.7%

    \[\leadsto \color{blue}{-10} \]
  7. Final simplification2.7%

    \[\leadsto -10 \]

Alternative 11: 2.7% accurate, 19.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 84.2%

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

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

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

    \[\leadsto -3 \]

Alternative 12: 15.2% accurate, 19.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x.im - x.im} \]
  7. Step-by-step derivation
    1. +-inverses14.1%

      \[\leadsto \color{blue}{0} \]
  8. Simplified14.1%

    \[\leadsto \color{blue}{0} \]
  9. Final simplification14.1%

    \[\leadsto 0 \]

Developer target: 91.5% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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