| Alternative 1 | |
|---|---|
| Error | 16.4 |
| Cost | 12992 |
\[{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}
\]
(FPCore (x.re x.im y.re y.im)
:precision binary64
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos
(+
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
(* (atan2 x.im x.re) y.re)))))(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -1.0686730943674026e-14)
(pow (hypot x.im x.re) y.re)
(if (<= y.re 2600000000000.0)
(exp (* (atan2 x.im x.re) (- y.im)))
(pow x.re y.re))))double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -1.0686730943674026e-14) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re);
} else if (y_46_re <= 2600000000000.0) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = pow(x_46_re, y_46_re);
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.exp(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -1.0686730943674026e-14) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else if (y_46_re <= 2600000000000.0) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = Math.pow(x_46_re, y_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -1.0686730943674026e-14: tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) elif y_46_re <= 2600000000000.0: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) else: tmp = math.pow(x_46_re, y_46_re) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -1.0686730943674026e-14) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; elseif (y_46_re <= 2600000000000.0) tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))); else tmp = x_46_re ^ y_46_re; end return tmp end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if (y_46_re <= -1.0686730943674026e-14) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; elseif (y_46_re <= 2600000000000.0) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); else tmp = x_46_re ^ y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -1.0686730943674026e-14], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], If[LessEqual[y$46$re, 2600000000000.0], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision], N[Power[x$46$re, y$46$re], $MachinePrecision]]]
e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.0686730943674026 \cdot 10^{-14}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{elif}\;y.re \leq 2600000000000:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;{x.re}^{y.re}\\
\end{array}
Results
if y.re < -1.0686730943674026e-14Initial program 36.6
Taylor expanded in y.im around 0 1.6
Taylor expanded in y.re around 0 1.7
Taylor expanded in y.im around 0 4.0
Simplified3.9
if -1.0686730943674026e-14 < y.re < 2.6e12Initial program 33.8
Taylor expanded in y.im around 0 29.7
Taylor expanded in y.re around 0 29.8
Taylor expanded in y.re around 0 6.7
if 2.6e12 < y.re Initial program 18.2
Taylor expanded in y.im around 0 8.9
Taylor expanded in y.re around 0 8.8
Taylor expanded in y.im around 0 16.0
Simplified16.0
Taylor expanded in x.im around 0 9.7
Final simplification6.2
| Alternative 1 | |
|---|---|
| Error | 16.4 |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Error | 22.4 |
| Cost | 6792 |
| Alternative 3 | |
|---|---|
| Error | 21.8 |
| Cost | 6724 |
| Alternative 4 | |
|---|---|
| Error | 28.3 |
| Cost | 6660 |
| Alternative 5 | |
|---|---|
| Error | 34.3 |
| Cost | 6528 |
herbie shell --seed 2022316
(FPCore (x.re x.im y.re y.im)
:name "powComplex, real part"
:precision binary64
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))