math.cube on complex, imaginary part

Percentage Accurate: 82.1% → 99.7%
Time: 9.0s
Alternatives: 14
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) + \frac{0.5}{x.im}\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (<=
      (+
       (* x.im (- (* x.re x.re) (* x.im x.im)))
       (* x.re (+ (* x.re x.im) (* x.re x.im))))
      INFINITY)
   (fma (+ x.re x.im) (* x.im (- x.re x.im)) (* x.re (* x.re (+ x.im x.im))))
   (+ (* x.im (* (+ x.re x.im) (- x.re x.im))) (/ 0.5 x.im))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
		tmp = fma((x_46_re + x_46_im), (x_46_im * (x_46_re - x_46_im)), (x_46_re * (x_46_re * (x_46_im + x_46_im))));
	} else {
		tmp = (x_46_im * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) + (0.5 / x_46_im);
	}
	return tmp;
}
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf)
		tmp = fma(Float64(x_46_re + x_46_im), Float64(x_46_im * Float64(x_46_re - x_46_im)), Float64(x_46_re * Float64(x_46_re * Float64(x_46_im + x_46_im))));
	else
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re - x_46_im))) + Float64(0.5 / x_46_im));
	end
	return tmp
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 / x$46$im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\

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


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

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.re + x.im, x.im \cdot \left(x.re - x.im\right), x.re \cdot \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right)\right) \]
      9. distribute-lft-out99.9%

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.3% accurate, 0.1× speedup?

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

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


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

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.4% accurate, 0.1× speedup?

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

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


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

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.1% accurate, 0.7× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \begin{array}{l} \mathbf{if}\;x.im \leq -1.4 \cdot 10^{+57} \lor \neg \left(x.im \leq 1.1 \cdot 10^{+34}\right):\\ \;\;\;\;x.im \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) + \frac{0.5}{x.im}\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.re \cdot \frac{x.re}{\frac{1}{x.im}} - x.im \cdot \frac{x.im}{\frac{1}{x.im}}\right)\\ \end{array} \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im)
 :precision binary64
 (if (or (<= x.im -1.4e+57) (not (<= x.im 1.1e+34)))
   (+ (* x.im (* (+ x.re x.im) (- x.re x.im))) (/ 0.5 x.im))
   (+
    (* x.re (+ (* x.re x.im) (* x.re x.im)))
    (- (* x.re (/ x.re (/ 1.0 x.im))) (* x.im (/ x.im (/ 1.0 x.im)))))))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -1.4e+57) || !(x_46_im <= 1.1e+34)) {
		tmp = (x_46_im * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) + (0.5 / x_46_im);
	} else {
		tmp = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + ((x_46_re * (x_46_re / (1.0 / x_46_im))) - (x_46_im * (x_46_im / (1.0 / x_46_im))));
	}
	return tmp;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8) :: tmp
    if ((x_46im <= (-1.4d+57)) .or. (.not. (x_46im <= 1.1d+34))) then
        tmp = (x_46im * ((x_46re + x_46im) * (x_46re - x_46im))) + (0.5d0 / x_46im)
    else
        tmp = (x_46re * ((x_46re * x_46im) + (x_46re * x_46im))) + ((x_46re * (x_46re / (1.0d0 / x_46im))) - (x_46im * (x_46im / (1.0d0 / x_46im))))
    end if
    code = tmp
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	double tmp;
	if ((x_46_im <= -1.4e+57) || !(x_46_im <= 1.1e+34)) {
		tmp = (x_46_im * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) + (0.5 / x_46_im);
	} else {
		tmp = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + ((x_46_re * (x_46_re / (1.0 / x_46_im))) - (x_46_im * (x_46_im / (1.0 / x_46_im))));
	}
	return tmp;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	tmp = 0
	if (x_46_im <= -1.4e+57) or not (x_46_im <= 1.1e+34):
		tmp = (x_46_im * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) + (0.5 / x_46_im)
	else:
		tmp = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + ((x_46_re * (x_46_re / (1.0 / x_46_im))) - (x_46_im * (x_46_im / (1.0 / x_46_im))))
	return tmp
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	tmp = 0.0
	if ((x_46_im <= -1.4e+57) || !(x_46_im <= 1.1e+34))
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re - x_46_im))) + Float64(0.5 / x_46_im));
	else
		tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))) + Float64(Float64(x_46_re * Float64(x_46_re / Float64(1.0 / x_46_im))) - Float64(x_46_im * Float64(x_46_im / Float64(1.0 / x_46_im)))));
	end
	return tmp
