math.cube on complex, imaginary part

Percentage Accurate: 82.7% → 99.7%
Time: 7.7s
Alternatives: 12
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 82.7% 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: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t_0 + x.re \cdot 0\\


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

    1. Initial program 95.8%

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow395.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow30.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.5 \cdot 10^{-104} \lor \neg \left(x.im \leq 6.2 \cdot 10^{-104}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + x.re \cdot 0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.49999999999999989e-104 or 6.19999999999999951e-104 < x.im

    1. Initial program 83.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. add-cube-cbrt82.8%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow382.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999989e-104 < x.im < 6.19999999999999951e-104

    1. Initial program 91.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. Step-by-step derivation
      1. add-cube-cbrt91.0%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow391.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -2.5 \cdot 10^{-104} \lor \neg \left(x.im \leq 6.2 \cdot 10^{-104}\right):\\ \;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + x.re \cdot 0\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - x.im\right)\\ \end{array} \]

Alternative 3: 92.2% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -7.3999999999999999e-103 or 2.3000000000000001e-103 < x.im

    1. Initial program 83.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. add-cube-cbrt82.8%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow382.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.3999999999999999e-103 < x.im < 2.3000000000000001e-103

    1. Initial program 91.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. Step-by-step derivation
      1. add-cube-cbrt91.0%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow391.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.8% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.5e10 or 4.4999999999999998e22 < x.im

    1. Initial program 76.2%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re, \color{blue}{x.im \cdot x.re} + x.im \cdot x.re, \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im\right) \]
      5. distribute-rgt-out80.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5e10 < x.im < 4.4999999999999998e22

    1. Initial program 93.7%

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow393.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 36.0% accurate, 2.7× speedup?

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

\\
2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)
\end{array}
Derivation
  1. Initial program 86.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. add-cube-cbrt86.0%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow386.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 50.5% accurate, 2.7× speedup?

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

\\
x.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3\right)
\end{array}
Derivation
  1. Initial program 86.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 53.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. Simplified53.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. Taylor expanded in x.im around 0 52.9%

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

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

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

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

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

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

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

Alternative 7: 56.3% accurate, 2.7× speedup?

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

\\
x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)
\end{array}
Derivation
  1. Initial program 86.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. add-cube-cbrt86.0%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}\right) \cdot \sqrt[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. pow386.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 34.7% accurate, 3.8× speedup?

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

\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 86.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. *-commutative86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
  5. Step-by-step derivation
    1. *-commutative35.9%

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

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

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

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

Alternative 9: 35.4% accurate, 3.8× speedup?

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

\\
x.re \cdot \left(x.re \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 86.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. *-commutative86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
  5. Step-by-step derivation
    1. *-commutative35.9%

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

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

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

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

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

Alternative 10: 2.7% accurate, 19.0× speedup?

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

\\
-10
\end{array}
Derivation
  1. Initial program 86.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. +-commutative86.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. *-commutative86.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-neg86.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-in84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -10 \]

Alternative 11: 2.7% accurate, 19.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 86.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 61.5%

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

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

    \[\leadsto -3 \]

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
0.1
\end{array}
Derivation
  1. Initial program 86.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. +-commutative86.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. *-commutative86.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-neg86.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-in84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.1 \]

Developer target: 91.6% accurate, 1.1× speedup?

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

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

Reproduce

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