math.cube on complex, imaginary part

Percentage Accurate: 82.2% → 99.2%
Time: 9.8s
Alternatives: 8
Speedup: 0.9×

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 8 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.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -2.8 \cdot 10^{+122} \lor \neg \left(x.im \leq 2 \cdot 10^{+84}\right):\\ \;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im \cdot 3\right)\right) - {x.im}^{3}\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -2.8e+122) (not (<= x.im 2e+84)))
   (* x.im (* (- x.re x.im) (+ x.re x.im)))
   (- (* x.re (* x.re (* x.im 3.0))) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -2.8e+122) || !(x_46_im <= 2e+84)) {
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	} else {
		tmp = (x_46_re * (x_46_re * (x_46_im * 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 <= (-2.8d+122)) .or. (.not. (x_46im <= 2d+84))) then
        tmp = x_46im * ((x_46re - x_46im) * (x_46re + x_46im))
    else
        tmp = (x_46re * (x_46re * (x_46im * 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 <= -2.8e+122) || !(x_46_im <= 2e+84)) {
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	} else {
		tmp = (x_46_re * (x_46_re * (x_46_im * 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 <= -2.8e+122) or not (x_46_im <= 2e+84):
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_re + x_46_im))
	else:
		tmp = (x_46_re * (x_46_re * (x_46_im * 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 <= -2.8e+122) || !(x_46_im <= 2e+84))
		tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im)));
	else
		tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im * 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 <= -2.8e+122) || ~((x_46_im <= 2e+84)))
		tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	else
		tmp = (x_46_re * (x_46_re * (x_46_im * 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, -2.8e+122], N[Not[LessEqual[x$46$im, 2e+84]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.8 \cdot 10^{+122} \lor \neg \left(x.im \leq 2 \cdot 10^{+84}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.8e122 or 2.00000000000000012e84 < x.im

    1. Initial program 56.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. difference-of-squares70.8%

        \[\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 \]
      2. *-commutative70.8%

        \[\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 \]
    3. Applied egg-rr70.8%

      \[\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 \]
    4. Step-by-step derivation
      1. expm1-log1p-u44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      2. expm1-udef44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)} - 1\right)} \]
      3. *-commutative44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.re\right)} - 1\right) \]
      4. *-commutative44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      5. *-un-lft-identity44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
      6. *-un-lft-identity44.9%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      7. flip-+0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
      8. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
      9. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    6. Simplified98.9%

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

    if -2.8e122 < x.im < 2.00000000000000012e84

    1. Initial program 88.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. +-commutative88.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. *-commutative88.0%

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

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

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

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

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

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

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

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

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

Alternative 2: 97.4% accurate, 0.1× speedup?

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

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

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

    1. Initial program 90.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. +-commutative90.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. *-commutative90.7%

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

        \[\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 \]
      2. *-commutative33.3%

        \[\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 \]
    3. Applied egg-rr33.3%

      \[\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 \]
    4. Step-by-step derivation
      1. expm1-log1p-u10.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      2. expm1-udef10.3%

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      5. *-un-lft-identity10.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
      6. *-un-lft-identity10.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      7. flip-+0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
      8. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
      9. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    6. Simplified97.4%

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

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

Alternative 3: 93.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t_0 \leq 10^{+235}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im)
 :precision binary64
 (let* ((t_0
         (+
          (* x.im (- (* x.re x.re) (* x.im x.im)))
          (* x.re (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_0 1e+235) t_0 (* 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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 1e+235) {
		tmp = t_0;
	} else {
		tmp = 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_46im * ((x_46re * x_46re) - (x_46im * x_46im))) + (x_46re * ((x_46re * x_46im) + (x_46re * x_46im)))
    if (t_0 <= 1d+235) then
        tmp = t_0
    else
        tmp = 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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_0 <= 1e+235) {
		tmp = t_0;
	} else {
		tmp = 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_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	tmp = 0
	if t_0 <= 1e+235:
		tmp = t_0
	else:
		tmp = 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(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_0 <= 1e+235)
		tmp = t_0;
	else
		tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im)
	t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	tmp = 0.0;
	if (t_0 <= 1e+235)
		tmp = t_0;
	else
		tmp = 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[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+235], t$95$0, N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \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)) < 1.0000000000000001e235

    1. Initial program 93.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 \]

    if 1.0000000000000001e235 < (+.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 44.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. difference-of-squares59.8%

        \[\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 \]
      2. *-commutative59.8%

        \[\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 \]
    3. Applied egg-rr59.8%

      \[\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 \]
    4. Step-by-step derivation
      1. expm1-log1p-u35.4%

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      5. *-un-lft-identity35.4%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
      6. *-un-lft-identity35.4%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      7. flip-+0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
      8. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
      9. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    6. Simplified88.9%

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

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

Alternative 4: 93.5% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -4.60000000000000015e166 or 2e80 < x.im

    1. Initial program 53.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-squares67.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 \]
      2. *-commutative67.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 \]
    3. Applied egg-rr67.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 \]
    4. Step-by-step derivation
      1. expm1-log1p-u49.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
      2. expm1-udef49.3%

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      5. *-un-lft-identity49.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
      6. *-un-lft-identity49.3%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
      7. flip-+0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
      8. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
      9. +-inverses0.0%

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
    5. Applied egg-rr0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
    6. Simplified98.7%

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

    if -4.60000000000000015e166 < x.im < 2e80

    1. Initial program 87.5%

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

        \[\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 \]
      2. *-commutative88.6%

        \[\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 \]
    3. Applied egg-rr88.6%

      \[\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 \]
    4. Step-by-step derivation
      1. *-commutative88.6%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 34.0% accurate, 2.1× speedup?

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

