math.cube on complex, imaginary part

Percentage Accurate: 83.0% → 94.4%
Time: 6.8s
Alternatives: 15
Speedup: 0.5×

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

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

Initial Program: 83.0% 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.4% 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 90.8%

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

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

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

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

        \[\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+87.3%

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

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

        \[\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*96.2%

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

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

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

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

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

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

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

        \[\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*96.3%

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

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

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

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

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

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

        \[\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+0.0%

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

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

        \[\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*0.0%

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

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

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

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

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

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

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

        \[\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*0.0%

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

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

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

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

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

    \[\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 2: 91.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := 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{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0\\

\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 90.8%

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

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

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

        \[\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+0.0%

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

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

        \[\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*0.0%

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

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

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

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

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

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

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

        \[\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*0.0%

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

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

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

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

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

    \[\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.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.im}^{3}\\ \end{array} \]

Alternative 3: 91.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := 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{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\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.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0

    1. Initial program 90.8%

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

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

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

        \[\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+0.0%

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

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

        \[\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*0.0%

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

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

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

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

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

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

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

        \[\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*0.0%

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

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

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

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

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

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

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

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

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

Alternative 4: 70.8% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -7.2000000000000002e130 or 1.35000000000000003e154 < x.re

    1. Initial program 49.4%

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

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

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

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

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

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

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

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

    if -7.2000000000000002e130 < x.re < 1.35000000000000003e154

    1. Initial program 94.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. *-commutative94.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. *-commutative94.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-+71.2%

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

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

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

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

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

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

      \[\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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.1%

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

Alternative 5: 78.0% accurate, 1.1× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;x.im \cdot t_0 + -3\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -4.8000000000000001e-85

    1. Initial program 78.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. Step-by-step derivation
      1. *-commutative78.9%

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

        \[\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-+73.5%

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

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

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

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

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

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

      \[\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 -4.8000000000000001e-85 < x.im < 5.39999999999999954e55

    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. Taylor expanded in x.re around inf 74.0%

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

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

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

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

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

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

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

    if 5.39999999999999954e55 < x.im

    1. Initial program 75.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 \]
    2. Step-by-step derivation
      1. *-commutative75.6%

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

        \[\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-+77.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{0}{0}, \frac{0}{0}, \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)\right)} \]
    6. Simplified84.4%

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

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

Alternative 6: 61.4% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.5 \cdot 10^{+19} \lor \neg \left(x.im \leq 1.9 \cdot 10^{-27}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.5e19 or 1.9e-27 < x.im

    1. Initial program 77.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 \]
    2. Step-by-step derivation
      1. *-commutative77.6%

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

        \[\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-+72.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{0}{0}, \frac{0}{0}, \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)\right)} \]
    6. Simplified78.4%

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

    if -3.5e19 < x.im < 1.9e-27

    1. Initial program 83.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 \]
    2. Step-by-step derivation
      1. *-commutative83.6%

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

        \[\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-+50.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-in50.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-rr50.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. *-commutative50.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-out50.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-out50.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-rr50.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 38.1%

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

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

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

Alternative 7: 37.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -6.4 \cdot 10^{+130} \lor \neg \left(x.re \leq 3.6 \cdot 10^{+196}\right):\\ \;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) + -3\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -6.4e+130) (not (<= x.re 3.6e+196)))
   (+ (* x.re (* x.im (+ x.re x.re))) -3.0)
   (* -2.0 (* x.re (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -6.4e+130) || !(x_46_re <= 3.6e+196)) {
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + -3.0;
	} else {
		tmp = -2.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_46re <= (-6.4d+130)) .or. (.not. (x_46re <= 3.6d+196))) then
        tmp = (x_46re * (x_46im * (x_46re + x_46re))) + (-3.0d0)
    else
        tmp = (-2.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_re <= -6.4e+130) || !(x_46_re <= 3.6e+196)) {
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + -3.0;
	} else {
		tmp = -2.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_re <= -6.4e+130) or not (x_46_re <= 3.6e+196):
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + -3.0
	else:
		tmp = -2.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_re <= -6.4e+130) || !(x_46_re <= 3.6e+196))
		tmp = Float64(Float64(x_46_re * Float64(x_46_im * Float64(x_46_re + x_46_re))) + -3.0);
	else
		tmp = Float64(-2.0 * 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_re <= -6.4e+130) || ~((x_46_re <= 3.6e+196)))
		tmp = (x_46_re * (x_46_im * (x_46_re + x_46_re))) + -3.0;
	else
		tmp = -2.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$re, -6.4e+130], N[Not[LessEqual[x$46$re, 3.6e+196]], $MachinePrecision]], N[(N[(x$46$re * N[(x$46$im * N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -3.0), $MachinePrecision], N[(-2.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -6.4 \cdot 10^{+130} \lor \neg \left(x.re \leq 3.6 \cdot 10^{+196}\right):\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(x.re + x.re\right)\right) + -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -6.4e130 or 3.60000000000000007e196 < x.re

    1. Initial program 53.4%

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

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

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

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

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

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

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

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

    if -6.4e130 < x.re < 3.60000000000000007e196

    1. Initial program 90.8%

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

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

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

        \[\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-in90.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+90.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-out90.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-neg90.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*91.8%

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

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

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

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

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

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

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

        \[\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*91.8%

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

        \[\leadsto x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - \color{blue}{{x.im}^{3}} \]
    3. Simplified91.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. add-cbrt-cube64.5%

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

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

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

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

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

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

Alternative 8: 36.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -5.5 \cdot 10^{+130} \lor \neg \left(x.re \leq 3.6 \cdot 10^{+196}\right):\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot x.im + -3\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re -5.5e+130) (not (<= x.re 3.6e+196)))
   (+ (* (* x.re x.re) x.im) -3.0)
   (* -2.0 (* x.re (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -5.5e+130) || !(x_46_re <= 3.6e+196)) {
		tmp = ((x_46_re * x_46_re) * x_46_im) + -3.0;
	} else {
		tmp = -2.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_46re <= (-5.5d+130)) .or. (.not. (x_46re <= 3.6d+196))) then
        tmp = ((x_46re * x_46re) * x_46im) + (-3.0d0)
    else
        tmp = (-2.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_re <= -5.5e+130) || !(x_46_re <= 3.6e+196)) {
		tmp = ((x_46_re * x_46_re) * x_46_im) + -3.0;
	} else {
		tmp = -2.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_re <= -5.5e+130) or not (x_46_re <= 3.6e+196):
		tmp = ((x_46_re * x_46_re) * x_46_im) + -3.0
	else:
		tmp = -2.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_re <= -5.5e+130) || !(x_46_re <= 3.6e+196))
		tmp = Float64(Float64(Float64(x_46_re * x_46_re) * x_46_im) + -3.0);
	else
		tmp = Float64(-2.0 * 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_re <= -5.5e+130) || ~((x_46_re <= 3.6e+196)))
		tmp = ((x_46_re * x_46_re) * x_46_im) + -3.0;
	else
		tmp = -2.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$re, -5.5e+130], N[Not[LessEqual[x$46$re, 3.6e+196]], $MachinePrecision]], N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] + -3.0), $MachinePrecision], N[(-2.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.5 \cdot 10^{+130} \lor \neg \left(x.re \leq 3.6 \cdot 10^{+196}\right):\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.im + -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -5.4999999999999997e130 or 3.60000000000000007e196 < x.re

    1. Initial program 53.4%

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

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

        \[\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-+41.5%

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

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

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

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

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

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

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

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

      \[\leadsto -3 + \color{blue}{{x.re}^{2}} \cdot x.im \]
    8. Simplified60.1%

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

    if -5.4999999999999997e130 < x.re < 3.60000000000000007e196

    1. Initial program 90.8%

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

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

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

        \[\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-in90.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+90.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-out90.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-neg90.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*91.8%

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

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

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

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

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

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

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

        \[\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*91.8%

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

        \[\leadsto x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - \color{blue}{{x.im}^{3}} \]
    3. Simplified91.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. add-cbrt-cube64.5%

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

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

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

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

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

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

Alternative 9: 24.2% accurate, 2.7× speedup?

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

\\
-2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)
\end{array}
Derivation
  1. Initial program 80.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 \]
  2. Step-by-step derivation
    1. +-commutative80.6%

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

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

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

      \[\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+77.4%

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

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

      \[\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*85.3%

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

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

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

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

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

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

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

      \[\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*85.4%

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

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

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

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

      \[\leadsto x.re \cdot \sqrt[3]{\color{blue}{{\left(x.re \cdot \left(x.im \cdot 3\right)\right)}^{3}}} - {x.im}^{3} \]
  5. Applied egg-rr64.8%

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

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

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

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

Alternative 10: 24.1% accurate, 3.2× speedup?

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

\\
\left(x.re \cdot x.re\right) \cdot \left(-x.im\right)
\end{array}
Derivation
  1. Initial program 80.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 \]
  2. Taylor expanded in x.re around inf 47.9%

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

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

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

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

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

Alternative 11: 3.6% accurate, 6.3× speedup?

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

\\
x.re \cdot -3
\end{array}
Derivation
  1. Initial program 80.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 \]
  2. Taylor expanded in x.re around 0 64.3%

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

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

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

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

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

      \[\leadsto -3 + \left(e^{\mathsf{log1p}\left(\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}}\right)} - 1\right) \cdot x.re \]
    5. +-inverses0.0%

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

      \[\leadsto -3 + \left(e^{\mathsf{log1p}\left(\frac{0}{\color{blue}{0}}\right)} - 1\right) \cdot x.re \]
  5. Applied egg-rr0.0%

    \[\leadsto -3 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0}{0}\right)} - 1\right)} \cdot x.re \]
  6. Simplified3.2%

    \[\leadsto -3 + \color{blue}{-3} \cdot x.re \]
  7. Taylor expanded in x.re around inf 3.6%

    \[\leadsto \color{blue}{-3 \cdot x.re} \]
  8. Final simplification3.6%

    \[\leadsto x.re \cdot -3 \]

