math.cube on complex, real part

Percentage Accurate: 82.9% → 98.4%
Time: 5.2s
Alternatives: 9
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 82.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ t_1 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im \cdot x.im\right) \cdot \left(x.re \cdot 2\right)\\ \mathbf{if}\;x.re \leq -2 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.re \leq -1.25 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.re \leq 2.8 \cdot 10^{-177}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 6 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* (+ x.re x.im) (* x.re (- x.re x.im))))
        (t_1
         (-
          (* x.re (- (* x.re x.re) (* x.im x.im)))
          (* (* x.im x.im) (* x.re 2.0)))))
   (if (<= x.re -2e+119)
     t_0
     (if (<= x.re -1.25e-104)
       t_1
       (if (<= x.re 2.8e-177)
         (* x.im (* (* x.re x.im) -3.0))
         (if (<= x.re 6e+57) t_1 t_0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	double t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - ((x_46_im * x_46_im) * (x_46_re * 2.0));
	double tmp;
	if (x_46_re <= -2e+119) {
		tmp = t_0;
	} else if (x_46_re <= -1.25e-104) {
		tmp = t_1;
	} else if (x_46_re <= 2.8e-177) {
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
	} else if (x_46_re <= 6e+57) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x_46re + x_46im) * (x_46re * (x_46re - x_46im))
    t_1 = (x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - ((x_46im * x_46im) * (x_46re * 2.0d0))
    if (x_46re <= (-2d+119)) then
        tmp = t_0
    else if (x_46re <= (-1.25d-104)) then
        tmp = t_1
    else if (x_46re <= 2.8d-177) then
        tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
    else if (x_46re <= 6d+57) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	double t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - ((x_46_im * x_46_im) * (x_46_re * 2.0));
	double tmp;
	if (x_46_re <= -2e+119) {
		tmp = t_0;
	} else if (x_46_re <= -1.25e-104) {
		tmp = t_1;
	} else if (x_46_re <= 2.8e-177) {
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
	} else if (x_46_re <= 6e+57) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))
	t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - ((x_46_im * x_46_im) * (x_46_re * 2.0))
	tmp = 0
	if x_46_re <= -2e+119:
		tmp = t_0
	elif x_46_re <= -1.25e-104:
		tmp = t_1
	elif x_46_re <= 2.8e-177:
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0)
	elif x_46_re <= 6e+57:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im)))
	t_1 = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(Float64(x_46_im * x_46_im) * Float64(x_46_re * 2.0)))
	tmp = 0.0
	if (x_46_re <= -2e+119)
		tmp = t_0;
	elseif (x_46_re <= -1.25e-104)
		tmp = t_1;
	elseif (x_46_re <= 2.8e-177)
		tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -3.0));
	elseif (x_46_re <= 6e+57)
		tmp = t_1;
	else
		tmp = t_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_re * (x_46_re - x_46_im));
	t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - ((x_46_im * x_46_im) * (x_46_re * 2.0));
	tmp = 0.0;
	if (x_46_re <= -2e+119)
		tmp = t_0;
	elseif (x_46_re <= -1.25e-104)
		tmp = t_1;
	elseif (x_46_re <= 2.8e-177)
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
	elseif (x_46_re <= 6e+57)
		tmp = t_1;
	else
		tmp = t_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$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x$46$im * x$46$im), $MachinePrecision] * N[(x$46$re * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -2e+119], t$95$0, If[LessEqual[x$46$re, -1.25e-104], t$95$1, If[LessEqual[x$46$re, 2.8e-177], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6e+57], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x.re \leq -1.25 \cdot 10^{-104}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x.re \leq 6 \cdot 10^{+57}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.99999999999999989e119 or 5.9999999999999999e57 < x.re

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) + \left(-\left(x.re \cdot x.im\right) \cdot x.im\right)\right) \]
      11. add-sqr-sqrt53.2%

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

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

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

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

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

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

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

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

    if -1.99999999999999989e119 < x.re < -1.24999999999999995e-104 or 2.79999999999999987e-177 < x.re < 5.9999999999999999e57

    1. Initial program 99.7%

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

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

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

    if -1.24999999999999995e-104 < x.re < 2.79999999999999987e-177

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2 \cdot 10^{+119}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ \mathbf{elif}\;x.re \leq -1.25 \cdot 10^{-104}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im \cdot x.im\right) \cdot \left(x.re \cdot 2\right)\\ \mathbf{elif}\;x.re \leq 2.8 \cdot 10^{-177}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\ \mathbf{elif}\;x.re \leq 6 \cdot 10^{+57}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im \cdot x.im\right) \cdot \left(x.re \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ \end{array} \]