end
x.re = abs(x.re)
function tmp_2 = code(x_46_re, x_46_im)
	tmp = 0.0;
	if ((x_46_im <= -1.4e+57) || ~((x_46_im <= 1.1e+34)))
		tmp = (x_46_im * ((x_46_re + x_46_im) * (x_46_re - x_46_im))) + (0.5 / x_46_im);
	else
		tmp = (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im))) + ((x_46_re * (x_46_re / (1.0 / x_46_im))) - (x_46_im * (x_46_im / (1.0 / x_46_im))));
	end
	tmp_2 = tmp;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -1.4e+57], N[Not[LessEqual[x$46$im, 1.1e+34]], $MachinePrecision]], N[(N[(x$46$im * N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 / x$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * N[(x$46$re / N[(1.0 / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im / N[(1.0 / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.re = |x.re|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.4 \cdot 10^{+57} \lor \neg \left(x.im \leq 1.1 \cdot 10^{+34}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) + \frac{0.5}{x.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.4e57 or 1.1000000000000001e34 < x.im

    1. Initial program 80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4e57 < x.im < 1.1000000000000001e34

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{x.re}{\frac{1}{x.im}} \cdot x.re - \frac{x.im \cdot x.im}{\frac{x.re + x.im}{\color{blue}{\left(x.re + x.im\right) \cdot x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      7. associate-/r*99.8%

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

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

        \[\leadsto \left(\frac{x.re}{\frac{1}{x.im}} \cdot x.re - \color{blue}{\frac{x.im}{\frac{\frac{1}{x.im}}{x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      10. associate-/r/99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -1.4 \cdot 10^{+57} \lor \neg \left(x.im \leq 1.1 \cdot 10^{+34}\right):\\ \;\;\;\;x.im \cdot \left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right) + \frac{0.5}{x.im}\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.re \cdot \frac{x.re}{\frac{1}{x.im}} - x.im \cdot \frac{x.im}{\frac{1}{x.im}}\right)\\ \end{array} \]

Alternative 5: 97.0% accurate, 1.0× speedup?

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999966e153 < x.re

    1. Initial program 45.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0 + \frac{x.im \cdot \left(x.re + x.im\right)}{1} \cdot \left(x.re + x.im\right)\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    5. Step-by-step derivation
      1. +-lft-identity79.9%

        \[\leadsto \color{blue}{\frac{x.im \cdot \left(x.re + x.im\right)}{1} \cdot \left(x.re + x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
      2. /-rgt-identity79.9%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 93.0% accurate, 1.3× speedup?

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.05e157 < x.re

    1. Initial program 45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{\frac{0.5}{x.im}} \]
    5. Step-by-step derivation
      1. difference-of-squares78.8%

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

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

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

Alternative 7: 93.8% accurate, 1.3× speedup?

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.5000000000000003e153 < x.re

    1. Initial program 45.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 91.1% accurate, 1.5× speedup?

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999966e153 < x.re

    1. Initial program 45.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
    7. Step-by-step derivation
      1. add-log-exp58.8%

        \[\leadsto \color{blue}{\log \left(e^{\left(x.re \cdot x.re\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re}\right)} \]
      2. +-commutative58.8%

        \[\leadsto \log \left(e^{\color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re\right) \cdot x.im}}\right) \]
      3. exp-sum58.8%

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

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

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

Alternative 9: 49.8% accurate, 2.7× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ 3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right) \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* 3.0 (* (* x.re x.re) x.im)))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return 3.0 * ((x_46_re * x_46_re) * x_46_im);
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = 3.0d0 * ((x_46re * x_46re) * x_46im)
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return 3.0 * ((x_46_re * x_46_re) * x_46_im);
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return 3.0 * ((x_46_re * x_46_re) * x_46_im)
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return Float64(3.0 * Float64(Float64(x_46_re * x_46_re) * x_46_im))
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re = |x.re|\\
\\
3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)} \]
  9. Final simplification48.0%

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

Alternative 10: 34.1% accurate, 3.8× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ \left(x.re \cdot x.re\right) \cdot x.im \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* (* x.re x.re) x.im))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return (x_46_re * x_46_re) * x_46_im;
}
NOTE: x.re should be positive before calling this function
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
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return (x_46_re * x_46_re) * x_46_im;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return (x_46_re * x_46_re) * x_46_im
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return Float64(Float64(x_46_re * x_46_re) * x_46_im)
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = (x_46_re * x_46_re) * x_46_im;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]
\begin{array}{l}
x.re = |x.re|\\
\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Derivation
  1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x.im \cdot {x.re}^{2}} \]
  5. Step-by-step derivation
    1. unpow235.2%

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

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

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

Alternative 11: 34.9% accurate, 3.8× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ x.re \cdot \left(x.re \cdot x.im\right) \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.im)))
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_im);
}
NOTE: x.re should be positive before calling this function
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)
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return x_46_re * (x_46_re * x_46_im);
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return x_46_re * (x_46_re * x_46_im)
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return Float64(x_46_re * Float64(x_46_re * x_46_im))
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = x_46_re * (x_46_re * x_46_im);
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.re = |x.re|\\
\\
x.re \cdot \left(x.re \cdot x.im\right)
\end{array}
Derivation
  1. Initial program 87.0%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(x.re \cdot x.re\right)} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re \]
  7. Step-by-step derivation
    1. add-log-exp33.7%

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

      \[\leadsto \log \left(e^{\color{blue}{\left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re + \left(x.re \cdot x.re\right) \cdot x.im}}\right) \]
    3. exp-sum33.7%

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

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

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

