math.cube on complex, real part

Percentage Accurate: 82.7% → 99.9%
Time: 7.6s
Alternatives: 9
Speedup: 0.5×

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

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\left(x.im\_m \cdot \left(x.re\_m \cdot x.im\_m\right)\right) \cdot -3 + {x.re\_m}^{3}\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 5.8e+102)
    (+ (* (* x.im_m (* x.re_m x.im_m)) -3.0) (pow x.re_m 3.0))
    (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m -27.0))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 5.8e+102) {
		tmp = ((x_46_im_m * (x_46_re_m * x_46_im_m)) * -3.0) + pow(x_46_re_m, 3.0);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 5.8d+102) then
        tmp = ((x_46im_m * (x_46re_m * x_46im_m)) * (-3.0d0)) + (x_46re_m ** 3.0d0)
    else
        tmp = x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + (-27.0d0)))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 5.8e+102) {
		tmp = ((x_46_im_m * (x_46_re_m * x_46_im_m)) * -3.0) + Math.pow(x_46_re_m, 3.0);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 5.8e+102:
		tmp = ((x_46_im_m * (x_46_re_m * x_46_im_m)) * -3.0) + math.pow(x_46_re_m, 3.0)
	else:
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 5.8e+102)
		tmp = Float64(Float64(Float64(x_46_im_m * Float64(x_46_re_m * x_46_im_m)) * -3.0) + (x_46_re_m ^ 3.0));
	else
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + -27.0)));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 5.8e+102)
		tmp = ((x_46_im_m * (x_46_re_m * x_46_im_m)) * -3.0) + (x_46_re_m ^ 3.0);
	else
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 5.8e+102], N[(N[(N[(x$46$im$95$m * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision] + N[Power[x$46$re$95$m, 3.0], $MachinePrecision]), $MachinePrecision], N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 85.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. Simplified84.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, {x.re}^{3}\right)} \]
    6. Step-by-step derivation
      1. fma-undefine92.0%

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

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

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

    if 5.8000000000000005e102 < x.re

    1. Initial program 69.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares74.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. Applied egg-rr74.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 \]
    5. Simplified69.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 \]
    6. Applied egg-rr92.3%

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

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

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

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

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