Alternative 2: 94.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.im\right)\\ t_1 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)\\ \mathbf{if}\;t_1 - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq 2 \cdot 10^{+240}:\\ \;\;\;\;t_1 - \left(t_0 + t_0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0 (* x.im (* x.re x.im)))
        (t_1 (* x.re (- (* x.re x.re) (* x.im x.im)))))
   (if (<= (- t_1 (* x.im (+ (* x.re x.im) (* x.re x.im)))) 2e+240)
     (- t_1 (+ t_0 t_0))
     (* (+ x.re x.im) (* x.re (- x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_re * x_46_im);
	double t_1 = x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	double tmp;
	if ((t_1 - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+240) {
		tmp = t_1 - (t_0 + t_0);
	} else {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x_46im * (x_46re * x_46im)
    t_1 = x_46re * ((x_46re * x_46re) - (x_46im * x_46im))
    if ((t_1 - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= 2d+240) then
        tmp = t_1 - (t_0 + t_0)
    else
        tmp = (x_46re + x_46im) * (x_46re * (x_46re - x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_im * (x_46_re * x_46_im);
	double t_1 = x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	double tmp;
	if ((t_1 - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+240) {
		tmp = t_1 - (t_0 + t_0);
	} else {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_im * (x_46_re * x_46_im)
	t_1 = x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))
	tmp = 0
	if (t_1 - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+240:
		tmp = t_1 - (t_0 + t_0)
	else:
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_im * Float64(x_46_re * x_46_im))
	t_1 = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)))
	tmp = 0.0
	if (Float64(t_1 - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= 2e+240)
		tmp = Float64(t_1 - Float64(t_0 + t_0));
	else
		tmp = Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = x_46_im * (x_46_re * x_46_im);
	t_1 = x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im));
	tmp = 0.0;
	if ((t_1 - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= 2e+240)
		tmp = t_1 - (t_0 + t_0);
	else
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+240], N[(t$95$1 - N[(t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

    1. Initial program 98.2%

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

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

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

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

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

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

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

    if 2.00000000000000003e240 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) + \left(-\left(x.re \cdot x.im\right) \cdot x.im\right)\right) \]
      11. add-sqr-sqrt27.0%

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

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

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

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

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

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

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

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

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

Alternative 3: 94.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+240}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (-
          (* x.re (- (* x.re x.re) (* x.im x.im)))
          (* x.im (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_0 2e+240) t_0 (* (+ x.re x.im) (* x.re (- x.re x.im))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 2e+240) {
		tmp = t_0;
	} else {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))
    if (t_0 <= 2d+240) then
        tmp = t_0
    else
        tmp = (x_46re + x_46im) * (x_46re * (x_46re - x_46im))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double t_0 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 2e+240) {
		tmp = t_0;
	} else {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	tmp = 0
	if t_0 <= 2e+240:
		tmp = t_0
	else:
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_0 <= 2e+240)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	tmp = 0.0;
	if (t_0 <= 2e+240)
		tmp = t_0;
	else
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+240], t$95$0, N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 98.2%

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

    if 2.00000000000000003e240 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) + \left(-\left(x.re \cdot x.im\right) \cdot x.im\right)\right) \]
      11. add-sqr-sqrt27.0%

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

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

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

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

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

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

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

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

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

Alternative 4: 90.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.re \leq -6.6 \cdot 10^{-88} \lor \neg \left(x.re \leq 2.7 \cdot 10^{+36}\right):\\ \;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \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.re -6.6e-88) (not (<= x.re 2.7e+36)))
   (* (+ x.re x.im) (* x.re (- x.re x.im)))
   (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -6.6e-88) || !(x_46_re <= 2.7e+36)) {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	} else {
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46re <= (-6.6d-88)) .or. (.not. (x_46re <= 2.7d+36))) then
        tmp = (x_46re + x_46im) * (x_46re * (x_46re - x_46im))
    else
        tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_re <= -6.6e-88) || !(x_46_re <= 2.7e+36)) {
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	} else {
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_re <= -6.6e-88) or not (x_46_re <= 2.7e+36):
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))
	else:
		tmp = x_46_im * ((x_46_re * x_46_im) * -3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_re <= -6.6e-88) || !(x_46_re <= 2.7e+36))
		tmp = Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im)));
	else
		tmp = Float64(x_46_im * 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_re <= -6.6e-88) || ~((x_46_re <= 2.7e+36)))
		tmp = (x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im));
	else
		tmp = x_46_im * ((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$re, -6.6e-88], N[Not[LessEqual[x$46$re, 2.7e+36]], $MachinePrecision]], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -6.6 \cdot 10^{-88} \lor \neg \left(x.re \leq 2.7 \cdot 10^{+36}\right):\\
