math.cube on complex, real part

Percentage Accurate: 82.2% → 99.8%
Time: 8.9s
Alternatives: 9
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 82.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - t_0 \leq \infty:\\ \;\;\;\;\left(x.re \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right) - t_0\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) - x.im \cdot -3\\ \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 (<= (- (* x.re (- (* x.re x.re) (* x.im x.im))) t_0) INFINITY)
     (- (* (* x.re (- x.re x.im)) (+ x.re x.im)) t_0)
     (- (* x.re (* (- x.re x.im) (+ x.re x.im))) (* x.im -3.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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= ((double) INFINITY)) {
		tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0;
	} else {
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0);
	}
	return tmp;
}
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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= Double.POSITIVE_INFINITY) {
		tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0;
	} else {
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= math.inf:
		tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0
	else:
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.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 (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - t_0) <= Inf)
		tmp = Float64(Float64(Float64(x_46_re * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im)) - t_0);
	else
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) - Float64(x_46_im * -3.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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= Inf)
		tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0;
	else
		tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.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[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], Infinity], N[(N[(N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\left(x.re \cdot x.im - x.im \cdot x.re\right)}{\color{blue}{x.re \cdot x.im} - x.im \cdot x.re} \cdot x.im \]
      8. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\ \mathbf{if}\;x.re \leq -1 \cdot 10^{+119} \lor \neg \left(x.re \leq 10^{+82}\right):\\ \;\;\;\;t_0 - x.im \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0 - x.im \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.re (* (- x.re x.im) (+ x.re x.im)))))
   (if (or (<= x.re -1e+119) (not (<= x.re 1e+82)))
     (- t_0 (* x.im -3.0))
     (- t_0 (* x.im (* (* x.re x.im) 2.0))))))
double code(double x_46_re, double x_46_im) {
	double t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	double tmp;
	if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82)) {
		tmp = t_0 - (x_46_im * -3.0);
	} else {
		tmp = t_0 - (x_46_im * ((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_46re * ((x_46re - x_46im) * (x_46re + x_46im))
    if ((x_46re <= (-1d+119)) .or. (.not. (x_46re <= 1d+82))) then
        tmp = t_0 - (x_46im * (-3.0d0))
    else
        tmp = t_0 - (x_46im * ((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_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	double tmp;
	if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82)) {
		tmp = t_0 - (x_46_im * -3.0);
	} else {
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
	}
	return tmp;
}
def code(x_46_re, x_46_im):
	t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))
	tmp = 0
	if (x_46_re <= -1e+119) or not (x_46_re <= 1e+82):
		tmp = t_0 - (x_46_im * -3.0)
	else:
		tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0))
	return tmp
function code(x_46_re, x_46_im)
	t_0 = Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im)))
	tmp = 0.0
	if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82))
		tmp = Float64(t_0 - Float64(x_46_im * -3.0));
	else
		tmp = Float64(t_0 - Float64(x_46_im * 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_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
	tmp = 0.0;
	if ((x_46_re <= -1e+119) || ~((x_46_re <= 1e+82)))
		tmp = t_0 - (x_46_im * -3.0);
	else
		tmp = t_0 - (x_46_im * ((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$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x$46$re, -1e+119], N[Not[LessEqual[x$46$re, 1e+82]], $MachinePrecision]], N[(t$95$0 - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\
\mathbf{if}\;x.re \leq -1 \cdot 10^{+119} \lor \neg \left(x.re \leq 10^{+82}\right):\\
\;\;\;\;t_0 - x.im \cdot -3\\

\mathbf{else}:\\
\;\;\;\;t_0 - x.im \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.re < -9.99999999999999944e118 or 9.9999999999999996e81 < x.re

    1. Initial program 59.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\left(x.re \cdot x.im - x.im \cdot x.re\right)}{\color{blue}{x.re \cdot x.im} - x.im \cdot x.re} \cdot x.im \]
      8. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999944e118 < x.re < 9.9999999999999996e81

    1. Initial program 88.7%

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

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

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

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

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

        \[\leadsto -27 \cdot \left(x.im \cdot x.re\right) - \left(\color{blue}{1 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) \cdot x.im \]
      3. *-un-lft-identity33.4%

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

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

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

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

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

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

Alternative 3: 72.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.8 \cdot 10^{-96} \lor \neg \left(x.re \leq 5.2 \cdot 10^{-78}\right):\\
\;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) - x.im \cdot -3\\

\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot -27 - x.im \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.re < -1.80000000000000004e-96 or 5.2000000000000002e-78 < x.re

    1. Initial program 77.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\left(x.re \cdot x.im - x.im \cdot x.re\right)}{\color{blue}{x.re \cdot x.im} - x.im \cdot x.re} \cdot x.im \]
      8. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.80000000000000004e-96 < x.re < 5.2000000000000002e-78

    1. Initial program 81.1%

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

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

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

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

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

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

        \[\leadsto -27 \cdot \left(x.im \cdot x.re\right) - \left(\color{blue}{1 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) \cdot x.im \]
      3. *-un-lft-identity43.1%

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

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

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

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

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

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

Alternative 4: 67.4% accurate, 1.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t_0 - x.im \cdot -3\\


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

    1. Initial program 88.4%

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

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

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

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

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

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

    if 6.39999999999999945e30 < x.im

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\left(x.re \cdot x.im - x.im \cdot x.re\right)}{\color{blue}{x.re \cdot x.im} - x.im \cdot x.re} \cdot x.im \]
      8. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 33.8% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 4.1e186

    1. Initial program 81.1%

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

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

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

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

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

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

        \[\leadsto -27 \cdot \left(x.im \cdot x.re\right) - \left(\color{blue}{1 \cdot \left(x.im \cdot x.re\right)} + x.im \cdot x.re\right) \cdot x.im \]
      3. *-un-lft-identity28.7%

        \[\leadsto -27 \cdot \left(x.im \cdot x.re\right) - \left(1 \cdot \left(x.im \cdot x.re\right) + \color{blue}{1 \cdot \left(x.im \cdot x.re\right)}\right) \cdot x.im \]
      4. distribute-rgt-out28.7%

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

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

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

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

    if 4.1e186 < x.re

    1. Initial program 54.2%

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

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

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

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

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

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

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

Alternative 6: 22.3% accurate, 2.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 4.8000000000000001e189

    1. Initial program 81.1%

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

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

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

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

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

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

    if 4.8000000000000001e189 < x.re

    1. Initial program 54.2%

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

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

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

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

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

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

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

Alternative 7: 19.6% accurate, 3.8× speedup?

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

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

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

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

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

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

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

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

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

Alternative 8: 3.6% 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 78.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) \cdot x.re - \frac{-\left(x.re \cdot x.im - x.im \cdot x.re\right)}{\color{blue}{x.re \cdot x.im} - x.im \cdot x.re} \cdot x.im \]
    8. distribute-neg-frac0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{3 \cdot x.im} \]
  10. Simplified3.6%

    \[\leadsto \color{blue}{x.im \cdot 3} \]
  11. Final simplification3.6%

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

Alternative 9: 3.0% 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 78.5%

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

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

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

    \[\leadsto \color{blue}{-x.re} \]
  5. Final simplification3.1%

    \[\leadsto -x.re \]

Developer target: 86.8% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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