math.cube on complex, real part

Percentage Accurate: 82.6% → 98.2%
Time: 8.8s
Alternatives: 6
Speedup: 1.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

Alternative 1: 98.2% accurate, 1.1× speedup?

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

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


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

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.99999999999999987e148 < x.im

    1. Initial program 38.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.1% accurate, 1.5× speedup?

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

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


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

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.6000000000000003e148 < x.im

    1. Initial program 38.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.8% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -8.5999999999999996e42 or 9.99999999999999971e-29 < x.re

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    10. Simplified84.3%

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

    if -8.5999999999999996e42 < x.re < 9.99999999999999971e-29

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.7% accurate, 1.7× speedup?

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
    10. Simplified68.1%

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

    if 2.94999999999999982e-15 < x.im

    1. Initial program 58.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 27.8% accurate, 3.8× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ x.re \cdot \left(x.im \cdot x.re\right) \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.im x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_im * x_46_re);
}
NOTE: x.im 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_46im * x_46re)
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_im * x_46_re);
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_im * x_46_re)
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_im * x_46_re))
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_im * x_46_re);
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.im \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
    2. unpow227.3%

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

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

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

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

Alternative 6: 58.9% accurate, 3.8× speedup?

\[\begin{array}{l} x.im = |x.im|\\ \\ x.re \cdot \left(x.re \cdot x.re\right) \end{array} \]
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
NOTE: x.im 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_46re)
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_re);
}
x.im = abs(x.im)
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_re * x_46_re)
x.im = abs(x.im)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_re * x_46_re))
end
x.im = abs(x.im)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_re * x_46_re);
end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Derivation
  1. Initial program 82.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x.re \cdot \color{blue}{{x.re}^{2}} \]
  10. Simplified58.9%

    \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot x.re\right)} \]
  11. Final simplification58.9%

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

Developer target: 87.1% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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