\;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x.im \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.re < -6.59999999999999987e-88 or 2.7000000000000001e36 < x.re

    1. Initial program 77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) + \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) + \left(-\left(x.re \cdot x.im\right) \cdot x.im\right)\right) \]
      11. add-sqr-sqrt57.4%

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

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

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

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

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

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

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

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

    if -6.59999999999999987e-88 < x.re < 2.7000000000000001e36

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 60.1% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5 \cdot 10^{+154} \lor \neg \left(x.re \leq 4.6 \cdot 10^{+149}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -5.00000000000000004e154 or 4.5999999999999997e149 < x.re

    1. Initial program 50.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
      5. add-sqr-sqrt5.1%

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      7. sqr-neg14.5%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      9. add-sqr-sqrt0.4%

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

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

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.im \cdot x.im\right)} \]
      14. distribute-lft-neg-out10.1%

        \[\leadsto \color{blue}{\left(-x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
      15. add-sqr-sqrt5.1%

        \[\leadsto \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      16. sqrt-unprod29.1%

        \[\leadsto \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) \]
      17. sqr-neg29.1%

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

        \[\leadsto \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      19. add-sqr-sqrt42.1%

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

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

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

    if -5.00000000000000004e154 < x.re < 4.5999999999999997e149

    1. Initial program 93.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 38.8% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -9.2000000000000005e153 or 6.0999999999999999e149 < x.re

    1. Initial program 50.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
      5. add-sqr-sqrt5.1%

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      7. sqr-neg14.5%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      9. add-sqr-sqrt0.4%

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

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

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.im \cdot x.im\right)} \]
      14. distribute-lft-neg-out10.1%

        \[\leadsto \color{blue}{\left(-x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
      15. add-sqr-sqrt5.1%

        \[\leadsto \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      16. sqrt-unprod29.1%

        \[\leadsto \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) \]
      17. sqr-neg29.1%

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

        \[\leadsto \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      19. add-sqr-sqrt42.1%

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

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

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

    if -9.2000000000000005e153 < x.re < 6.0999999999999999e149

    1. Initial program 93.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
      5. add-sqr-sqrt33.8%

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      7. sqr-neg37.2%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      9. add-sqr-sqrt22.4%

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

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

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

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

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

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

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

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

Alternative 7: 39.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.45 \cdot 10^{+154} \lor \neg \left(x.re \leq 5.2 \cdot 10^{+149}\right):\\
\;\;\;\;x.im \cdot \left(x.re \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -1.4499999999999999e154 or 5.19999999999999957e149 < x.re

    1. Initial program 50.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
      5. add-sqr-sqrt5.1%

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      7. sqr-neg14.5%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      9. add-sqr-sqrt0.4%

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

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

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

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

        \[\leadsto -\color{blue}{x.re \cdot \left(x.im \cdot x.im\right)} \]
      14. distribute-lft-neg-out10.1%

        \[\leadsto \color{blue}{\left(-x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
      15. add-sqr-sqrt5.1%

        \[\leadsto \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      16. sqrt-unprod29.1%

        \[\leadsto \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) \]
      17. sqr-neg29.1%

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

        \[\leadsto \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
      19. add-sqr-sqrt42.1%

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

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

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

    if -1.4499999999999999e154 < x.re < 5.19999999999999957e149

    1. Initial program 93.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
      5. add-sqr-sqrt33.8%

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

        \[\leadsto \left(\color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      7. sqr-neg37.2%

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

        \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
      9. add-sqr-sqrt22.4%

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

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

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

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

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

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

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

Alternative 8: 23.0% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
    5. add-sqr-sqrt26.8%

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

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

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
    9. add-sqr-sqrt17.1%

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

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

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

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

      \[\leadsto -\color{blue}{x.re \cdot \left(x.im \cdot x.im\right)} \]
    14. distribute-lft-neg-out32.5%

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

      \[\leadsto \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-x.re\right)} \]
    16. add-sqr-sqrt17.9%

      \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)} \]
    17. sqrt-unprod28.1%

      \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \]
    18. sqr-neg28.1%

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

      \[\leadsto \left(x.im \cdot x.im\right) \cdot \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \]
    20. add-sqr-sqrt24.5%

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

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

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

Alternative 9: 23.0% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(-x.re\right) \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im} \]
    5. add-sqr-sqrt26.8%

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

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

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

      \[\leadsto \left(\color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot x.im \]
    9. add-sqr-sqrt17.1%

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

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

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

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

      \[\leadsto -\color{blue}{x.re \cdot \left(x.im \cdot x.im\right)} \]
    14. distribute-lft-neg-out32.5%

      \[\leadsto \color{blue}{\left(-x.re\right) \cdot \left(x.im \cdot x.im\right)} \]
    15. add-sqr-sqrt17.9%

      \[\leadsto \color{blue}{\left(\sqrt{-x.re} \cdot \sqrt{-x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
    16. sqrt-unprod28.1%

      \[\leadsto \color{blue}{\sqrt{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot \left(x.im \cdot x.im\right) \]
    17. sqr-neg28.1%

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

      \[\leadsto \color{blue}{\left(\sqrt{x.re} \cdot \sqrt{x.re}\right)} \cdot \left(x.im \cdot x.im\right) \]
    19. add-sqr-sqrt24.5%

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

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

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

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

Developer target: 87.4% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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