math.cube on complex, imaginary part

Percentage Accurate: 82.7% → 96.7%
Time: 6.2s
Alternatives: 8
Speedup: 1.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 82.7% 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: 96.7% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;x.re \leq 1.7 \cdot 10^{+151}:\\
\;\;\;\;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(\left(x.re \cdot x.im\right) \cdot 3\right)\\


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

    1. Initial program 57.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 57.0%

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u17.9%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr17.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def17.9%

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

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

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

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

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

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

        \[\leadsto x.im \cdot \left(\left(\color{blue}{2 \cdot {x.re}^{2}} + {x.re}^{2}\right) - x.im \cdot x.im\right) \]
      8. distribute-lft1-in57.0%

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

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

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

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

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

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

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

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

    if -8e153 < x.re < 1.7e151

    1. Initial program 92.3%

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

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u67.9%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr50.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def72.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1.7e151 < x.re

    1. Initial program 49.4%

      \[\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 49.4%

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u16.9%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr16.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def16.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -8 \cdot 10^{+153}:\\ \;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.re \leq 1.7 \cdot 10^{+151}:\\ \;\;\;\;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(\left(x.re \cdot x.im\right) \cdot 3\right)\\ \end{array} \]

Alternative 2: 96.5% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.im \cdot \left(x.re \cdot 2\right), x.re, \left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)\right)\\

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


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

    1. Initial program 92.4%

      \[\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 92.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 2\right), x.re, \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)}\right) \]
      6. difference-of-squares92.5%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x.im \cdot \left(x.re \cdot 2\right), x.re, \left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\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. Taylor expanded in x.re around 0 0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)}\right)} - 1 \]
      5. distribute-lft-out31.0%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def31.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(-1 \cdot {x.im}^{2}\right)} \]
    10. Step-by-step derivation
      1. unpow272.4%

        \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
      2. mul-1-neg72.4%

        \[\leadsto x.im \cdot \color{blue}{\left(-x.im \cdot x.im\right)} \]
      3. distribute-rgt-neg-in72.4%

        \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
    11. Simplified72.4%

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

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

Alternative 3: 77.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -8.2 \cdot 10^{+18} \lor \neg \left(x.re \leq 4.2 \cdot 10^{-26}\right):\\
\;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -8.2e18 or 4.20000000000000016e-26 < x.re

    1. Initial program 64.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. Taylor expanded in x.re around inf 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.2e18 < x.re < 4.20000000000000016e-26

    1. Initial program 99.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. Taylor expanded in x.re around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr56.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def76.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(-1 \cdot {x.im}^{2}\right)} \]
    10. Step-by-step derivation
      1. unpow291.1%

        \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
      2. mul-1-neg91.1%

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

        \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
    11. Simplified91.1%

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

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

Alternative 4: 82.8% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -2 \cdot 10^{+30} \lor \neg \left(x.re \leq 4.7 \cdot 10^{-26}\right):\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < -2e30 or 4.69999999999999989e-26 < x.re

    1. Initial program 64.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. Taylor expanded in x.re around 0 64.6%

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

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

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

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

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

      \[\leadsto \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \color{blue}{x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u33.9%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr27.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def40.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e30 < x.re < 4.69999999999999989e-26

    1. Initial program 99.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. Taylor expanded in x.re around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr56.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def76.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(-1 \cdot {x.im}^{2}\right)} \]
    10. Step-by-step derivation
      1. unpow291.1%

        \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
      2. mul-1-neg91.1%

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

        \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
    11. Simplified91.1%

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

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

Alternative 5: 82.9% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;x.re \leq 1.9 \cdot 10^{-27}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


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

    1. Initial program 65.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. Taylor expanded in x.re around 0 65.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr24.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.85e18 < x.re < 1.9e-27

    1. Initial program 99.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. Taylor expanded in x.re around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr56.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def76.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(-1 \cdot {x.im}^{2}\right)} \]
    10. Step-by-step derivation
      1. unpow291.1%

        \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
      2. mul-1-neg91.1%

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

        \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
    11. Simplified91.1%

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

    if 1.9e-27 < x.re

    1. Initial program 64.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 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def48.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 82.8% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;x.re \leq 3.5 \cdot 10^{-29}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -2.2000000000000001e25

    1. Initial program 65.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. Taylor expanded in x.re around 0 65.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr24.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2000000000000001e25 < x.re < 3.4999999999999997e-29

    1. Initial program 99.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. Taylor expanded in x.re around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
    6. Applied egg-rr56.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def76.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \color{blue}{\left(-1 \cdot {x.im}^{2}\right)} \]
    10. Step-by-step derivation
      1. unpow291.1%

        \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
      2. mul-1-neg91.1%

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

        \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
    11. Simplified91.1%

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

    if 3.4999999999999997e-29 < x.re

    1. Initial program 64.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 inf 66.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 59.9% accurate, 3.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(\left(2 \cdot x.re\right) \cdot x.re\right) + \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)}\right)} - 1 \]
    5. distribute-lft-out41.6%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \color{blue}{\left(x.re \cdot 2\right)} + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1 \]
  6. Applied egg-rr41.6%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x.im \cdot \left(x.re \cdot \left(x.re \cdot 2\right) + \left(x.re \cdot x.re - x.im \cdot x.im\right)\right)\right)} - 1} \]
  7. Step-by-step derivation
    1. expm1-def58.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x.im \cdot \left(-1 \cdot \color{blue}{\left(x.im \cdot x.im\right)}\right) \]
    2. mul-1-neg55.7%

      \[\leadsto x.im \cdot \color{blue}{\left(-x.im \cdot x.im\right)} \]
    3. distribute-rgt-neg-in55.7%

      \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
  11. Simplified55.7%

    \[\leadsto x.im \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \]
  12. Final simplification55.7%

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

Alternative 8: 2.7% accurate, 19.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x.im \cdot \left(x.re \cdot 2\right), x.re, \color{blue}{x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right)}\right) \]
    6. difference-of-squares87.1%

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

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

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

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

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

    \[\leadsto -3 \]

Developer target: 91.6% 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 2023171 
(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)))