
(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 11 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
(let* ((t_0
(*
(pow (hypot x.im x.re) y.re)
(cos (* (log (hypot x.im x.re)) y.im)))))
(if (<= y.re -0.000235)
t_0
(if (<= y.re 0.00135)
(*
(pow (exp (- y.im)) (atan2 x.im x.re))
(cos (* (atan2 x.im x.re) y.re)))
(if (<= y.re 1.3e+76)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(sin (fma (atan2 x.im x.re) y.re (/ (PI) 2.0))))
t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\mathbf{if}\;y.re \leq -0.000235:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 0.00135:\\
\;\;\;\;{\left(e^{-y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{+76}:\\
\;\;\;\;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 \sin \left(\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.re, \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -2.34999999999999993e-4 or 1.3e76 < y.re Initial program 45.8%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6444.1
Applied rewrites44.1%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6481.4
Applied rewrites81.4%
if -2.34999999999999993e-4 < y.re < 0.0013500000000000001Initial program 47.6%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6460.5
Applied rewrites60.5%
Taylor expanded in y.re around 0
distribute-lft-neg-inN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-atan2.f6486.5
Applied rewrites86.5%
if 0.0013500000000000001 < y.re < 1.3e76Initial program 50.0%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6492.9
Applied rewrites92.9%
Applied rewrites100.0%
Final simplification84.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.re -1.9e-7) (not (<= y.re 0.0125)))
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos (* (log (hypot x.im x.re)) y.im)))
(*
(pow (exp (- y.im)) (atan2 x.im x.re))
(cos (* (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 tmp;
if ((y_46_re <= -1.9e-7) || !(y_46_re <= 0.0125)) {
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(hypot(x_46_im, x_46_re)) * y_46_im));
} else {
tmp = pow(exp(-y_46_im), atan2(x_46_im, x_46_re)) * cos((atan2(x_46_im, 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) {
double tmp;
if ((y_46_re <= -1.9e-7) || !(y_46_re <= 0.0125)) {
tmp = 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.hypot(x_46_im, x_46_re)) * y_46_im));
} else {
tmp = Math.pow(Math.exp(-y_46_im), Math.atan2(x_46_im, x_46_re)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -1.9e-7) or not (y_46_re <= 0.0125): tmp = 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.hypot(x_46_im, x_46_re)) * y_46_im)) else: tmp = math.pow(math.exp(-y_46_im), math.atan2(x_46_im, x_46_re)) * math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -1.9e-7) || !(y_46_re <= 0.0125)) tmp = 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(log(hypot(x_46_im, x_46_re)) * y_46_im))); else tmp = Float64((exp(Float64(-y_46_im)) ^ atan(x_46_im, x_46_re)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); end return tmp 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.9e-7) || ~((y_46_re <= 0.0125))) 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(hypot(x_46_im, x_46_re)) * y_46_im)); else tmp = (exp(-y_46_im) ^ atan2(x_46_im, x_46_re)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -1.9e-7], N[Not[LessEqual[y$46$re, 0.0125]], $MachinePrecision]], 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[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[(-y$46$im)], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.9 \cdot 10^{-7} \lor \neg \left(y.re \leq 0.0125\right):\\
\;\;\;\;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(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{-y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\end{array}
\end{array}
if y.re < -1.90000000000000007e-7 or 0.012500000000000001 < y.re Initial program 46.2%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6482.6
Applied rewrites82.6%
if -1.90000000000000007e-7 < y.re < 0.012500000000000001Initial program 47.6%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6460.5
Applied rewrites60.5%
Taylor expanded in y.re around 0
distribute-lft-neg-inN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-atan2.f6486.5
Applied rewrites86.5%
Final simplification84.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.re -0.000235) (not (<= y.re 4.5e+15)))
(* (pow (hypot x.im x.re) y.re) (cos (* (log (hypot x.im x.re)) y.im)))
(*
(pow (exp (- y.im)) (atan2 x.im x.re))
(cos (* (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 tmp;
if ((y_46_re <= -0.000235) || !(y_46_re <= 4.5e+15)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * cos((log(hypot(x_46_im, x_46_re)) * y_46_im));
} else {
tmp = pow(exp(-y_46_im), atan2(x_46_im, x_46_re)) * cos((atan2(x_46_im, 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) {
double tmp;
if ((y_46_re <= -0.000235) || !(y_46_re <= 4.5e+15)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re) * Math.cos((Math.log(Math.hypot(x_46_im, x_46_re)) * y_46_im));
} else {
tmp = Math.pow(Math.exp(-y_46_im), Math.atan2(x_46_im, x_46_re)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -0.000235) or not (y_46_re <= 4.5e+15): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) * math.cos((math.log(math.hypot(x_46_im, x_46_re)) * y_46_im)) else: tmp = math.pow(math.exp(-y_46_im), math.atan2(x_46_im, x_46_re)) * math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -0.000235) || !(y_46_re <= 4.5e+15)) tmp = Float64((hypot(x_46_im, x_46_re) ^ y_46_re) * cos(Float64(log(hypot(x_46_im, x_46_re)) * y_46_im))); else tmp = Float64((exp(Float64(-y_46_im)) ^ atan(x_46_im, x_46_re)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -0.000235) || ~((y_46_re <= 4.5e+15))) tmp = (hypot(x_46_im, x_46_re) ^ y_46_re) * cos((log(hypot(x_46_im, x_46_re)) * y_46_im)); else tmp = (exp(-y_46_im) ^ atan2(x_46_im, x_46_re)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -0.000235], N[Not[LessEqual[y$46$re, 4.5e+15]], $MachinePrecision]], N[(N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] * N[Cos[N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[(-y$46$im)], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -0.000235 \lor \neg \left(y.re \leq 4.5 \cdot 10^{+15}\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{-y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\end{array}
\end{array}
if y.re < -2.34999999999999993e-4 or 4.5e15 < y.re Initial program 46.0%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6443.7
Applied rewrites43.7%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6481.0
Applied rewrites81.0%
if -2.34999999999999993e-4 < y.re < 4.5e15Initial program 47.7%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6462.3
Applied rewrites62.3%
Taylor expanded in y.re around 0
distribute-lft-neg-inN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-atan2.f6484.9
Applied rewrites84.9%
Final simplification83.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= y.im -215000000.0) (not (<= y.im 3500000.0)))
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(sin (* 0.5 (PI))))
(* (pow (hypot x.im x.re) y.re) (cos (* (log (hypot x.im x.re)) y.im)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -215000000 \lor \neg \left(y.im \leq 3500000\right):\\
\;\;\;\;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 \sin \left(0.5 \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \cos \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot y.im\right)\\
\end{array}
\end{array}
if y.im < -2.15e8 or 3.5e6 < y.im Initial program 46.8%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6464.3
Applied rewrites64.3%
Applied rewrites72.4%
Taylor expanded in y.re around 0
Applied rewrites64.3%
if -2.15e8 < y.im < 3.5e6Initial program 47.0%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6447.0
Applied rewrites47.0%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6492.8
Applied rewrites92.8%
Final simplification79.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 0.5 (PI)))
(t_1
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(sin t_0)))
(t_2 (pow (hypot x.im x.re) y.re)))
(if (<= y.im -106000000.0)
t_1
(if (<= y.im -4e-241)
(* t_2 (sin (- t_0 (* y.re (atan2 x.im x.re)))))
(if (<= y.im 2.05e+66)
(* (sin (fma (atan2 x.im x.re) y.re (/ (PI) 2.0))) t_2)
t_1)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \mathsf{PI}\left(\right)\\
t_1 := 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 \sin t\_0\\
t_2 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;y.im \leq -106000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -4 \cdot 10^{-241}:\\
\;\;\;\;t\_2 \cdot \sin \left(t\_0 - y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{elif}\;y.im \leq 2.05 \cdot 10^{+66}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.re, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -1.06e8 or 2.04999999999999997e66 < y.im Initial program 48.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f6467.0
Applied rewrites67.0%
Applied rewrites73.0%
Taylor expanded in y.re around 0
Applied rewrites67.0%
if -1.06e8 < y.im < -3.9999999999999999e-241Initial program 45.3%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6445.3
Applied rewrites45.3%
Taylor expanded in y.re around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-atan2.f6486.2
Applied rewrites86.2%
Applied rewrites90.9%
Taylor expanded in y.im around 0
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-atan2.f6490.7
Applied rewrites90.7%
if -3.9999999999999999e-241 < y.im < 2.04999999999999997e66Initial program 46.1%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6470.3
Applied rewrites70.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6478.2
Applied rewrites78.2%
Applied rewrites86.1%
Final simplification78.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re)))
(if (<= x.re -1e-126)
(* (sin (fma (atan2 x.im x.re) y.re (/ (PI) 2.0))) t_0)
(* t_0 (sin (- (* 0.5 (PI)) (* y.re (atan2 x.im x.re))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;x.re \leq -1 \cdot 10^{-126}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.re, \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sin \left(0.5 \cdot \mathsf{PI}\left(\right) - y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\end{array}
\end{array}
if x.re < -9.9999999999999995e-127Initial program 41.0%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6464.4
Applied rewrites64.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6460.9
Applied rewrites60.9%
Applied rewrites69.4%
if -9.9999999999999995e-127 < x.re Initial program 49.7%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6438.5
Applied rewrites38.5%
Taylor expanded in y.re around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-atan2.f6461.6
Applied rewrites61.6%
Applied rewrites63.0%
Taylor expanded in y.im around 0
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-atan2.f6464.4
Applied rewrites64.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.im x.re) y.re)))
(if (<= x.re -2e-77)
(* (cos (* (atan2 x.im x.re) y.re)) t_0)
(* t_0 (sin (- (* 0.5 (PI)) (* y.re (atan2 x.im x.re))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{if}\;x.re \leq -2 \cdot 10^{-77}:\\
\;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sin \left(0.5 \cdot \mathsf{PI}\left(\right) - y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\end{array}
\end{array}
if x.re < -1.9999999999999999e-77Initial program 39.7%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6464.7
Applied rewrites64.7%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6463.5
Applied rewrites63.5%
if -1.9999999999999999e-77 < x.re Initial program 50.0%
Taylor expanded in y.im around 0
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6438.0
Applied rewrites38.0%
Taylor expanded in y.re around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-atan2.f6460.5
Applied rewrites60.5%
Applied rewrites62.4%
Taylor expanded in y.im around 0
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-atan2.f6463.2
Applied rewrites63.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (cos (* (atan2 x.im x.re) y.re)) (pow (hypot x.im x.re) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return cos((atan2(x_46_im, x_46_re) * y_46_re)) * pow(hypot(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) {
return Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re)) * Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) * math.pow(math.hypot(x_46_im, x_46_re), y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) * (hypot(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) tmp = cos((atan2(x_46_im, x_46_re) * y_46_re)) * (hypot(x_46_im, x_46_re) ^ y_46_re); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}
\end{array}
Initial program 46.9%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6470.4
Applied rewrites70.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6459.8
Applied rewrites59.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -6.5) (not (<= y.re 0.6))) (* (cos (* (atan2 x.im x.re) y.re)) (pow x.re y.re)) (fma (log (hypot x.im x.re)) y.re 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -6.5) || !(y_46_re <= 0.6)) {
tmp = cos((atan2(x_46_im, x_46_re) * y_46_re)) * pow(x_46_re, y_46_re);
} else {
tmp = fma(log(hypot(x_46_im, x_46_re)), y_46_re, 1.0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -6.5) || !(y_46_re <= 0.6)) tmp = Float64(cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) * (x_46_re ^ y_46_re)); else tmp = fma(log(hypot(x_46_im, x_46_re)), y_46_re, 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -6.5], N[Not[LessEqual[y$46$re, 0.6]], $MachinePrecision]], N[(N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision] * N[Power[x$46$re, y$46$re], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.5 \lor \neg \left(y.re \leq 0.6\right):\\
\;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot {x.re}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), y.re, 1\right)\\
\end{array}
\end{array}
if y.re < -6.5 or 0.599999999999999978 < y.re Initial program 46.2%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6482.3
Applied rewrites82.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6468.6
Applied rewrites68.6%
Taylor expanded in x.im around 0
Applied rewrites58.8%
if -6.5 < y.re < 0.599999999999999978Initial program 47.7%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6458.1
Applied rewrites58.1%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6450.7
Applied rewrites50.7%
Taylor expanded in y.re around 0
Applied rewrites49.3%
Final simplification54.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -9.5e-9) (not (<= y.re 1.25e+14))) (* (cos (* (atan2 x.im x.re) y.re)) (pow x.im y.re)) (fma (log (hypot x.im x.re)) y.re 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -9.5e-9) || !(y_46_re <= 1.25e+14)) {
tmp = cos((atan2(x_46_im, x_46_re) * y_46_re)) * pow(x_46_im, y_46_re);
} else {
tmp = fma(log(hypot(x_46_im, x_46_re)), y_46_re, 1.0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -9.5e-9) || !(y_46_re <= 1.25e+14)) tmp = Float64(cos(Float64(atan(x_46_im, x_46_re) * y_46_re)) * (x_46_im ^ y_46_re)); else tmp = fma(log(hypot(x_46_im, x_46_re)), y_46_re, 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -9.5e-9], N[Not[LessEqual[y$46$re, 1.25e+14]], $MachinePrecision]], N[(N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision] * N[Power[x$46$im, y$46$re], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.5 \cdot 10^{-9} \lor \neg \left(y.re \leq 1.25 \cdot 10^{+14}\right):\\
\;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot {x.im}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), y.re, 1\right)\\
\end{array}
\end{array}
if y.re < -9.5000000000000007e-9 or 1.25e14 < y.re Initial program 45.7%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6483.0
Applied rewrites83.0%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6467.6
Applied rewrites67.6%
Taylor expanded in x.re around 0
Applied rewrites44.7%
if -9.5000000000000007e-9 < y.re < 1.25e14Initial program 48.1%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6457.6
Applied rewrites57.6%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6451.8
Applied rewrites51.8%
Taylor expanded in y.re around 0
Applied rewrites48.9%
Final simplification46.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 1.0)
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
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
code = 1.0d0
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 1.0 end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 46.9%
Taylor expanded in y.re around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6470.4
Applied rewrites70.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6459.8
Applied rewrites59.8%
Taylor expanded in y.re around 0
Applied rewrites25.6%
herbie shell --seed 2024340
(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)))))