
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * 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): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * 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): t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}
\end{array}
Initial program 39.7%
cancel-sign-sub-inv39.7%
fma-define39.7%
hypot-define39.7%
distribute-lft-neg-in39.7%
distribute-rgt-neg-out39.7%
fma-define39.7%
hypot-define78.0%
*-commutative78.0%
Simplified78.0%
add-cube-cbrt75.3%
pow377.6%
fma-undefine77.2%
*-commutative77.2%
*-commutative77.2%
fma-define77.6%
Applied egg-rr77.6%
Taylor expanded in y.im around inf 80.6%
Final simplification80.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.re x.im) y.re)))
(if (<= y.re -5.7e-15)
(/ t_0 (+ 1.0 (* (atan2 x.im x.re) y.im)))
(if (<= y.re 5.6e-17)
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (* (atan2 x.im x.re) (- y.im))))
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = pow(hypot(x_46_re, x_46_im), y_46_re);
double tmp;
if (y_46_re <= -5.7e-15) {
tmp = t_0 / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im));
} else if (y_46_re <= 5.6e-17) {
tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
double tmp;
if (y_46_re <= -5.7e-15) {
tmp = t_0 / (1.0 + (Math.atan2(x_46_im, x_46_re) * y_46_im));
} else if (y_46_re <= 5.6e-17) {
tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re))) * Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) tmp = 0 if y_46_re <= -5.7e-15: tmp = t_0 / (1.0 + (math.atan2(x_46_im, x_46_re) * y_46_im)) elif y_46_re <= 5.6e-17: tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) * math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_re, x_46_im) ^ y_46_re tmp = 0.0 if (y_46_re <= -5.7e-15) tmp = Float64(t_0 / Float64(1.0 + Float64(atan(x_46_im, x_46_re) * y_46_im))); elseif (y_46_re <= 5.6e-17) tmp = Float64(cos(Float64(y_46_re * atan(x_46_im, x_46_re))) * exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_re, x_46_im) ^ y_46_re; tmp = 0.0; if (y_46_re <= -5.7e-15) tmp = t_0 / (1.0 + (atan2(x_46_im, x_46_re) * y_46_im)); elseif (y_46_re <= 5.6e-17) tmp = cos((y_46_re * atan2(x_46_im, x_46_re))) * exp((atan2(x_46_im, x_46_re) * -y_46_im)); else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$re, -5.7e-15], N[(t$95$0 / N[(1.0 + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.6e-17], N[(N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -5.7 \cdot 10^{-15}:\\
\;\;\;\;\frac{t\_0}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;y.re \leq 5.6 \cdot 10^{-17}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -5.7000000000000003e-15Initial program 35.6%
exp-diff31.5%
exp-to-pow31.5%
hypot-define31.5%
*-commutative31.5%
exp-prod31.5%
fma-define31.5%
hypot-define71.2%
*-commutative71.2%
Simplified71.2%
add-cube-cbrt82.2%
pow384.9%
fma-undefine83.6%
*-commutative83.6%
*-commutative83.6%
fma-define84.9%
Applied egg-rr68.5%
Taylor expanded in y.im around inf 65.8%
Taylor expanded in y.im around 0 80.9%
if -5.7000000000000003e-15 < y.re < 5.5999999999999998e-17Initial program 40.7%
exp-diff40.7%
exp-to-pow40.7%
hypot-define40.7%
*-commutative40.7%
exp-prod40.5%
fma-define40.5%
hypot-define75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in y.re around 0 76.3%
rec-exp76.3%
distribute-lft-neg-in76.3%
exp-prod75.5%
Simplified75.5%
Taylor expanded in x.re around -inf 39.4%
Taylor expanded in y.im around 0 78.8%
*-commutative78.8%
Simplified78.8%
if 5.5999999999999998e-17 < y.re Initial program 42.9%
exp-diff39.3%
exp-to-pow39.3%
hypot-define39.3%
*-commutative39.3%
exp-prod39.3%
fma-define39.3%
hypot-define60.7%
*-commutative60.7%
Simplified60.7%
add-cube-cbrt67.7%
pow371.3%
fma-undefine71.3%
*-commutative71.3%
*-commutative71.3%
fma-define71.3%
Applied egg-rr58.9%
Taylor expanded in y.im around inf 64.7%
Taylor expanded in y.im around 0 73.7%
Final simplification78.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im))
(t_1 (pow (hypot x.re x.im) y.re))
(t_2 (exp (- (* (log (/ -1.0 x.im)) (- y.re)) t_0))))
(if (<= x.im -6200000.0)
t_2
(if (<= x.im -9e-132)
t_1
(if (<= x.im -2.1e-300)
t_2
(if (<= x.im 9.2e-215)
(/ t_1 (+ 1.0 t_0))
(exp (- (* y.re (log x.im)) t_0))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = pow(hypot(x_46_re, x_46_im), y_46_re);
double t_2 = exp(((log((-1.0 / x_46_im)) * -y_46_re) - t_0));
double tmp;
if (x_46_im <= -6200000.0) {
tmp = t_2;
} else if (x_46_im <= -9e-132) {
tmp = t_1;
} else if (x_46_im <= -2.1e-300) {
tmp = t_2;
} else if (x_46_im <= 9.2e-215) {
tmp = t_1 / (1.0 + t_0);
} else {
tmp = exp(((y_46_re * log(x_46_im)) - t_0));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
double t_2 = Math.exp(((Math.log((-1.0 / x_46_im)) * -y_46_re) - t_0));
double tmp;
if (x_46_im <= -6200000.0) {
tmp = t_2;
} else if (x_46_im <= -9e-132) {
tmp = t_1;
} else if (x_46_im <= -2.1e-300) {
tmp = t_2;
} else if (x_46_im <= 9.2e-215) {
tmp = t_1 / (1.0 + t_0);
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_im)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.atan2(x_46_im, x_46_re) * y_46_im t_1 = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) t_2 = math.exp(((math.log((-1.0 / x_46_im)) * -y_46_re) - t_0)) tmp = 0 if x_46_im <= -6200000.0: tmp = t_2 elif x_46_im <= -9e-132: tmp = t_1 elif x_46_im <= -2.1e-300: tmp = t_2 elif x_46_im <= 9.2e-215: tmp = t_1 / (1.0 + t_0) else: tmp = math.exp(((y_46_re * math.log(x_46_im)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im) t_1 = hypot(x_46_re, x_46_im) ^ y_46_re t_2 = exp(Float64(Float64(log(Float64(-1.0 / x_46_im)) * Float64(-y_46_re)) - t_0)) tmp = 0.0 if (x_46_im <= -6200000.0) tmp = t_2; elseif (x_46_im <= -9e-132) tmp = t_1; elseif (x_46_im <= -2.1e-300) tmp = t_2; elseif (x_46_im <= 9.2e-215) tmp = Float64(t_1 / Float64(1.0 + t_0)); else tmp = exp(Float64(Float64(y_46_re * log(x_46_im)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = atan2(x_46_im, x_46_re) * y_46_im; t_1 = hypot(x_46_re, x_46_im) ^ y_46_re; t_2 = exp(((log((-1.0 / x_46_im)) * -y_46_re) - t_0)); tmp = 0.0; if (x_46_im <= -6200000.0) tmp = t_2; elseif (x_46_im <= -9e-132) tmp = t_1; elseif (x_46_im <= -2.1e-300) tmp = t_2; elseif (x_46_im <= 9.2e-215) tmp = t_1 / (1.0 + t_0); else tmp = exp(((y_46_re * log(x_46_im)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision] * (-y$46$re)), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -6200000.0], t$95$2, If[LessEqual[x$46$im, -9e-132], t$95$1, If[LessEqual[x$46$im, -2.1e-300], t$95$2, If[LessEqual[x$46$im, 9.2e-215], N[(t$95$1 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
t_2 := e^{\log \left(\frac{-1}{x.im}\right) \cdot \left(-y.re\right) - t\_0}\\
\mathbf{if}\;x.im \leq -6200000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x.im \leq -9 \cdot 10^{-132}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x.im \leq -2.1 \cdot 10^{-300}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x.im \leq 9.2 \cdot 10^{-215}:\\
\;\;\;\;\frac{t\_1}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.im - t\_0}\\
\end{array}
\end{array}
if x.im < -6.2e6 or -8.9999999999999999e-132 < x.im < -2.10000000000000004e-300Initial program 30.5%
cancel-sign-sub-inv30.5%
fma-define30.5%
hypot-define30.5%
distribute-lft-neg-in30.5%
distribute-rgt-neg-out30.5%
fma-define30.5%
hypot-define76.8%
*-commutative76.8%
Simplified76.8%
add-cube-cbrt71.9%
pow373.8%
fma-undefine73.8%
*-commutative73.8%
*-commutative73.8%
fma-define73.8%
Applied egg-rr73.8%
Taylor expanded in y.im around inf 80.5%
Taylor expanded in x.im around -inf 78.9%
+-commutative78.9%
neg-mul-178.9%
sub-neg78.9%
mul-1-neg78.9%
*-commutative78.9%
distribute-rgt-neg-in78.9%
Simplified78.9%
if -6.2e6 < x.im < -8.9999999999999999e-132Initial program 65.4%
exp-diff61.5%
exp-to-pow61.5%
hypot-define61.5%
*-commutative61.5%
exp-prod61.5%
fma-define61.5%
hypot-define81.5%
*-commutative81.5%
Simplified81.5%
add-cube-cbrt88.5%
pow392.4%
fma-undefine92.4%
*-commutative92.4%
*-commutative92.4%
fma-define92.4%
Applied egg-rr84.7%
Taylor expanded in y.im around inf 81.5%
Taylor expanded in y.im around 0 74.3%
if -2.10000000000000004e-300 < x.im < 9.1999999999999996e-215Initial program 35.4%
exp-diff35.4%
exp-to-pow35.4%
hypot-define35.4%
*-commutative35.4%
exp-prod34.8%
fma-define34.8%
hypot-define65.6%
*-commutative65.6%
Simplified65.6%
add-cube-cbrt67.0%
pow367.0%
fma-undefine67.0%
*-commutative67.0%
*-commutative67.0%
fma-define67.0%
Applied egg-rr61.7%
Taylor expanded in y.im around inf 65.4%
Taylor expanded in y.im around 0 70.7%
if 9.1999999999999996e-215 < x.im Initial program 42.7%
cancel-sign-sub-inv42.7%
fma-define42.7%
hypot-define42.7%
distribute-lft-neg-in42.7%
distribute-rgt-neg-out42.7%
fma-define42.7%
hypot-define78.4%
*-commutative78.4%
Simplified78.4%
add-cube-cbrt77.1%
pow380.0%
fma-undefine79.1%
*-commutative79.1%
*-commutative79.1%
fma-define80.0%
Applied egg-rr80.0%
Taylor expanded in y.im around inf 80.9%
Taylor expanded in x.re around 0 77.3%
+-commutative77.3%
neg-mul-177.3%
unsub-neg77.3%
*-commutative77.3%
Simplified77.3%
Final simplification76.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= x.re 1.6e-308) (and (not (<= x.re 1.9e-184)) (<= x.re 4.8e-14))) (pow (hypot x.re x.im) y.re) (exp (- (* y.re (log x.re)) (* (atan2 x.im x.re) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((x_46_re <= 1.6e-308) || (!(x_46_re <= 1.9e-184) && (x_46_re <= 4.8e-14))) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re);
} else {
tmp = exp(((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im)));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((x_46_re <= 1.6e-308) || (!(x_46_re <= 1.9e-184) && (x_46_re <= 4.8e-14))) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_re)) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (x_46_re <= 1.6e-308) or (not (x_46_re <= 1.9e-184) and (x_46_re <= 4.8e-14)): tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) else: tmp = math.exp(((y_46_re * math.log(x_46_re)) - (math.atan2(x_46_im, x_46_re) * y_46_im))) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((x_46_re <= 1.6e-308) || (!(x_46_re <= 1.9e-184) && (x_46_re <= 4.8e-14))) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; else tmp = exp(Float64(Float64(y_46_re * log(x_46_re)) - Float64(atan(x_46_im, x_46_re) * y_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((x_46_re <= 1.6e-308) || (~((x_46_re <= 1.9e-184)) && (x_46_re <= 4.8e-14))) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; else tmp = exp(((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im))); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[x$46$re, 1.6e-308], And[N[Not[LessEqual[x$46$re, 1.9e-184]], $MachinePrecision], LessEqual[x$46$re, 4.8e-14]]], N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 1.6 \cdot 10^{-308} \lor \neg \left(x.re \leq 1.9 \cdot 10^{-184}\right) \land x.re \leq 4.8 \cdot 10^{-14}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\end{array}
\end{array}
if x.re < 1.6000000000000001e-308 or 1.90000000000000008e-184 < x.re < 4.8e-14Initial program 43.5%
exp-diff41.4%
exp-to-pow41.4%
hypot-define41.4%
*-commutative41.4%
exp-prod41.4%
fma-define41.4%
hypot-define73.1%
*-commutative73.1%
Simplified73.1%
add-cube-cbrt78.6%
pow382.1%
fma-undefine81.4%
*-commutative81.4%
*-commutative81.4%
fma-define82.1%
Applied egg-rr73.8%
Taylor expanded in y.im around inf 75.1%
Taylor expanded in y.im around 0 62.5%
if 1.6000000000000001e-308 < x.re < 1.90000000000000008e-184 or 4.8e-14 < x.re Initial program 34.8%
cancel-sign-sub-inv34.8%
fma-define34.8%
hypot-define34.8%
distribute-lft-neg-in34.8%
distribute-rgt-neg-out34.8%
fma-define34.8%
hypot-define74.5%
*-commutative74.5%
Simplified74.5%
add-cube-cbrt70.9%
pow371.8%
fma-undefine71.8%
*-commutative71.8%
*-commutative71.8%
fma-define71.8%
Applied egg-rr71.8%
Taylor expanded in y.im around inf 74.1%
Taylor expanded in x.im around 0 69.5%
+-commutative69.5%
neg-mul-169.5%
unsub-neg69.5%
Simplified69.5%
Final simplification65.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im)))
(if (<= x.im 4e-213)
(/ (pow (hypot x.re x.im) y.re) (+ 1.0 t_0))
(exp (- (* y.re (log x.im)) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
double tmp;
if (x_46_im <= 4e-213) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0);
} else {
tmp = exp(((y_46_re * log(x_46_im)) - t_0));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.atan2(x_46_im, x_46_re) * y_46_im;
double tmp;
if (x_46_im <= 4e-213) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0);
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_im)) - t_0));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.atan2(x_46_im, x_46_re) * y_46_im tmp = 0 if x_46_im <= 4e-213: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0) else: tmp = math.exp(((y_46_re * math.log(x_46_im)) - t_0)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im) tmp = 0.0 if (x_46_im <= 4e-213) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + t_0)); else tmp = exp(Float64(Float64(y_46_re * log(x_46_im)) - t_0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = atan2(x_46_im, x_46_re) * y_46_im; tmp = 0.0; if (x_46_im <= 4e-213) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (1.0 + t_0); else tmp = exp(((y_46_re * log(x_46_im)) - t_0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, If[LessEqual[x$46$im, 4e-213], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
\mathbf{if}\;x.im \leq 4 \cdot 10^{-213}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.im - t\_0}\\
\end{array}
\end{array}
if x.im < 3.9999999999999998e-213Initial program 37.5%
exp-diff36.2%
exp-to-pow36.2%
hypot-define36.2%
*-commutative36.2%
exp-prod36.0%
fma-define36.0%
hypot-define71.5%
*-commutative71.5%
Simplified71.5%
add-cube-cbrt74.0%
pow375.9%
fma-undefine75.9%
*-commutative75.9%
*-commutative75.9%
fma-define75.9%
Applied egg-rr69.9%
Taylor expanded in y.im around inf 71.6%
Taylor expanded in y.im around 0 63.4%
if 3.9999999999999998e-213 < x.im Initial program 42.7%
cancel-sign-sub-inv42.7%
fma-define42.7%
hypot-define42.7%
distribute-lft-neg-in42.7%
distribute-rgt-neg-out42.7%
fma-define42.7%
hypot-define78.4%
*-commutative78.4%
Simplified78.4%
add-cube-cbrt77.1%
pow380.0%
fma-undefine79.1%
*-commutative79.1%
*-commutative79.1%
fma-define80.0%
Applied egg-rr80.0%
Taylor expanded in y.im around inf 80.9%
Taylor expanded in x.re around 0 77.3%
+-commutative77.3%
neg-mul-177.3%
unsub-neg77.3%
*-commutative77.3%
Simplified77.3%
Final simplification69.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= x.im 3.2e-213) (pow (hypot x.re x.im) y.re) (exp (- (* y.re (log x.im)) (* (atan2 x.im x.re) y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (x_46_im <= 3.2e-213) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re);
} else {
tmp = exp(((y_46_re * log(x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im)));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (x_46_im <= 3.2e-213) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
} else {
tmp = Math.exp(((y_46_re * Math.log(x_46_im)) - (Math.atan2(x_46_im, x_46_re) * y_46_im)));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if x_46_im <= 3.2e-213: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) else: tmp = math.exp(((y_46_re * math.log(x_46_im)) - (math.atan2(x_46_im, x_46_re) * y_46_im))) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (x_46_im <= 3.2e-213) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; else tmp = exp(Float64(Float64(y_46_re * log(x_46_im)) - Float64(atan(x_46_im, x_46_re) * y_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if (x_46_im <= 3.2e-213) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; else tmp = exp(((y_46_re * log(x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im))); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[x$46$im, 3.2e-213], N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Exp[N[(N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 3.2 \cdot 10^{-213}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.im - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\end{array}
\end{array}
if x.im < 3.19999999999999972e-213Initial program 37.5%
exp-diff36.2%
exp-to-pow36.2%
hypot-define36.2%
*-commutative36.2%
exp-prod36.0%
fma-define36.0%
hypot-define71.5%
*-commutative71.5%
Simplified71.5%
add-cube-cbrt74.0%
pow375.9%
fma-undefine75.9%
*-commutative75.9%
*-commutative75.9%
fma-define75.9%
Applied egg-rr69.9%
Taylor expanded in y.im around inf 71.6%
Taylor expanded in y.im around 0 62.4%
if 3.19999999999999972e-213 < x.im Initial program 42.7%
cancel-sign-sub-inv42.7%
fma-define42.7%
hypot-define42.7%
distribute-lft-neg-in42.7%
distribute-rgt-neg-out42.7%
fma-define42.7%
hypot-define78.4%
*-commutative78.4%
Simplified78.4%
add-cube-cbrt77.1%
pow380.0%
fma-undefine79.1%
*-commutative79.1%
*-commutative79.1%
fma-define80.0%
Applied egg-rr80.0%
Taylor expanded in y.im around inf 80.9%
Taylor expanded in x.re around 0 77.3%
+-commutative77.3%
neg-mul-177.3%
unsub-neg77.3%
*-commutative77.3%
Simplified77.3%
Final simplification68.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (hypot x.re x.im) y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow(hypot(x_46_re, x_46_im), y_46_re);
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_re, x_46_im), y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return hypot(x_46_re, x_46_im) ^ y_46_re end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}
\end{array}
Initial program 39.7%
exp-diff37.8%
exp-to-pow37.8%
hypot-define37.8%
*-commutative37.8%
exp-prod37.6%
fma-define37.6%
hypot-define71.0%
*-commutative71.0%
Simplified71.0%
add-cube-cbrt75.3%
pow377.6%
fma-undefine77.2%
*-commutative77.2%
*-commutative77.2%
fma-define77.6%
Applied egg-rr69.7%
Taylor expanded in y.im around inf 71.5%
Taylor expanded in y.im around 0 60.0%
Final simplification60.0%
herbie shell --seed 2024053
(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)))))