
(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 9 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 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -1.3e-6)
t_0
(if (<= y.re 3.8e+22)
(*
(exp (* (- y.im) (atan2 x.im x.re)))
(cos (* y.re (atan2 x.im x.re))))
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -1.3e-6) {
tmp = t_0;
} else if (y_46_re <= 3.8e+22) {
tmp = exp((-y_46_im * atan2(x_46_im, x_46_re))) * cos((y_46_re * atan2(x_46_im, x_46_re)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -1.3e-6) tmp = t_0; elseif (y_46_re <= 3.8e+22) tmp = Float64(exp(Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re))) * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.3e-6], t$95$0, If[LessEqual[y$46$re, 3.8e+22], N[(N[Exp[N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.3 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 3.8 \cdot 10^{+22}:\\
\;\;\;\;e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.30000000000000005e-6 or 3.8000000000000004e22 < y.re Initial program 30.1%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.5
Applied rewrites68.5%
Taylor expanded in y.re around 0
Applied rewrites75.0%
if -1.30000000000000005e-6 < y.re < 3.8000000000000004e22Initial program 35.7%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-atan2.f6449.6
Applied rewrites49.6%
Taylor expanded in y.re around 0
neg-mul-1N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-atan2.f6482.0
Applied rewrites82.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re)))
(t_1 (* y.im (atan2 x.im x.re)))
(t_2 (log (/ -1.0 x.re)))
(t_3 (* y.im (log x.re)))
(t_4 (* (sin t_0) (sin t_3)))
(t_5 (* (cos t_0) (cos t_3))))
(if (<= x.re -5e-309)
(* (cos (fma t_2 (- y.im) t_0)) (exp (- (fma y.re t_2 t_1))))
(*
(/
(- (pow t_5 3.0) (pow t_4 3.0))
(+ (pow t_5 2.0) (+ (pow t_4 2.0) (* t_5 t_4))))
(exp (- (* y.re (log x.re)) t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_re * atan2(x_46_im, x_46_re);
double t_1 = y_46_im * atan2(x_46_im, x_46_re);
double t_2 = log((-1.0 / x_46_re));
double t_3 = y_46_im * log(x_46_re);
double t_4 = sin(t_0) * sin(t_3);
double t_5 = cos(t_0) * cos(t_3);
double tmp;
if (x_46_re <= -5e-309) {
tmp = cos(fma(t_2, -y_46_im, t_0)) * exp(-fma(y_46_re, t_2, t_1));
} else {
tmp = ((pow(t_5, 3.0) - pow(t_4, 3.0)) / (pow(t_5, 2.0) + (pow(t_4, 2.0) + (t_5 * t_4)))) * exp(((y_46_re * log(x_46_re)) - t_1));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_1 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_2 = log(Float64(-1.0 / x_46_re)) t_3 = Float64(y_46_im * log(x_46_re)) t_4 = Float64(sin(t_0) * sin(t_3)) t_5 = Float64(cos(t_0) * cos(t_3)) tmp = 0.0 if (x_46_re <= -5e-309) tmp = Float64(cos(fma(t_2, Float64(-y_46_im), t_0)) * exp(Float64(-fma(y_46_re, t_2, t_1)))); else tmp = Float64(Float64(Float64((t_5 ^ 3.0) - (t_4 ^ 3.0)) / Float64((t_5 ^ 2.0) + Float64((t_4 ^ 2.0) + Float64(t_5 * t_4)))) * exp(Float64(Float64(y_46_re * log(x_46_re)) - t_1))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[(-1.0 / x$46$re), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$im * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[t$95$0], $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -5e-309], N[(N[Cos[N[(t$95$2 * (-y$46$im) + t$95$0), $MachinePrecision]], $MachinePrecision] * N[Exp[(-N[(y$46$re * t$95$2 + t$95$1), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[t$95$5, 3.0], $MachinePrecision] - N[Power[t$95$4, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$5, 2.0], $MachinePrecision] + N[(N[Power[t$95$4, 2.0], $MachinePrecision] + N[(t$95$5 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := \log \left(\frac{-1}{x.re}\right)\\
t_3 := y.im \cdot \log x.re\\
t_4 := \sin t\_0 \cdot \sin t\_3\\
t_5 := \cos t\_0 \cdot \cos t\_3\\
\mathbf{if}\;x.re \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(t\_2, -y.im, t\_0\right)\right) \cdot e^{-\mathsf{fma}\left(y.re, t\_2, t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{t\_5}^{3} - {t\_4}^{3}}{{t\_5}^{2} + \left({t\_4}^{2} + t\_5 \cdot t\_4\right)} \cdot e^{y.re \cdot \log x.re - t\_1}\\
\end{array}
\end{array}
if x.re < -4.9999999999999995e-309Initial program 32.1%
Taylor expanded in x.re around -inf
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-exp.f64N/A
Applied rewrites76.7%
if -4.9999999999999995e-309 < x.re Initial program 34.0%
Taylor expanded in x.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-atan2.f6476.5
Applied rewrites76.5%
Applied rewrites79.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -1.3e-6)
t_0
(if (<= y.re 820000000.0)
(/ 1.0 (/ 1.0 (* 1.0 (exp (* (- y.im) (atan2 x.im x.re))))))
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -1.3e-6) {
tmp = t_0;
} else if (y_46_re <= 820000000.0) {
tmp = 1.0 / (1.0 / (1.0 * exp((-y_46_im * atan2(x_46_im, x_46_re)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -1.3e-6) tmp = t_0; elseif (y_46_re <= 820000000.0) tmp = Float64(1.0 / Float64(1.0 / Float64(1.0 * exp(Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re)))))); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.3e-6], t$95$0, If[LessEqual[y$46$re, 820000000.0], N[(1.0 / N[(1.0 / N[(1.0 * N[Exp[N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.3 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 820000000:\\
\;\;\;\;\frac{1}{\frac{1}{1 \cdot e^{\left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.30000000000000005e-6 or 8.2e8 < y.re Initial program 30.5%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.2
Applied rewrites68.2%
Taylor expanded in y.re around 0
Applied rewrites74.4%
if -1.30000000000000005e-6 < y.re < 8.2e8Initial program 35.5%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites35.5%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6434.7
Applied rewrites34.7%
Taylor expanded in y.im around 0
Applied rewrites82.8%
Applied rewrites82.8%
Final simplification78.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -1.3e-6)
t_0
(if (<= y.re 820000000.0)
(/ 1.0 (/ (exp (* y.im (atan2 x.im x.re))) 1.0))
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -1.3e-6) {
tmp = t_0;
} else if (y_46_re <= 820000000.0) {
tmp = 1.0 / (exp((y_46_im * atan2(x_46_im, x_46_re))) / 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -1.3e-6) tmp = t_0; elseif (y_46_re <= 820000000.0) tmp = Float64(1.0 / Float64(exp(Float64(y_46_im * atan(x_46_im, x_46_re))) / 1.0)); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.3e-6], t$95$0, If[LessEqual[y$46$re, 820000000.0], N[(1.0 / N[(N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.3 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 820000000:\\
\;\;\;\;\frac{1}{\frac{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}{1}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.30000000000000005e-6 or 8.2e8 < y.re Initial program 30.5%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.2
Applied rewrites68.2%
Taylor expanded in y.re around 0
Applied rewrites74.4%
if -1.30000000000000005e-6 < y.re < 8.2e8Initial program 35.5%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites35.5%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6434.7
Applied rewrites34.7%
Taylor expanded in y.im around 0
Applied rewrites82.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -2.3e-36)
t_0
(if (<= y.re 31.0) (/ 1.0 (fma (atan2 x.im x.re) y.im 1.0)) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -2.3e-36) {
tmp = t_0;
} else if (y_46_re <= 31.0) {
tmp = 1.0 / fma(atan2(x_46_im, x_46_re), y_46_im, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -2.3e-36) tmp = t_0; elseif (y_46_re <= 31.0) tmp = Float64(1.0 / fma(atan(x_46_im, x_46_re), y_46_im, 1.0)); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -2.3e-36], t$95$0, If[LessEqual[y$46$re, 31.0], N[(1.0 / N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -2.3 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 31:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -2.29999999999999996e-36 or 31 < y.re Initial program 30.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in y.re around 0
Applied rewrites72.8%
if -2.29999999999999996e-36 < y.re < 31Initial program 35.9%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites35.9%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6435.9
Applied rewrites35.9%
Taylor expanded in y.im around 0
Applied rewrites50.7%
Applied rewrites50.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (/ (* 0.5 (* x.im x.im)) x.re) y.re))))
(if (<= y.re -2.3e-36)
t_0
(if (<= y.re 1.75e-9) (/ 1.0 (fma (atan2 x.im x.re) y.im 1.0)) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(((0.5 * (x_46_im * x_46_im)) / x_46_re), y_46_re);
double tmp;
if (y_46_re <= -2.3e-36) {
tmp = t_0;
} else if (y_46_re <= 1.75e-9) {
tmp = 1.0 / fma(atan2(x_46_im, x_46_re), y_46_im, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (Float64(Float64(0.5 * Float64(x_46_im * x_46_im)) / x_46_re) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -2.3e-36) tmp = t_0; elseif (y_46_re <= 1.75e-9) tmp = Float64(1.0 / fma(atan(x_46_im, x_46_re), y_46_im, 1.0)); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[(N[(0.5 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] / x$46$re), $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -2.3e-36], t$95$0, If[LessEqual[y$46$re, 1.75e-9], N[(1.0 / N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\frac{0.5 \cdot \left(x.im \cdot x.im\right)}{x.re}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -2.3 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.75 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -2.29999999999999996e-36 or 1.75e-9 < y.re Initial program 30.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6466.2
Applied rewrites66.2%
Taylor expanded in x.re around inf
Applied rewrites57.5%
Taylor expanded in x.re around 0
Applied rewrites45.6%
Taylor expanded in y.re around 0
Applied rewrites48.5%
if -2.29999999999999996e-36 < y.re < 1.75e-9Initial program 36.0%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites35.9%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6435.9
Applied rewrites35.9%
Taylor expanded in y.im around 0
Applied rewrites51.9%
Applied rewrites51.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re 1.02e+21) (/ 1.0 (fma (atan2 x.im x.re) y.im 1.0)) (fma y.re (log (sqrt (fma x.im x.im (* x.re x.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 <= 1.02e+21) {
tmp = 1.0 / fma(atan2(x_46_im, x_46_re), y_46_im, 1.0);
} else {
tmp = fma(y_46_re, log(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_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 <= 1.02e+21) tmp = Float64(1.0 / fma(atan(x_46_im, x_46_re), y_46_im, 1.0)); else tmp = fma(y_46_re, log(sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)))), 1.0); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 1.02e+21], N[(1.0 / N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im + 1.0), $MachinePrecision]), $MachinePrecision], N[(y$46$re * N[Log[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 1.02 \cdot 10^{+21}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y.re, \log \left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right), 1\right)\\
\end{array}
\end{array}
if y.re < 1.02e21Initial program 34.2%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites33.2%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6425.0
Applied rewrites25.0%
Taylor expanded in y.im around 0
Applied rewrites32.5%
Applied rewrites32.5%
if 1.02e21 < y.re Initial program 28.8%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6457.8
Applied rewrites57.8%
Taylor expanded in y.re around 0
Applied rewrites37.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ 1.0 (fma (atan2 x.im x.re) y.im 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0 / fma(atan2(x_46_im, x_46_re), y_46_im, 1.0);
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(1.0 / fma(atan(x_46_im, x_46_re), y_46_im, 1.0)) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(1.0 / N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im, 1\right)}
\end{array}
Initial program 33.0%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift--.f64N/A
exp-diffN/A
associate-*r/N/A
clear-numN/A
Applied rewrites30.6%
Taylor expanded in y.re around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6421.0
Applied rewrites21.0%
Taylor expanded in y.im around 0
Applied rewrites25.7%
Applied rewrites25.7%
(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 33.0%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6449.5
Applied rewrites49.5%
Taylor expanded in y.re around 0
Applied rewrites25.3%
herbie shell --seed 2024216
(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)))))