math.cube on complex, imaginary part

Percentage Accurate: 82.6% → 96.3%
Time: 8.5s
Alternatives: 9
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 82.6% accurate, 1.0× speedup?

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

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

Alternative 1: 96.3% accurate, 1.1× speedup?

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

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


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

    1. Initial program 80.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 0 80.7%

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

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

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

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

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

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

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

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

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

    if 7.79999999999999981e150 < x.re

    1. Initial program 46.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. Taylor expanded in x.re around 0 46.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, {x.re}^{2}, -1 \cdot {x.im}^{3}\right)} + x.im \cdot \left(2 \cdot \left(x.re \cdot x.re\right)\right) \]
      3. mul-1-neg42.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.2% accurate, 1.0× speedup?

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

\mathbf{elif}\;x.im \leq -5.9 \cdot 10^{-64}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x.im \leq 1.6 \cdot 10^{+146}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x.im < -1.79999999999999997e162

    1. Initial program 41.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. Applied egg-rr17.2%

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

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

    if -1.79999999999999997e162 < x.im < -5.89999999999999995e-64 or 2.6000000000000001e-101 < x.im < 1.6e146

    1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.89999999999999995e-64 < x.im < 2.6000000000000001e-101

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6e146 < x.im

    1. Initial program 39.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.im \cdot \color{blue}{\left(-x.im \cdot x.im\right)} \]
      3. distribute-rgt-neg-in76.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.8 \cdot 10^{+162}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq -5.9 \cdot 10^{-64}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) - x.im \cdot x.im\right)\\ \mathbf{elif}\;x.im \leq 2.6 \cdot 10^{-101}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right)\\ \mathbf{elif}\;x.im \leq 1.6 \cdot 10^{+146}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) - x.im \cdot x.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \end{array} \]

