?

Average Error: 7.3 → 0.3
Time: 8.6s
Precision: binary64
Cost: 1352

?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.3
Target0.3
Herbie0.3
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if x.im < -1.4e154

    1. Initial program 64.0

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Simplified64.0

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

      [Start]64.0

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

      rational_best-simplify-3 [=>]64.0

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

      rational_best-simplify-3 [=>]64.0

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

      rational_best-simplify-3 [<=]64.0

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

      rational_best-simplify-62 [=>]64.0

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

      rational_best-simplify-111 [=>]64.0

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

      rational_best-simplify-113 [=>]64.0

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

      rational_best-simplify-3 [=>]64.0

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

      rational_best-simplify-52 [=>]64.0

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

      rational_best-simplify-113 [=>]64.0

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

      rational_best-simplify-52 [<=]64.0

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

      rational_best-simplify-110 [=>]64.0

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

      rational_best-simplify-52 [=>]64.0

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

      rational_best-simplify-110 [=>]64.0

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

      rational_best-simplify-62 [<=]64.0

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

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

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

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

      [Start]64.0

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

      rational_best-simplify-110 [=>]64.0

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

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

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

      [Start]64.0

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

      rational_best-simplify-113 [=>]64.0

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

      rational_best-simplify-3 [=>]64.0

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

      rational_best-simplify-18 [<=]64.0

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

      rational_best-simplify-62 [=>]64.0

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

      rational_best-simplify-52 [=>]64.0

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

      metadata-eval [=>]64.0

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

      rational_best-simplify-56 [<=]64.0

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

      metadata-eval [<=]64.0

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

      rational_best-simplify-52 [<=]64.0

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

      rational_best-simplify-62 [<=]64.0

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

      rational_best-simplify-1 [=>]64.0

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

      rational_best-simplify-62 [=>]64.0

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

      rational_best-simplify-3 [=>]64.0

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

      rational_best-simplify-18 [=>]64.0

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

      rational_best-simplify-110 [=>]64.0

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

      metadata-eval [=>]64.0

      \[ \left(x.im \cdot \left(-x.im \cdot \color{blue}{3}\right)\right) \cdot x.re \]
    8. Applied egg-rr0.4

      \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;0 \ne 0:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.im \cdot -3\right) \cdot x.re\right)\\ } \end{array}} \]
    9. Simplified0.4

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

      [Start]0.4

      \[ \begin{array}{l} \mathbf{if}\;0 \ne 0:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \left(\left(x.im \cdot -3\right) \cdot x.re\right)\\ \end{array} \]

      rational_best-simplify-8 [=>]0.4

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

      rational_best-simplify-3 [=>]0.4

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

      rational_best-simplify-3 [=>]0.4

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

    if -1.4e154 < x.im < 1.65000000000000008e70

    1. Initial program 0.2

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

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

      [Start]0.2

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

      rational_best-simplify-3 [=>]0.2

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

      rational_best-simplify-3 [=>]0.2

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

      rational_best-simplify-3 [<=]0.2

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

      rational_best-simplify-62 [=>]0.2

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

      rational_best-simplify-111 [=>]0.2

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

      rational_best-simplify-113 [=>]0.2

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

      rational_best-simplify-3 [=>]0.2

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

      rational_best-simplify-52 [=>]0.2

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

      rational_best-simplify-113 [=>]0.2

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

      rational_best-simplify-52 [<=]0.2

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

      rational_best-simplify-110 [=>]0.2

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

      rational_best-simplify-52 [=>]0.2

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

      rational_best-simplify-110 [=>]0.2

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

      rational_best-simplify-62 [<=]0.2

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

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

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

      [Start]0.2

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

      rational_best-simplify-62 [=>]0.2

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

      rational_best-simplify-19 [=>]0.2

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

      rational_best-simplify-51 [=>]0.2

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

      rational_best-simplify-113 [=>]0.2

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

      rational_best-simplify-3 [=>]0.2

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

      rational_best-simplify-113 [=>]0.2

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

    if 1.65000000000000008e70 < x.im

    1. Initial program 27.0

      \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im \]
    2. Simplified27.1

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

      [Start]27.0

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

      rational_best-simplify-3 [=>]27.0

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

      rational_best-simplify-3 [=>]27.0

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

      rational_best-simplify-3 [<=]27.0

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

      rational_best-simplify-62 [=>]27.0

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

      rational_best-simplify-111 [=>]27.0

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

      rational_best-simplify-113 [=>]27.0

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

      rational_best-simplify-3 [=>]27.0

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

      rational_best-simplify-52 [=>]27.0

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

      rational_best-simplify-113 [=>]27.0

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

      rational_best-simplify-52 [<=]27.0

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

      rational_best-simplify-110 [=>]27.1

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

      rational_best-simplify-52 [=>]27.1

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

      rational_best-simplify-110 [=>]27.1

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

      rational_best-simplify-62 [<=]27.1

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

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

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

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

      [Start]27.2

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

      rational_best-simplify-110 [=>]27.2

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

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

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

      [Start]27.7

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

      rational_best-simplify-113 [=>]27.7

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

      rational_best-simplify-3 [=>]27.7

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

      rational_best-simplify-18 [<=]27.7

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

      rational_best-simplify-62 [=>]27.7

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

      rational_best-simplify-52 [=>]27.7

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

      metadata-eval [=>]27.7

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

      rational_best-simplify-56 [<=]27.7

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

      metadata-eval [<=]27.7

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

      rational_best-simplify-52 [<=]27.7

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

      rational_best-simplify-62 [<=]27.7

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

      rational_best-simplify-1 [=>]27.7

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

      rational_best-simplify-62 [=>]27.7

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

      rational_best-simplify-3 [=>]27.7

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

      rational_best-simplify-18 [=>]27.7

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

      rational_best-simplify-110 [=>]27.7

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

      metadata-eval [=>]27.7

      \[ \left(x.im \cdot \left(-x.im \cdot \color{blue}{3}\right)\right) \cdot x.re \]
    8. Applied egg-rr0.9

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

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

      [Start]0.9

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

      rational_best-simplify-19 [=>]0.9

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

      rational_best-simplify-52 [=>]0.9

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

      rational_best-simplify-3 [=>]0.9

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

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

