?

Average Accuracy: 50.1% → 56.5%
Time: 10.7s
Precision: binary64
Cost: 9608

?

\[\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} t_0 := x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ t_1 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\left(1 + t_0\right) + -1\\ \mathbf{elif}\;t_1 \leq 10^{+299}:\\ \;\;\;\;{x.re}^{3} + -3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left|t_0\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
 (let* ((t_0 (* x.im (* x.im (* x.re -3.0))))
        (t_1
         (-
          (* x.re (- (* x.re x.re) (* x.im x.im)))
          (* x.im (+ (* x.re x.im) (* x.re x.im))))))
   (if (<= t_1 (- INFINITY))
     (+ (+ 1.0 t_0) -1.0)
     (if (<= t_1 1e+299)
       (+ (pow x.re 3.0) (* -3.0 (* x.re (* x.im x.im))))
       (fabs t_0)))))
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 t_0 = x_46_im * (x_46_im * (x_46_re * -3.0));
	double t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (1.0 + t_0) + -1.0;
	} else if (t_1 <= 1e+299) {
		tmp = pow(x_46_re, 3.0) + (-3.0 * (x_46_re * (x_46_im * x_46_im)));
	} else {
		tmp = fabs(t_0);
	}
	return tmp;
}
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 t_0 = x_46_im * (x_46_im * (x_46_re * -3.0));
	double t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (1.0 + t_0) + -1.0;
	} else if (t_1 <= 1e+299) {
		tmp = Math.pow(x_46_re, 3.0) + (-3.0 * (x_46_re * (x_46_im * x_46_im)));
	} else {
		tmp = Math.abs(t_0);
	}
	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):
	t_0 = x_46_im * (x_46_im * (x_46_re * -3.0))
	t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (1.0 + t_0) + -1.0
	elif t_1 <= 1e+299:
		tmp = math.pow(x_46_re, 3.0) + (-3.0 * (x_46_re * (x_46_im * x_46_im)))
	else:
		tmp = math.fabs(t_0)
	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)
	t_0 = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0)))
	t_1 = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(1.0 + t_0) + -1.0);
	elseif (t_1 <= 1e+299)
		tmp = Float64((x_46_re ^ 3.0) + Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))));
	else
		tmp = abs(t_0);
	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)
	t_0 = x_46_im * (x_46_im * (x_46_re * -3.0));
	t_1 = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (1.0 + t_0) + -1.0;
	elseif (t_1 <= 1e+299)
		tmp = (x_46_re ^ 3.0) + (-3.0 * (x_46_re * (x_46_im * x_46_im)));
	else
		tmp = abs(t_0);
	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_] := Block[{t$95$0 = N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[t$95$1, 1e+299], N[(N[Power[x$46$re, 3.0], $MachinePrecision] + N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[t$95$0], $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}
t_0 := x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
t_1 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\left(1 + t_0\right) + -1\\

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

\mathbf{else}:\\
\;\;\;\;\left|t_0\right|\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original50.1%
Target56.1%
Herbie56.5%
\[\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 (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < -inf.0

    1. Initial program 0.0%

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

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

      [Start]0.0

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

      *-commutative [=>]0.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 \]

      fma-neg [=>]0.0

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

      distribute-lft-neg-in [=>]0.0

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

      *-commutative [=>]0.0

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

      *-commutative [=>]0.0

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

      count-2 [=>]0.0

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

      distribute-lft-neg-in [=>]0.0

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

      metadata-eval [=>]0.0

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

      *-commutative [<=]0.0

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

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

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

      [Start]0.5

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

      distribute-rgt-out [=>]0.5

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

      metadata-eval [=>]0.5

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

      metadata-eval [<=]0.5

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

      associate-*l* [=>]0.5

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

      *-commutative [<=]0.5

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

      distribute-rgt-out [<=]0.5

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

      unpow2 [=>]0.5

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

      associate-*l* [=>]16.9

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

      distribute-rgt-out [=>]16.9

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

      metadata-eval [=>]16.9

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

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

      [Start]16.9

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

      expm1-log1p-u [=>]0.4

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

      expm1-udef [=>]0.5

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

      log1p-udef [=>]0.5

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

      add-exp-log [<=]17.0

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

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

    1. Initial program 99.7%

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

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

      [Start]99.7

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

      *-commutative [=>]99.7

      \[ \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 \]

      sub-neg [=>]99.7

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

      distribute-lft-in [=>]99.7

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

      associate--l+ [=>]99.7

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

      cube-unmult [=>]99.8

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

      *-commutative [<=]99.8

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

      distribute-lft-out [=>]99.8

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

      associate-*l* [=>]99.8

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

      distribute-lft-out-- [=>]99.7

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

      neg-mul-1 [=>]99.7

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

      count-2 [=>]99.7

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

      associate-*l* [=>]99.7

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

      distribute-rgt-out-- [=>]99.7

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

      associate-*l* [<=]99.8

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

      metadata-eval [=>]99.8

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

    if 1.0000000000000001e299 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im))

    1. Initial program 0.6%

      \[\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.6%

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

      [Start]0.6

      \[ \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 \]

      *-commutative [=>]0.6

      \[ \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 \]

      fma-neg [=>]0.6

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

      distribute-lft-neg-in [=>]0.6

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

      *-commutative [=>]0.6

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

      *-commutative [=>]0.6

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

      count-2 [=>]0.6

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

      distribute-lft-neg-in [=>]0.6

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

      metadata-eval [=>]0.6

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

      *-commutative [<=]0.6

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

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

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

      [Start]0.4

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

      distribute-rgt-out [=>]0.4

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

      metadata-eval [=>]0.4

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

      metadata-eval [<=]0.4

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

      associate-*l* [=>]0.4

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

      *-commutative [<=]0.4

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

      distribute-rgt-out [<=]0.4

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

      unpow2 [=>]0.4

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

      associate-*l* [=>]9.8

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

      distribute-rgt-out [=>]9.8

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

      metadata-eval [=>]9.8

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

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

      [Start]9.8

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

      add-sqr-sqrt [=>]9.5

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

      sqrt-unprod [=>]2.4

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

      pow2 [=>]2.4

      \[ \sqrt{\color{blue}{{\left(x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\right)}^{2}}} \]
    6. Applied egg-rr10.6%

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

      [Start]2.4

      \[ \sqrt{{\left(x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\right)}^{2}} \]

      unpow2 [=>]2.4

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

      rem-sqrt-square [=>]10.6

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

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

Alternatives

Alternative 1
Accuracy56.2%
Cost13312
\[\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, {x.re}^{3}\right) \]
Alternative 2
Accuracy56.3%
Cost9416
\[\begin{array}{l} t_0 := x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ t_1 := x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+302}:\\ \;\;\;\;\left(1 + t_0\right) + -1\\ \mathbf{elif}\;t_1 \leq 10^{+299}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left|t_0\right|\\ \end{array} \]
Alternative 3
Accuracy56.0%
Cost3273
\[\begin{array}{l} t_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 + x.re \cdot x.im\right)\\ \mathbf{if}\;t_0 \leq -4 \cdot 10^{+302} \lor \neg \left(t_0 \leq 10^{+299}\right):\\ \;\;\;\;\left(1 + x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\ \end{array} \]
Alternative 4
Accuracy55.6%
Cost968
\[\begin{array}{l} \mathbf{if}\;x.im \leq -2.9 \cdot 10^{+27}:\\ \;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{elif}\;x.im \leq 4.2 \cdot 10^{+67}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \end{array} \]
Alternative 5
Accuracy45.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;x.im \leq -1.4 \cdot 10^{-43} \lor \neg \left(x.im \leq 1.25 \cdot 10^{-38}\right):\\ \;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]
Alternative 6
Accuracy51.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;x.im \leq -3.9 \cdot 10^{-41} \lor \neg \left(x.im \leq 1.3 \cdot 10^{-38}\right):\\ \;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]
Alternative 7
Accuracy51.7%
Cost713
\[\begin{array}{l} \mathbf{if}\;x.im \leq -1.55 \cdot 10^{-40} \lor \neg \left(x.im \leq 2.12 \cdot 10^{-38}\right):\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \end{array} \]
Alternative 8
Accuracy51.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;x.im \leq -3.2 \cdot 10^{-43}:\\ \;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\ \mathbf{elif}\;x.im \leq 1.2 \cdot 10^{-38}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\ \end{array} \]
Alternative 9
Accuracy51.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;x.im \leq -4.9 \cdot 10^{-45}:\\ \;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\ \mathbf{elif}\;x.im \leq 1.75 \cdot 10^{-38}:\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\ \end{array} \]
Alternative 10
Accuracy33.8%
Cost649
\[\begin{array}{l} \mathbf{if}\;x.re \leq -2.8 \cdot 10^{-102} \lor \neg \left(x.re \leq 5 \cdot 10^{-107}\right):\\ \;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(-x.im\right)\\ \end{array} \]
Alternative 11
Accuracy15.8%
Cost320
\[x.re \cdot \left(x.im \cdot x.im\right) \]
Alternative 12
Accuracy31.6%
Cost320
\[x.re \cdot \left(x.re \cdot x.re\right) \]

Error

Reproduce?

herbie shell --seed 2023153 
(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)))