Alternative 3: 69.2% accurate, 1.6× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.re \leq 1.45 \cdot 10^{+170} \lor \neg \left(x.re \leq 9.2 \cdot 10^{+179}\right) \land x.re \leq 4.2 \cdot 10^{+221}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.re 1.45e+170) (and (not (<= x.re 9.2e+179)) (<= x.re 4.2e+221)))
   (* x.im (* x.im (- x.im)))
   (* x.re (* x.re x.im))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= 1.45e+170) || (!(x_46_re <= 9.2e+179) && (x_46_re <= 4.2e+221))) {
		tmp = x_46_im * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * x_46_im);
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46re <= 1.45d+170) .or. (.not. (x_46re <= 9.2d+179)) .and. (x_46re <= 4.2d+221)) then
        tmp = x_46im * (x_46im * -x_46im)
    else
        tmp = x_46re * (x_46re * x_46im)
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= 1.45e+170) || (!(x_46_re <= 9.2e+179) && (x_46_re <= 4.2e+221))) {
		tmp = x_46_im * (x_46_im * -x_46_im);
	} else {
		tmp = x_46_re * (x_46_re * x_46_im);
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= 1.45e+170) or (not (x_46_re <= 9.2e+179) and (x_46_re <= 4.2e+221)):
		tmp = x_46_im * (x_46_im * -x_46_im)
	else:
		tmp = x_46_re * (x_46_re * x_46_im)
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= 1.45e+170) || (!(x_46_re <= 9.2e+179) && (x_46_re <= 4.2e+221)))
		tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im)));
	else
		tmp = Float64(x_46_re * Float64(x_46_re * x_46_im));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_re <= 1.45e+170) || (~((x_46_re <= 9.2e+179)) && (x_46_re <= 4.2e+221)))
		tmp = x_46_im * (x_46_im * -x_46_im);
	else
		tmp = x_46_re * (x_46_re * x_46_im);
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, 1.45e+170], And[N[Not[LessEqual[x$46$re, 9.2e+179]], $MachinePrecision], LessEqual[x$46$re, 4.2e+221]]], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 1.45 \cdot 10^{+170} \lor \neg \left(x.re \leq 9.2 \cdot 10^{+179}\right) \land x.re \leq 4.2 \cdot 10^{+221}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 1.45e170 or 9.19999999999999976e179 < x.re < 4.20000000000000004e221

    1. Initial program 78.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. Taylor expanded in x.re around 0 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45e170 < x.re < 9.19999999999999976e179 or 4.20000000000000004e221 < x.re

    1. Initial program 59.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 89.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. Step-by-step derivation
      1. unpow289.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. Simplified89.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 \]
    5. Step-by-step derivation
      1. *-commutative89.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{\color{blue}{x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      5. exp-prod89.0%

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

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{\left(2 \cdot \left(x.re \cdot x.im\right)\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      7. count-289.0%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      8. *-commutative89.0%

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

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      10. sqrt-prod77.3%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\sqrt{x.im \cdot x.im}} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      11. sqr-neg77.3%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \sqrt{\color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      12. sqrt-unprod23.5%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(\sqrt{-x.im} \cdot \sqrt{-x.im}\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      13. add-sqr-sqrt53.7%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(-x.im\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      14. cancel-sign-sub-inv53.7%

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{\left(x.re \cdot x.im - x.im \cdot x.re\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      15. *-commutative53.7%

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

        \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{0}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
      17. metadata-eval89.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq 1.45 \cdot 10^{+170} \lor \neg \left(x.re \leq 9.2 \cdot 10^{+179}\right) \land x.re \leq 4.2 \cdot 10^{+221}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im\right)\\ \end{array} \]

Alternative 4: 74.4% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.8000000000000002e-4 or 2.5000000000000001e-4 < x.im

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8000000000000002e-4 < x.im < 2.5000000000000001e-4

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -0.00038 \lor \neg \left(x.im \leq 0.00025\right):\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)\\ \end{array} \]

Alternative 5: 74.3% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.7e-4 or 3.4999999999999997e-5 < x.im

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7e-4 < x.im < 3.4999999999999997e-5

    1. Initial program 89.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 0 89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.1% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5.9999999999999997e-7 or 0.0019499999999999999 < x.im

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.9999999999999997e-7 < x.im < 0.0019499999999999999

    1. Initial program 89.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 0 89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 35.6% accurate, 3.8× speedup?

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

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

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

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

    \[\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 \]
  5. Step-by-step derivation
    1. *-commutative54.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(e^{\left(x.re \cdot x.re\right) \cdot x.im + \left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.re}\right)} \]
    2. +-commutative36.8%

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

      \[\leadsto \log \color{blue}{\left(e^{\left(\left(x.re \cdot x.im\right) \cdot 2\right) \cdot x.re} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right)} \]
    4. *-commutative36.8%

      \[\leadsto \log \left(e^{\color{blue}{x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    5. exp-prod36.4%

      \[\leadsto \log \left(\color{blue}{{\left(e^{x.re}\right)}^{\left(\left(x.re \cdot x.im\right) \cdot 2\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    6. *-commutative36.4%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{\left(2 \cdot \left(x.re \cdot x.im\right)\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    7. count-236.4%

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

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

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    10. sqrt-prod33.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\sqrt{x.im \cdot x.im}} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    11. sqr-neg33.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \sqrt{\color{blue}{\left(-x.im\right) \cdot \left(-x.im\right)}} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    12. sqrt-unprod24.2%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(\sqrt{-x.im} \cdot \sqrt{-x.im}\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    13. add-sqr-sqrt29.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im + \color{blue}{\left(-x.im\right)} \cdot x.re\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    14. cancel-sign-sub-inv29.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{\left(x.re \cdot x.im - x.im \cdot x.re\right)}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    15. *-commutative29.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\left(x.re \cdot x.im - \color{blue}{x.re \cdot x.im}\right)} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    16. +-inverses36.7%

      \[\leadsto \log \left({\left(e^{x.re}\right)}^{\color{blue}{0}} \cdot e^{\left(x.re \cdot x.re\right) \cdot x.im}\right) \]
    17. metadata-eval36.7%

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

      \[\leadsto \log \color{blue}{\left(e^{\left(x.re \cdot x.re\right) \cdot x.im}\right)} \]
  8. Applied egg-rr39.6%

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

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

Alternative 8: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ -3 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 -3.0)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return -3.0;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -3.0d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return -3.0;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return -3.0
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return -3.0
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = -3.0;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := -3.0
\begin{array}{l}
x.re = |x.re|\\
\\
-3
\end{array}
Derivation
  1. Initial program 77.5%

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

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

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

      \[\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-in75.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+75.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-out75.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-neg75.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*80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -3 \]

Alternative 9: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ 0.125 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 0.125)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return 0.125;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = 0.125d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return 0.125;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return 0.125
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return 0.125
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = 0.125;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := 0.125
\begin{array}{l}
x.re = |x.re|\\
\\
0.125
\end{array}
Derivation
  1. Initial program 77.5%

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

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

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

      \[\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-in75.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+75.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-out75.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-neg75.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*80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.125 \]

Developer target: 91.7% 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 2023238 
(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)))