Alternatives

Alternative 1
Error0.3
Cost1224
\[\begin{array}{l} \mathbf{if}\;x.im \leq -5 \cdot 10^{+104}:\\ \;\;\;\;x.im \cdot \left(x.re \cdot \left(-3 \cdot x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 1.55 \cdot 10^{+70}:\\ \;\;\;\;\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.im + x.im\right)\right) \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;\left(x.im \cdot \left(x.re \cdot 3\right)\right) \cdot \left(-x.im\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost1216
\[\left(x.re \cdot \left(x.re \cdot x.re\right) - x.im \cdot \left(x.re \cdot x.im\right)\right) - \left(x.im + x.im\right) \cdot \left(x.re \cdot x.im\right) \]
Alternative 3
Error0.5
Cost968
\[\begin{array}{l} t_0 := \left(x.im \cdot \left(x.re \cdot 3\right)\right) \cdot \left(-x.im\right)\\ \mathbf{if}\;x.im \leq -5.6 \cdot 10^{+57}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 7.2 \cdot 10^{+69}:\\ \;\;\;\;\left(x.re \cdot x.re - x.im \cdot \left(x.im \cdot 3\right)\right) \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error19.4
Cost512
\[\left(x.im \cdot \left(x.re \cdot 3\right)\right) \cdot \left(-x.im\right) \]
Alternative 5
Error19.4
Cost448
\[x.im \cdot \left(x.re \cdot \left(-3 \cdot x.im\right)\right) \]

Error

Reproduce?

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

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

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