\\
x.im \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re + x.im\right)\right)
\end{array}
Derivation
  1. Initial program 76.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. Step-by-step derivation
    1. difference-of-squares82.0%

      \[\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 \]
    2. *-commutative82.0%

      \[\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 \]
  3. Applied egg-rr82.0%

    \[\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 \]
  4. Step-by-step derivation
    1. expm1-log1p-u65.5%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
    2. expm1-udef58.1%

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

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
    5. *-un-lft-identity58.1%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
    6. *-un-lft-identity58.1%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
    7. flip-+0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
    8. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
    9. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
  5. Applied egg-rr0.0%

    \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
  6. Simplified79.6%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.3% accurate, 2.1× speedup?

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

\\
x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)
\end{array}
Derivation
  1. Initial program 76.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. Step-by-step derivation
    1. difference-of-squares82.0%

      \[\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 \]
    2. *-commutative82.0%

      \[\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 \]
  3. Applied egg-rr82.0%

    \[\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 \]
  4. Step-by-step derivation
    1. expm1-log1p-u65.5%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\right)\right)} \]
    2. expm1-udef58.1%

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

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(\color{blue}{x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
    5. *-un-lft-identity58.1%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(1 \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\right)}\right)} - 1\right) \]
    6. *-un-lft-identity58.1%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \color{blue}{\left(x.re \cdot x.im + x.re \cdot x.im\right)}\right)} - 1\right) \]
    7. flip-+0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(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}}\right)} - 1\right) \]
    8. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{\color{blue}{0}}{x.re \cdot x.im - x.re \cdot x.im}\right)} - 1\right) \]
    9. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{\color{blue}{0}}\right)} - 1\right) \]
  5. Applied egg-rr0.0%

    \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \color{blue}{\left(e^{\mathsf{log1p}\left(x.re \cdot \frac{0}{0}\right)} - 1\right)} \]
  6. Simplified79.6%

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

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

Alternative 7: 3.5% accurate, 9.5× speedup?

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

\\
-x.re
\end{array}
Derivation
  1. Initial program 76.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. Step-by-step derivation
    1. difference-of-squares82.0%

      \[\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 \]
    2. *-commutative82.0%

      \[\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 \]
  3. Applied egg-rr82.0%

    \[\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 \]
  4. Step-by-step derivation
    1. *-commutative82.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\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}} \cdot x.re \]
    3. +-inverses0.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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)}{\color{blue}{\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)}} \cdot x.re \]
    5. div-sub0.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{\color{blue}{{\left(x.re \cdot x.im\right)}^{2}}}{\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)} - \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) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.re \]
    7. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{{\left(x.re \cdot x.im\right)}^{2}}{\color{blue}{0}} - \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) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.re \]
    8. pow20.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{{\left(x.re \cdot x.im\right)}^{2}}{0} - \frac{\color{blue}{{\left(x.re \cdot x.im\right)}^{2}}}{\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)}\right) \cdot x.re \]
    9. +-inverses0.0%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot x.re} \]
  8. Step-by-step derivation
    1. mul-1-neg3.7%

      \[\leadsto \color{blue}{-x.re} \]
  9. Simplified3.7%

    \[\leadsto \color{blue}{-x.re} \]
  10. Final simplification3.7%

    \[\leadsto -x.re \]

Alternative 8: 3.6% accurate, 19.0× speedup?

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

\\
x.re
\end{array}
Derivation
  1. Initial program 76.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. Step-by-step derivation
    1. difference-of-squares82.0%

      \[\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 \]
    2. *-commutative82.0%

      \[\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 \]
  3. Applied egg-rr82.0%

    \[\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 \]
  4. Step-by-step derivation
    1. *-commutative82.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\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}} \cdot x.re \]
    3. +-inverses0.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \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)}{\color{blue}{\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)}} \cdot x.re \]
    5. div-sub0.0%

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{\color{blue}{{\left(x.re \cdot x.im\right)}^{2}}}{\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)} - \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) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.re \]
    7. +-inverses0.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{{\left(x.re \cdot x.im\right)}^{2}}{\color{blue}{0}} - \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) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)}\right) \cdot x.re \]
    8. pow20.0%

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.im + \left(\frac{{\left(x.re \cdot x.im\right)}^{2}}{0} - \frac{\color{blue}{{\left(x.re \cdot x.im\right)}^{2}}}{\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)}\right) \cdot x.re \]
    9. +-inverses0.0%

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

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

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

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

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

      \[\leadsto \left(x.re - x.im\right) \cdot \left(\left(x.re + x.im\right) \cdot x.im\right) + \color{blue}{\sqrt{\left(-1 \cdot x.re\right) \cdot \left(-1 \cdot x.re\right)}} \]
    4. swap-sqr58.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, \left(x.re + x.im\right) \cdot x.im, x.re\right)} \]
  8. Applied egg-rr42.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.re - x.im, x.im \cdot \left(x.im - x.re\right), x.re\right)} \]
  9. Taylor expanded in x.im around 0 3.7%

    \[\leadsto \color{blue}{x.re} \]
  10. Final simplification3.7%

    \[\leadsto x.re \]

Developer target: 91.2% 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 2023305 
(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)))