Alternative 2: 94.1% accurate, 0.5× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \cdot \left(x.re\_m \cdot x.re\_m - x.im\_m \cdot x.im\_m\right) - x.im\_m \cdot \left(x.re\_m \cdot x.im\_m + x.re\_m \cdot x.im\_m\right) \leq 10^{-261}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + x.im\_m\right)\right) - x.im\_m \cdot \left(x.im\_m \cdot \left(x.re\_m \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot 0 - x.re\_m \cdot \left(\left(x.re\_m + x.im\_m\right) \cdot \left(x.im\_m - x.re\_m\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<=
       (-
        (* x.re_m (- (* x.re_m x.re_m) (* x.im_m x.im_m)))
        (* x.im_m (+ (* x.re_m x.im_m) (* x.re_m x.im_m))))
       1e-261)
    (-
     (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m x.im_m)))
     (* x.im_m (* x.im_m (* x.re_m 2.0))))
    (- (* x.im_m 0.0) (* x.re_m (* (+ x.re_m x.im_m) (- x.im_m x.re_m)))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= 1e-261) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * (x_46_im_m * (x_46_re_m * 2.0)));
	} else {
		tmp = (x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m)));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (((x_46re_m * ((x_46re_m * x_46re_m) - (x_46im_m * x_46im_m))) - (x_46im_m * ((x_46re_m * x_46im_m) + (x_46re_m * x_46im_m)))) <= 1d-261) then
        tmp = (x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + x_46im_m))) - (x_46im_m * (x_46im_m * (x_46re_m * 2.0d0)))
    else
        tmp = (x_46im_m * 0.0d0) - (x_46re_m * ((x_46re_m + x_46im_m) * (x_46im_m - x_46re_m)))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= 1e-261) {
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * (x_46_im_m * (x_46_re_m * 2.0)));
	} else {
		tmp = (x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m)));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if ((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= 1e-261:
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * (x_46_im_m * (x_46_re_m * 2.0)))
	else:
		tmp = (x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m)))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m * x_46_re_m) - Float64(x_46_im_m * x_46_im_m))) - Float64(x_46_im_m * Float64(Float64(x_46_re_m * x_46_im_m) + Float64(x_46_re_m * x_46_im_m)))) <= 1e-261)
		tmp = Float64(Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + x_46_im_m))) - Float64(x_46_im_m * Float64(x_46_im_m * Float64(x_46_re_m * 2.0))));
	else
		tmp = Float64(Float64(x_46_im_m * 0.0) - Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im_m) * Float64(x_46_im_m - x_46_re_m))));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (((x_46_re_m * ((x_46_re_m * x_46_re_m) - (x_46_im_m * x_46_im_m))) - (x_46_im_m * ((x_46_re_m * x_46_im_m) + (x_46_re_m * x_46_im_m)))) <= 1e-261)
		tmp = (x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + x_46_im_m))) - (x_46_im_m * (x_46_im_m * (x_46_re_m * 2.0)));
	else
		tmp = (x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m)));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m * x$46$re$95$m), $MachinePrecision] - N[(x$46$im$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] + N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-261], N[(N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m + x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im$95$m * N[(x$46$im$95$m * N[(x$46$re$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im$95$m * 0.0), $MachinePrecision] - N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im$95$m), $MachinePrecision] * N[(x$46$im$95$m - x$46$re$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 93.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares93.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. Applied egg-rr93.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 \]
    5. Taylor expanded in x.re around 0 93.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 \]
    6. Step-by-step derivation
      1. *-commutative93.9%

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

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

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

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

    if 9.99999999999999984e-262 < (-.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 69.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares72.5%

        \[\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. Applied egg-rr72.5%

      \[\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 \]
    5. Step-by-step derivation
      1. *-commutative72.5%

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

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

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

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

        \[\leadsto \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) \cdot x.re - \left(x.re \cdot x.im + \sqrt{\color{blue}{\left(-1 \cdot x.re\right)} \cdot \left(-x.re\right)} \cdot x.im\right) \cdot x.im \]
      6. mul-1-neg38.6%

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

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

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

        \[\leadsto \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{\left(-x.re\right)} \cdot x.im\right) \cdot x.im \]
      10. cancel-sign-sub-inv55.0%

        \[\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 x.im - x.re \cdot x.im\right)} \cdot x.im \]
      11. +-inverses77.6%

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

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

    \[\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 10^{-261}:\\ \;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) - x.im \cdot \left(x.im \cdot \left(x.re \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot 0 - x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.im - x.re\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 67.0% accurate, 1.2× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 2.6 \cdot 10^{+18}:\\ \;\;\;\;x.im\_m \cdot \left(\left(x.re\_m \cdot x.im\_m\right) \cdot -2 + x.re\_m \cdot -27\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 2.6e+18)
    (* x.im_m (+ (* (* x.re_m x.im_m) -2.0) (* x.re_m -27.0)))
    (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m -27.0))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 2.6e+18) {
		tmp = x_46_im_m * (((x_46_re_m * x_46_im_m) * -2.0) + (x_46_re_m * -27.0));
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 2.6d+18) then
        tmp = x_46im_m * (((x_46re_m * x_46im_m) * (-2.0d0)) + (x_46re_m * (-27.0d0)))
    else
        tmp = x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + (-27.0d0)))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 2.6e+18) {
		tmp = x_46_im_m * (((x_46_re_m * x_46_im_m) * -2.0) + (x_46_re_m * -27.0));
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 2.6e+18:
		tmp = x_46_im_m * (((x_46_re_m * x_46_im_m) * -2.0) + (x_46_re_m * -27.0))
	else:
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 2.6e+18)
		tmp = Float64(x_46_im_m * Float64(Float64(Float64(x_46_re_m * x_46_im_m) * -2.0) + Float64(x_46_re_m * -27.0)));
	else
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + -27.0)));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 2.6e+18)
		tmp = x_46_im_m * (((x_46_re_m * x_46_im_m) * -2.0) + (x_46_re_m * -27.0));
	else
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 2.6e+18], N[(x$46$im$95$m * N[(N[(N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision] * -2.0), $MachinePrecision] + N[(x$46$re$95$m * -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 84.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares85.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. Applied egg-rr85.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 \]
    5. Simplified47.9%

      \[\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 \]
    6. Taylor expanded in x.re around 0 31.0%

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

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

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

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

    if 2.6e18 < x.re

    1. Initial program 76.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares80.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. Applied egg-rr80.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 \]
    5. Simplified71.1%

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

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

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

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

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

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

Alternative 4: 57.6% accurate, 1.4× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 27:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot -27\right)\\ \mathbf{else}:\\ \;\;\;\;x.re\_m \cdot \left(\left(x.re\_m - x.im\_m\right) \cdot \left(x.re\_m + -27\right)\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 27.0)
    (* x.re_m (* x.re_m -27.0))
    (* x.re_m (* (- x.re_m x.im_m) (+ x.re_m -27.0))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 27.0) {
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 27.0d0) then
        tmp = x_46re_m * (x_46re_m * (-27.0d0))
    else
        tmp = x_46re_m * ((x_46re_m - x_46im_m) * (x_46re_m + (-27.0d0)))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 27.0) {
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	} else {
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 27.0:
		tmp = x_46_re_m * (x_46_re_m * -27.0)
	else:
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0))
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 27.0)
		tmp = Float64(x_46_re_m * Float64(x_46_re_m * -27.0));
	else
		tmp = Float64(x_46_re_m * Float64(Float64(x_46_re_m - x_46_im_m) * Float64(x_46_re_m + -27.0)));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 27.0)
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	else
		tmp = x_46_re_m * ((x_46_re_m - x_46_im_m) * (x_46_re_m + -27.0));
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 27.0], N[(x$46$re$95$m * N[(x$46$re$95$m * -27.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re$95$m * N[(N[(x$46$re$95$m - x$46$im$95$m), $MachinePrecision] * N[(x$46$re$95$m + -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \begin{array}{l}
\mathbf{if}\;x.re\_m \leq 27:\\
\;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot -27\right)\\

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


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

    1. Initial program 83.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. 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 \]
    4. 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 \]
    5. Simplified47.7%

      \[\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 \]
    6. Taylor expanded in x.im around 0 31.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right)\right) + \color{blue}{x.re \cdot \left(x.re \cdot \left(x.re + -27\right)\right)} \]
      10. metadata-eval32.8%

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right)\right) + x.re \cdot \left(x.re \cdot \left(x.re + \color{blue}{\left(-27\right)}\right)\right) \]
      11. sub-neg32.8%

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right) + x.re \cdot \color{blue}{\left(x.re + \left(-27\right)\right)}\right) \]
      14. metadata-eval39.8%

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

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

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

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

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

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot -27\right)} \]
    12. Simplified34.6%

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

    if 27 < x.re

    1. Initial program 78.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. Add Preprocessing
    3. 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.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    4. Applied egg-rr82.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 \]
    5. Simplified70.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 \]
    6. Applied egg-rr83.8%

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

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

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

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

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