Alternative 12: 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 80.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 \]
  2. Step-by-step derivation
    1. +-commutative80.6%

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

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

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

      \[\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+77.4%

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

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

      \[\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*85.3%

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

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

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

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

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

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

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

      \[\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*85.4%

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

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

    \[\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*85.4%

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

      \[\leadsto \color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3} - {x.im}^{3} \]
    3. flip--19.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-inv19.4%

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

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

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

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

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

      \[\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*19.2%

      \[\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*19.2%

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

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

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

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

    \[\leadsto -10 \]

Alternative 13: 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 80.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 \]
  2. Taylor expanded in x.re around 0 64.3%

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

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

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

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

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

      \[\leadsto -3 + \left(e^{\mathsf{log1p}\left(\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}}\right)} - 1\right) \cdot x.re \]
    5. +-inverses0.0%

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

      \[\leadsto -3 + \left(e^{\mathsf{log1p}\left(\frac{0}{\color{blue}{0}}\right)} - 1\right) \cdot x.re \]
  5. Applied egg-rr0.0%

    \[\leadsto -3 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{0}{0}\right)} - 1\right)} \cdot x.re \]
  6. Simplified3.2%

    \[\leadsto -3 + \color{blue}{-3} \cdot x.re \]
  7. Taylor expanded in x.re around 0 2.5%

    \[\leadsto \color{blue}{-3} \]
  8. Final simplification2.5%

    \[\leadsto -3 \]