Alternative 12: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ -3.25 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 -3.25)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return -3.25;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -3.25d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return -3.25;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return -3.25
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return -3.25
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = -3.25;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := -3.25
\begin{array}{l}
x.re = |x.re|\\
\\
-3.25
\end{array}
Derivation
  1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -3.25 \]

Alternative 13: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ -3 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 -3.0)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return -3.0;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = -3.0d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return -3.0;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return -3.0
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return -3.0
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = -3.0;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := -3.0
\begin{array}{l}
x.re = |x.re|\\
\\
-3
\end{array}
Derivation
  1. Initial program 87.0%

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

    \[\leadsto \color{blue}{-1 \cdot {x.im}^{3}} \]
  3. Simplified2.7%

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

    \[\leadsto -3 \]

Alternative 14: 2.7% accurate, 19.0× speedup?

\[\begin{array}{l} x.re = |x.re|\\ \\ 3.25 \end{array} \]
NOTE: x.re should be positive before calling this function
(FPCore (x.re x.im) :precision binary64 3.25)
x.re = abs(x.re);
double code(double x_46_re, double x_46_im) {
	return 3.25;
}
NOTE: x.re should be positive before calling this function
real(8) function code(x_46re, x_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    code = 3.25d0
end function
x.re = Math.abs(x.re);
public static double code(double x_46_re, double x_46_im) {
	return 3.25;
}
x.re = abs(x.re)
def code(x_46_re, x_46_im):
	return 3.25
x.re = abs(x.re)
function code(x_46_re, x_46_im)
	return 3.25
end
x.re = abs(x.re)
function tmp = code(x_46_re, x_46_im)
	tmp = 3.25;
end
NOTE: x.re should be positive before calling this function
code[x$46$re_, x$46$im_] := 3.25
\begin{array}{l}
x.re = |x.re|\\
\\
3.25
\end{array}
Derivation
  1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(27 \cdot {\left(x.re \cdot \left(x.re \cdot x.im\right)\right)}^{3} - {x.im}^{\color{blue}{9}}\right) \cdot \frac{1}{\left(\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3\right) \cdot \left(\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3\right) + \left({x.im}^{3} \cdot {x.im}^{3} + \left(\left(\left(x.re \cdot x.re\right) \cdot x.im\right) \cdot 3\right) \cdot {x.im}^{3}\right)} \]
    9. associate-+r+13.9%

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

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

    \[\leadsto \color{blue}{3.25} \]
  7. Final simplification2.8%

    \[\leadsto 3.25 \]

Developer target: 91.7% accurate, 1.1× speedup?

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

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

Reproduce

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

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

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