Alternative 5: 78.5% accurate, 1.5× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(x.im\_m \cdot 0 - x.re\_m \cdot \left(\left(x.re\_m + x.im\_m\right) \cdot \left(x.im\_m - x.re\_m\right)\right)\right) \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (- (* x.im_m 0.0) (* x.re_m (* (+ x.re_m x.im_m) (- x.im_m x.re_m))))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * ((x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m))));
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * ((x_46im_m * 0.0d0) - (x_46re_m * ((x_46re_m + x_46im_m) * (x_46im_m - x_46re_m))))
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * ((x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m))));
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * ((x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m))))
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * Float64(Float64(x_46_im_m * 0.0) - Float64(x_46_re_m * Float64(Float64(x_46_re_m + x_46_im_m) * Float64(x_46_im_m - x_46_re_m)))))
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * ((x_46_im_m * 0.0) - (x_46_re_m * ((x_46_re_m + x_46_im_m) * (x_46_im_m - x_46_re_m))));
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * N[(N[(x$46$im$95$m * 0.0), $MachinePrecision] - N[(x$46$re$95$m * N[(N[(x$46$re$95$m + x$46$im$95$m), $MachinePrecision] * N[(x$46$im$95$m - x$46$re$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(x.im\_m \cdot 0 - x.re\_m \cdot \left(\left(x.re\_m + x.im\_m\right) \cdot \left(x.im\_m - x.re\_m\right)\right)\right)
\end{array}
Derivation
  1. Initial program 82.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. Add Preprocessing
  3. Step-by-step derivation
    1. difference-of-squares84.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. Applied egg-rr84.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 \]
  5. Step-by-step derivation
    1. *-commutative84.3%

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

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

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

      \[\leadsto \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) \cdot x.re - \left(x.re \cdot x.im + \sqrt{\color{blue}{\left(-x.re\right) \cdot \left(-x.re\right)}} \cdot x.im\right) \cdot x.im \]
    5. mul-1-neg67.0%

      \[\leadsto \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) \cdot x.re - \left(x.re \cdot x.im + \sqrt{\color{blue}{\left(-1 \cdot x.re\right)} \cdot \left(-x.re\right)} \cdot x.im\right) \cdot x.im \]
    6. mul-1-neg67.0%

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

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

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

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

      \[\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 x.im - x.re \cdot x.im\right)} \cdot x.im \]
    11. +-inverses78.7%

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

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

    \[\leadsto x.im \cdot 0 - x.re \cdot \left(\left(x.re + x.im\right) \cdot \left(x.im - x.re\right)\right) \]
  8. Add Preprocessing

Alternative 6: 40.8% accurate, 1.6× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.im\_m \leq 3.3 \cdot 10^{+238}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot \left(x.re\_m - 27\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot -27\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.im_m 3.3e+238)
    (* x.im_m (* x.re_m (- x.re_m 27.0)))
    (* x.im_m (* x.re_m -27.0)))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_im_m <= 3.3e+238) {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m - 27.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46im_m <= 3.3d+238) then
        tmp = x_46im_m * (x_46re_m * (x_46re_m - 27.0d0))
    else
        tmp = x_46im_m * (x_46re_m * (-27.0d0))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_im_m <= 3.3e+238) {
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m - 27.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_im_m <= 3.3e+238:
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m - 27.0))
	else:
		tmp = x_46_im_m * (x_46_re_m * -27.0)
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_im_m <= 3.3e+238)
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * Float64(x_46_re_m - 27.0)));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * -27.0));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_im_m <= 3.3e+238)
		tmp = x_46_im_m * (x_46_re_m * (x_46_re_m - 27.0));
	else
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$im$95$m, 3.3e+238], N[(x$46$im$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * -27.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 83.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares84.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. Applied egg-rr84.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 \]
    5. Simplified52.7%

      \[\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 \]
    6. Taylor expanded in x.im around 0 37.6%

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

        \[\leadsto \color{blue}{\left(x.re \cdot \left(x.re - 27\right)\right) \cdot x.im} + {x.re}^{2} \cdot \left(x.re - 27\right) \]
      2. sub-neg37.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right) + x.re \cdot \color{blue}{\left(x.re + \left(-27\right)\right)}\right) \]
      14. metadata-eval49.8%

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

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

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

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

    if 3.3000000000000001e238 < x.im

    1. Initial program 65.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares75.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. Applied egg-rr75.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 \]
    5. Simplified51.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 \]
    6. Taylor expanded in x.im around 0 12.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. pow140.0%

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

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

        \[\leadsto {\color{blue}{\left(x.im \cdot \left(x.re \cdot -27\right)\right)}}^{1} \]
    11. Applied egg-rr40.0%

      \[\leadsto \color{blue}{{\left(x.im \cdot \left(x.re \cdot -27\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow140.0%

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

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

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

Alternative 7: 52.7% accurate, 1.6× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.im\_m \leq 2.4 \cdot 10^{+238}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot \left(x.re\_m - 27\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im\_m \cdot \left(x.re\_m \cdot -27\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.im_m 2.4e+238)
    (* x.re_m (* x.re_m (- x.re_m 27.0)))
    (* x.im_m (* x.re_m -27.0)))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_im_m <= 2.4e+238) {
		tmp = x_46_re_m * (x_46_re_m * (x_46_re_m - 27.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46im_m <= 2.4d+238) then
        tmp = x_46re_m * (x_46re_m * (x_46re_m - 27.0d0))
    else
        tmp = x_46im_m * (x_46re_m * (-27.0d0))
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_im_m <= 2.4e+238) {
		tmp = x_46_re_m * (x_46_re_m * (x_46_re_m - 27.0));
	} else {
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_im_m <= 2.4e+238:
		tmp = x_46_re_m * (x_46_re_m * (x_46_re_m - 27.0))
	else:
		tmp = x_46_im_m * (x_46_re_m * -27.0)
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_im_m <= 2.4e+238)
		tmp = Float64(x_46_re_m * Float64(x_46_re_m * Float64(x_46_re_m - 27.0)));
	else
		tmp = Float64(x_46_im_m * Float64(x_46_re_m * -27.0));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_im_m <= 2.4e+238)
		tmp = x_46_re_m * (x_46_re_m * (x_46_re_m - 27.0));
	else
		tmp = x_46_im_m * (x_46_re_m * -27.0);
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$im$95$m, 2.4e+238], N[(x$46$re$95$m * N[(x$46$re$95$m * N[(x$46$re$95$m - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im$95$m * N[(x$46$re$95$m * -27.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

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

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


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

    1. Initial program 83.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares84.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. Applied egg-rr84.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 \]
    5. Simplified52.7%

      \[\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 \]
    6. Taylor expanded in x.im around 0 37.6%

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

        \[\leadsto \color{blue}{\left(x.re \cdot \left(x.re - 27\right)\right) \cdot x.im} + {x.re}^{2} \cdot \left(x.re - 27\right) \]
      2. sub-neg37.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right) + x.re \cdot \color{blue}{\left(x.re + \left(-27\right)\right)}\right) \]
      14. metadata-eval49.8%

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

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

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

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

    if 2.4e238 < x.im

    1. Initial program 65.9%

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares75.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. Applied egg-rr75.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 \]
    5. Simplified51.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 \]
    6. Taylor expanded in x.im around 0 12.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
    10. Step-by-step derivation
      1. pow140.0%

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

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

        \[\leadsto {\color{blue}{\left(x.im \cdot \left(x.re \cdot -27\right)\right)}}^{1} \]
    11. Applied egg-rr40.0%

      \[\leadsto \color{blue}{{\left(x.im \cdot \left(x.re \cdot -27\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow140.0%

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

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

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

Alternative 8: 21.4% accurate, 1.9× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \begin{array}{l} \mathbf{if}\;x.re\_m \leq 9.5 \cdot 10^{-167}:\\ \;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot -27\right)\\ \mathbf{else}:\\ \;\;\;\;-27 \cdot \left(x.re\_m \cdot x.im\_m\right)\\ \end{array} \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (*
  x.re_s
  (if (<= x.re_m 9.5e-167)
    (* x.re_m (* x.re_m -27.0))
    (* -27.0 (* x.re_m x.im_m)))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 9.5e-167) {
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	} else {
		tmp = -27.0 * (x_46_re_m * x_46_im_m);
	}
	return x_46_re_s * tmp;
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    real(8) :: tmp
    if (x_46re_m <= 9.5d-167) then
        tmp = x_46re_m * (x_46re_m * (-27.0d0))
    else
        tmp = (-27.0d0) * (x_46re_m * x_46im_m)
    end if
    code = x_46re_s * tmp
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	double tmp;
	if (x_46_re_m <= 9.5e-167) {
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	} else {
		tmp = -27.0 * (x_46_re_m * x_46_im_m);
	}
	return x_46_re_s * tmp;
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	tmp = 0
	if x_46_re_m <= 9.5e-167:
		tmp = x_46_re_m * (x_46_re_m * -27.0)
	else:
		tmp = -27.0 * (x_46_re_m * x_46_im_m)
	return x_46_re_s * tmp
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0
	if (x_46_re_m <= 9.5e-167)
		tmp = Float64(x_46_re_m * Float64(x_46_re_m * -27.0));
	else
		tmp = Float64(-27.0 * Float64(x_46_re_m * x_46_im_m));
	end
	return Float64(x_46_re_s * tmp)
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp_2 = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = 0.0;
	if (x_46_re_m <= 9.5e-167)
		tmp = x_46_re_m * (x_46_re_m * -27.0);
	else
		tmp = -27.0 * (x_46_re_m * x_46_im_m);
	end
	tmp_2 = x_46_re_s * tmp;
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * If[LessEqual[x$46$re$95$m, 9.5e-167], N[(x$46$re$95$m * N[(x$46$re$95$m * -27.0), $MachinePrecision]), $MachinePrecision], N[(-27.0 * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \begin{array}{l}
\mathbf{if}\;x.re\_m \leq 9.5 \cdot 10^{-167}:\\
\;\;\;\;x.re\_m \cdot \left(x.re\_m \cdot -27\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 9.49999999999999955e-167

    1. Initial program 82.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares83.8%

        \[\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. Applied egg-rr83.8%

      \[\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 \]
    5. Simplified53.1%

      \[\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 \]
    6. Taylor expanded in x.im around 0 38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.re \cdot \color{blue}{\left(-27 \cdot x.re\right)} \]
    11. Step-by-step derivation
      1. *-commutative42.5%

        \[\leadsto x.re \cdot \color{blue}{\left(x.re \cdot -27\right)} \]
    12. Simplified42.5%

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

    if 9.49999999999999955e-167 < x.re

    1. Initial program 83.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. Add Preprocessing
    3. Step-by-step derivation
      1. difference-of-squares85.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. Applied egg-rr85.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 \]
    5. Simplified51.7%

      \[\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 \]
    6. Taylor expanded in x.im around 0 33.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right)\right) + x.re \cdot \left(x.re \cdot \left(x.re + \color{blue}{\left(-27\right)}\right)\right) \]
      11. sub-neg40.6%

        \[\leadsto x.re \cdot \left(x.im \cdot \left(x.re + -27\right)\right) + x.re \cdot \left(x.re \cdot \color{blue}{\left(x.re - 27\right)}\right) \]
      12. distribute-lft-in46.6%

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

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

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

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

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

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

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

Alternative 9: 20.5% accurate, 3.8× speedup?

\[\begin{array}{l} x.im_m = \left|x.im\right| \\ x.re\_m = \left|x.re\right| \\ x.re\_s = \mathsf{copysign}\left(1, x.re\right) \\ x.re\_s \cdot \left(-27 \cdot \left(x.re\_m \cdot x.im\_m\right)\right) \end{array} \]
x.im_m = (fabs.f64 x.im)
x.re\_m = (fabs.f64 x.re)
x.re\_s = (copysign.f64 #s(literal 1 binary64) x.re)
(FPCore (x.re_s x.re_m x.im_m)
 :precision binary64
 (* x.re_s (* -27.0 (* x.re_m x.im_m))))
x.im_m = fabs(x_46_im);
x.re\_m = fabs(x_46_re);
x.re\_s = copysign(1.0, x_46_re);
double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * (-27.0 * (x_46_re_m * x_46_im_m));
}
x.im_m = abs(x_46im)
x.re\_m = abs(x_46re)
x.re\_s = copysign(1.0d0, x_46re)
real(8) function code(x_46re_s, x_46re_m, x_46im_m)
    real(8), intent (in) :: x_46re_s
    real(8), intent (in) :: x_46re_m
    real(8), intent (in) :: x_46im_m
    code = x_46re_s * ((-27.0d0) * (x_46re_m * x_46im_m))
end function
x.im_m = Math.abs(x_46_im);
x.re\_m = Math.abs(x_46_re);
x.re\_s = Math.copySign(1.0, x_46_re);
public static double code(double x_46_re_s, double x_46_re_m, double x_46_im_m) {
	return x_46_re_s * (-27.0 * (x_46_re_m * x_46_im_m));
}
x.im_m = math.fabs(x_46_im)
x.re\_m = math.fabs(x_46_re)
x.re\_s = math.copysign(1.0, x_46_re)
def code(x_46_re_s, x_46_re_m, x_46_im_m):
	return x_46_re_s * (-27.0 * (x_46_re_m * x_46_im_m))
x.im_m = abs(x_46_im)
x.re\_m = abs(x_46_re)
x.re\_s = copysign(1.0, x_46_re)
function code(x_46_re_s, x_46_re_m, x_46_im_m)
	return Float64(x_46_re_s * Float64(-27.0 * Float64(x_46_re_m * x_46_im_m)))
end
x.im_m = abs(x_46_im);
x.re\_m = abs(x_46_re);
x.re\_s = sign(x_46_re) * abs(1.0);
function tmp = code(x_46_re_s, x_46_re_m, x_46_im_m)
	tmp = x_46_re_s * (-27.0 * (x_46_re_m * x_46_im_m));
end
x.im_m = N[Abs[x$46$im], $MachinePrecision]
x.re\_m = N[Abs[x$46$re], $MachinePrecision]
x.re\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$46$re$95$s_, x$46$re$95$m_, x$46$im$95$m_] := N[(x$46$re$95$s * N[(-27.0 * N[(x$46$re$95$m * x$46$im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im_m = \left|x.im\right|
\\
x.re\_m = \left|x.re\right|
\\
x.re\_s = \mathsf{copysign}\left(1, x.re\right)

\\
x.re\_s \cdot \left(-27 \cdot \left(x.re\_m \cdot x.im\_m\right)\right)
\end{array}
Derivation
  1. Initial program 82.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. Add Preprocessing
  3. Step-by-step derivation
    1. difference-of-squares84.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. Applied egg-rr84.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 \]
  5. Simplified52.6%

    \[\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 \]
  6. Taylor expanded in x.im around 0 36.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-27 \cdot \left(x.im \cdot x.re\right)} \]
  10. Final simplification19.0%

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

Developer target: 99.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 2024078 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :alt
  (+ (* (* 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)))