Alternative 14: 2.7% accurate, 19.0× speedup?

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

\\
0.1
\end{array}
Derivation
  1. Initial program 80.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 \]
  2. Step-by-step derivation
    1. +-commutative80.6%

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

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

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

      \[\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+77.4%

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

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

      \[\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*85.3%

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

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

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

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

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

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

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

      \[\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*85.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{\left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)}} \]
    5. associate-*r*11.7%

      \[\leadsto \frac{{\left(\color{blue}{\left(\left(x.re \cdot x.re\right) \cdot x.im\right)} \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    6. associate-*r*11.6%

      \[\leadsto \frac{{\color{blue}{\left(\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\right)}}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    7. unpow-prod-down5.8%

      \[\leadsto \frac{\color{blue}{{\left(x.re \cdot x.re\right)}^{3} \cdot {\left(x.im \cdot 3\right)}^{3}} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    8. pow25.8%

      \[\leadsto \frac{{\color{blue}{\left({x.re}^{2}\right)}}^{3} \cdot {\left(x.im \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    9. pow-pow5.8%

      \[\leadsto \frac{\color{blue}{{x.re}^{\left(2 \cdot 3\right)}} \cdot {\left(x.im \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
    10. metadata-eval5.8%

      \[\leadsto \frac{{x.re}^{\color{blue}{6}} \cdot {\left(x.im \cdot 3\right)}^{3} + {\left(-{x.im}^{3}\right)}^{3}}{\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) + \left(\left(-{x.im}^{3}\right) \cdot \left(-{x.im}^{3}\right) - \left(\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3\right) \cdot \left(-{x.im}^{3}\right)\right)} \]
  5. Applied egg-rr5.9%

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

    \[\leadsto \color{blue}{0.1} \]
  7. Final simplification2.8%

    \[\leadsto 0.1 \]

Alternative 15: 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 80.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 \]
  2. Step-by-step derivation
    1. +-commutative80.6%

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

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

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

      \[\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+77.4%

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

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

      \[\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*85.3%

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

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

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

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

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

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

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

      \[\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*85.4%

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

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

    \[\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*85.4%

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

      \[\leadsto \color{blue}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3} - {x.im}^{3} \]
    3. flip--19.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. swap-sqr19.3%

      \[\leadsto \frac{\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}}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    5. pow219.3%

      \[\leadsto \frac{\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}}{\left(x.re \cdot \left(x.re \cdot x.im\right)\right) \cdot 3 + {x.im}^{3}} \]
    6. metadata-eval19.3%

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

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

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

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

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

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

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

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

    \[\leadsto 10 \]

Developer target: 91.6% 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 2023173 
(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)))