math.cube on complex, imaginary part

Percentage Accurate: 82.2% → 99.7%
Time: 7.0s
Alternatives: 13
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5e102 or 1e71 < x.im

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e102 < x.im < 1e71

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -5e102 or 1e71 < x.im

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e102 < x.im < 1e71

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.3% accurate, 0.5× speedup?

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

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

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

    1. Initial program 96.1%

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

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

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

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

    if 5.0000000000000001e291 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re))

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.08 \cdot 10^{-70} \lor \neg \left(x.im \leq 5.6 \cdot 10^{-41}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right) + \left(x.re + x.re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.0800000000000001e-70 or 5.6000000000000003e-41 < x.im

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0800000000000001e-70 < x.im < 5.6000000000000003e-41

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 86.7% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -6.6000000000000003e-71 or 2.1500000000000001e-42 < x.im

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.6000000000000003e-71 < x.im < 2.1500000000000001e-42

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

Alternative 6: 60.0% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -5.4 \cdot 10^{+168}:\\ \;\;\;\;x.im \cdot \frac{x.im}{0.1111111111111111} + -3\\ \mathbf{elif}\;x.im \leq 1.45 \cdot 10^{+165}:\\ \;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re + x.re\right) + -3\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (<= x.im -5.4e+168)
   (+ (* x.im (/ x.im 0.1111111111111111)) -3.0)
   (if (<= x.im 1.45e+165)
     (* (* x.re x.re) (* x.im 3.0))
     (* x.im (+ (+ x.re x.re) -3.0)))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -5.4e+168) {
		tmp = (x_46_im * (x_46_im / 0.1111111111111111)) + -3.0;
	} else if (x_46_im <= 1.45e+165) {
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	} else {
		tmp = x_46_im * ((x_46_re + x_46_re) + -3.0);
	}
	return tmp;
}
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if (x_46im <= (-5.4d+168)) then
        tmp = (x_46im * (x_46im / 0.1111111111111111d0)) + (-3.0d0)
    else if (x_46im <= 1.45d+165) then
        tmp = (x_46re * x_46re) * (x_46im * 3.0d0)
    else
        tmp = x_46im * ((x_46re + x_46re) + (-3.0d0))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if (x_46_im <= -5.4e+168) {
		tmp = (x_46_im * (x_46_im / 0.1111111111111111)) + -3.0;
	} else if (x_46_im <= 1.45e+165) {
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	} else {
		tmp = x_46_im * ((x_46_re + x_46_re) + -3.0);
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	tmp = 0
	if x_46_im <= -5.4e+168:
		tmp = (x_46_im * (x_46_im / 0.1111111111111111)) + -3.0
	elif x_46_im <= 1.45e+165:
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0)
	else:
		tmp = x_46_im * ((x_46_re + x_46_re) + -3.0)
	return tmp
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (x_46_im <= -5.4e+168)
		tmp = Float64(Float64(x_46_im * Float64(x_46_im / 0.1111111111111111)) + -3.0);
	elseif (x_46_im <= 1.45e+165)
		tmp = Float64(Float64(x_46_re * x_46_re) * Float64(x_46_im * 3.0));
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re + x_46_re) + -3.0));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if (x_46_im <= -5.4e+168)
		tmp = (x_46_im * (x_46_im / 0.1111111111111111)) + -3.0;
	elseif (x_46_im <= 1.45e+165)
		tmp = (x_46_re * x_46_re) * (x_46_im * 3.0);
	else
		tmp = x_46_im * ((x_46_re + x_46_re) + -3.0);
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -5.4e+168], N[(N[(x$46$im * N[(x$46$im / 0.1111111111111111), $MachinePrecision]), $MachinePrecision] + -3.0), $MachinePrecision], If[LessEqual[x$46$im, 1.45e+165], N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re + x$46$re), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -5.4 \cdot 10^{+168}:\\
\;\;\;\;x.im \cdot \frac{x.im}{0.1111111111111111} + -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -5.40000000000000031e168

    1. Initial program 67.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{x.im \cdot x.im}{0.1111111111111111} + -3} \]
    6. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{x.im}{\frac{0.1111111111111111}{x.im}}} + -3 \]
      2. associate-/r/100.0%

        \[\leadsto \color{blue}{\frac{x.im}{0.1111111111111111} \cdot x.im} + -3 \]
    7. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x.im}{0.1111111111111111} \cdot x.im} + -3 \]

    if -5.40000000000000031e168 < x.im < 1.45000000000000003e165

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

    if 1.45000000000000003e165 < x.im

    1. Initial program 58.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 51.1% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 2.3 \cdot 10^{+166}:\\
\;\;\;\;3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)\\

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


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

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.30000000000000008e166 < x.im

    1. Initial program 58.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 51.1% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 5.8 \cdot 10^{+165}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot \left(x.im \cdot 3\right)\\

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


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

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

    if 5.80000000000000011e165 < x.im

    1. Initial program 58.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 49.7% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 34.4% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x.re}^{2} \cdot x.im} \]
  7. Simplified33.5%

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

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

Alternative 11: 4.5% accurate, 6.3× speedup?

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

\\
x.im \cdot -3
\end{array}
Derivation
  1. Initial program 85.3%

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

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

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

    \[\leadsto \color{blue}{-3 \cdot x.im} \]
  5. Final simplification4.4%

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

Alternative 12: 2.7% accurate, 19.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -3 \]

Alternative 13: 2.7% accurate, 19.0× speedup?

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

\\
0.1
\end{array}
Derivation
  1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.1 \]

Developer target: 91.1% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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