
(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 10 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
(exp
(fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im)))))
(t_1 (* y.im (log (hypot x.im x.re))))
(t_2 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_3 (exp (- (* y.re t_2) (* (atan2 x.im x.re) y.im))))
(t_4 (* t_3 (cos (+ (* y.im t_2) (* y.re (atan2 x.im x.re))))))
(t_5 (cos t_1)))
(if (<= t_4 0.8)
(* t_5 t_3)
(if (<= t_4 INFINITY)
(* t_0 (+ 1.0 (* -0.5 (pow t_1 2.0))))
(* t_0 t_5)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double t_1 = y_46_im * log(hypot(x_46_im, x_46_re));
double t_2 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_3 = exp(((y_46_re * t_2) - (atan2(x_46_im, x_46_re) * y_46_im)));
double t_4 = t_3 * cos(((y_46_im * t_2) + (y_46_re * atan2(x_46_im, x_46_re))));
double t_5 = cos(t_1);
double tmp;
if (t_4 <= 0.8) {
tmp = t_5 * t_3;
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_0 * (1.0 + (-0.5 * pow(t_1, 2.0)));
} else {
tmp = t_0 * t_5;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 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)))) t_1 = Float64(y_46_im * log(hypot(x_46_im, x_46_re))) t_2 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_3 = exp(Float64(Float64(y_46_re * t_2) - Float64(atan(x_46_im, x_46_re) * y_46_im))) t_4 = Float64(t_3 * cos(Float64(Float64(y_46_im * t_2) + Float64(y_46_re * atan(x_46_im, x_46_re))))) t_5 = cos(t_1) tmp = 0.0 if (t_4 <= 0.8) tmp = Float64(t_5 * t_3); elseif (t_4 <= Inf) tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * (t_1 ^ 2.0)))); else tmp = Float64(t_0 * t_5); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(y$46$re * t$95$2), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[Cos[N[(N[(y$46$im * t$95$2), $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[t$95$1], $MachinePrecision]}, If[LessEqual[t$95$4, 0.8], N[(t$95$5 * t$95$3), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$5), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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)}\\
t_1 := y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_2 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_3 := e^{y.re \cdot t\_2 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_4 := t\_3 \cdot \cos \left(y.im \cdot t\_2 + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_5 := \cos t\_1\\
\mathbf{if}\;t\_4 \leq 0.8:\\
\;\;\;\;t\_5 \cdot t\_3\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_0 \cdot \left(1 + -0.5 \cdot {t\_1}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_5\\
\end{array}
\end{array}
if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < 0.80000000000000004Initial program 86.3%
Taylor expanded in y.re around 0 87.5%
unpow287.5%
unpow287.5%
hypot-undefine87.5%
Simplified87.5%
if 0.80000000000000004 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < +inf.0Initial program 71.5%
fma-neg71.5%
hypot-define71.5%
distribute-rgt-neg-out71.5%
fma-define71.5%
hypot-define71.5%
*-commutative71.5%
Simplified71.5%
Taylor expanded in y.im around inf 73.0%
unpow273.0%
unpow273.0%
hypot-undefine73.0%
Simplified73.0%
Taylor expanded in y.im around 0 89.0%
unpow289.0%
unpow289.0%
unpow289.0%
hypot-undefine89.0%
unpow289.0%
swap-sqr89.0%
unpow289.0%
Simplified89.0%
if +inf.0 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) Initial program 0.0%
fma-neg0.0%
hypot-define0.0%
distribute-rgt-neg-out0.0%
fma-define0.0%
hypot-define87.4%
*-commutative87.4%
Simplified87.4%
Taylor expanded in y.im around inf 0.0%
unpow20.0%
unpow20.0%
hypot-undefine91.8%
Simplified91.8%
Final simplification89.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (log (hypot x.im x.re))))
(t_1
(exp
(fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))))
(if (<= y.re 1.15e-302)
(* t_1 (cos (pow (cbrt t_0) 3.0)))
(* t_1 (cos t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * log(hypot(x_46_im, x_46_re));
double t_1 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double tmp;
if (y_46_re <= 1.15e-302) {
tmp = t_1 * cos(pow(cbrt(t_0), 3.0));
} else {
tmp = t_1 * cos(t_0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * log(hypot(x_46_im, x_46_re))) t_1 = 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)))) tmp = 0.0 if (y_46_re <= 1.15e-302) tmp = Float64(t_1 * cos((cbrt(t_0) ^ 3.0))); else tmp = Float64(t_1 * cos(t_0)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[y$46$re, 1.15e-302], N[(t$95$1 * N[Cos[N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_1 := 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)}\\
\mathbf{if}\;y.re \leq 1.15 \cdot 10^{-302}:\\
\;\;\;\;t\_1 \cdot \cos \left({\left(\sqrt[3]{t\_0}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos t\_0\\
\end{array}
\end{array}
if y.re < 1.15000000000000001e-302Initial program 49.9%
fma-neg49.9%
hypot-define49.9%
distribute-rgt-neg-out49.9%
fma-define49.9%
hypot-define85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in y.im around inf 49.9%
unpow249.9%
unpow249.9%
hypot-undefine86.0%
Simplified86.0%
add-cube-cbrt88.4%
pow391.5%
Applied egg-rr91.5%
if 1.15000000000000001e-302 < y.re Initial program 37.8%
fma-neg37.8%
hypot-define37.8%
distribute-rgt-neg-out37.8%
fma-define37.8%
hypot-define81.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in y.im around inf 39.4%
unpow239.4%
unpow239.4%
hypot-undefine85.7%
Simplified85.7%
Final simplification88.6%
(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)))) (cos (* y.im (log (hypot x.im x.re))))))
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))) * cos((y_46_im * log(hypot(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(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)))) * cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(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] * N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $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)} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)
\end{array}
Initial program 43.9%
fma-neg43.9%
hypot-define43.9%
distribute-rgt-neg-out43.9%
fma-define43.9%
hypot-define83.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in y.im around inf 44.6%
unpow244.6%
unpow244.6%
hypot-undefine85.9%
Simplified85.9%
Final simplification85.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))))
(if (<= x.re -5e-309)
(* t_0 (cos (* y.im (log (/ -1.0 x.re)))))
(* t_0 (cos (* y.im (log x.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double tmp;
if (x_46_re <= -5e-309) {
tmp = t_0 * cos((y_46_im * log((-1.0 / x_46_re))));
} else {
tmp = t_0 * cos((y_46_im * log(x_46_re)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 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)))) tmp = 0.0 if (x_46_re <= -5e-309) tmp = Float64(t_0 * cos(Float64(y_46_im * log(Float64(-1.0 / x_46_re))))); else tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_re)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = 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]}, If[LessEqual[x$46$re, -5e-309], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[N[(-1.0 / x$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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)}\\
\mathbf{if}\;x.re \leq -5 \cdot 10^{-309}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log \left(\frac{-1}{x.re}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.re\right)\\
\end{array}
\end{array}
if x.re < -4.9999999999999995e-309Initial program 47.3%
fma-neg47.3%
hypot-define47.3%
distribute-rgt-neg-out47.3%
fma-define47.3%
hypot-define86.7%
*-commutative86.7%
Simplified86.7%
Taylor expanded in y.im around inf 49.0%
unpow249.0%
unpow249.0%
hypot-undefine88.5%
Simplified88.5%
Taylor expanded in x.re around -inf 87.6%
mul-1-neg87.6%
cos-neg87.6%
Simplified87.6%
if -4.9999999999999995e-309 < x.re Initial program 41.1%
fma-neg41.1%
hypot-define41.1%
distribute-rgt-neg-out41.1%
fma-define41.1%
hypot-define80.3%
*-commutative80.3%
Simplified80.3%
Taylor expanded in y.im around inf 41.1%
unpow241.1%
unpow241.1%
hypot-undefine83.8%
Simplified83.8%
Taylor expanded in x.im around 0 83.1%
Final simplification85.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(exp
(fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))))
(if (<= x.re 3e-295) t_0 (* t_0 (cos (* y.im (log x.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double tmp;
if (x_46_re <= 3e-295) {
tmp = t_0;
} else {
tmp = t_0 * cos((y_46_im * log(x_46_re)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 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)))) tmp = 0.0 if (x_46_re <= 3e-295) tmp = t_0; else tmp = Float64(t_0 * cos(Float64(y_46_im * log(x_46_re)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = 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]}, If[LessEqual[x$46$re, 3e-295], t$95$0, N[(t$95$0 * N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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)}\\
\mathbf{if}\;x.re \leq 3 \cdot 10^{-295}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \cos \left(y.im \cdot \log x.re\right)\\
\end{array}
\end{array}
if x.re < 2.99999999999999996e-295Initial program 47.0%
fma-neg47.0%
hypot-define47.0%
distribute-rgt-neg-out47.0%
fma-define47.0%
hypot-define85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in y.im around inf 49.5%
unpow249.5%
unpow249.5%
hypot-undefine88.1%
Simplified88.1%
Taylor expanded in y.im around 0 86.6%
if 2.99999999999999996e-295 < x.re Initial program 41.2%
fma-neg41.2%
hypot-define41.2%
distribute-rgt-neg-out41.2%
fma-define41.2%
hypot-define81.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in y.im around inf 40.5%
unpow240.5%
unpow240.5%
hypot-undefine83.9%
Simplified83.9%
Taylor expanded in x.im around 0 83.2%
Final simplification84.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= x.re 4.9e-166)
(exp (fma (log (hypot x.re x.im)) y.re (* (atan2 x.im x.re) (- y.im))))
(*
(cos (* y.im (log (hypot x.im x.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 <= 4.9e-166) {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
} else {
tmp = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * exp(((y_46_re * log(x_46_re)) - (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 <= 4.9e-166) tmp = 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)))); else tmp = Float64(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * 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
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[x$46$re, 4.9e-166], 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], N[(N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $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]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 4.9 \cdot 10^{-166}:\\
\;\;\;\;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)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\end{array}
\end{array}
if x.re < 4.8999999999999999e-166Initial program 45.9%
fma-neg45.9%
hypot-define45.9%
distribute-rgt-neg-out45.9%
fma-define45.9%
hypot-define85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in y.im around inf 47.9%
unpow247.9%
unpow247.9%
hypot-undefine89.2%
Simplified89.2%
Taylor expanded in y.im around 0 87.3%
if 4.8999999999999999e-166 < x.re Initial program 41.0%
fma-neg41.0%
hypot-define41.0%
distribute-rgt-neg-out41.0%
fma-define41.0%
hypot-define80.2%
*-commutative80.2%
Simplified80.2%
Taylor expanded in y.im around inf 40.0%
unpow240.0%
unpow240.0%
hypot-undefine81.1%
Simplified81.1%
Taylor expanded in x.im around 0 78.3%
+-commutative78.3%
neg-mul-178.3%
unsub-neg78.3%
Simplified78.3%
Final simplification83.6%
(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 43.9%
fma-neg43.9%
hypot-define43.9%
distribute-rgt-neg-out43.9%
fma-define43.9%
hypot-define83.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in y.im around inf 44.6%
unpow244.6%
unpow244.6%
hypot-undefine85.9%
Simplified85.9%
Taylor expanded in y.im around 0 81.8%
Final simplification81.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -0.00345) (not (<= y.re 8500000000.0))) (pow (hypot x.im x.re) y.re) (exp (* (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 ((y_46_re <= -0.00345) || !(y_46_re <= 8500000000.0)) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = exp((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 ((y_46_re <= -0.00345) || !(y_46_re <= 8500000000.0)) {
tmp = Math.pow(Math.hypot(x_46_im, x_46_re), y_46_re);
} else {
tmp = Math.exp((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 (y_46_re <= -0.00345) or not (y_46_re <= 8500000000.0): tmp = math.pow(math.hypot(x_46_im, x_46_re), y_46_re) else: tmp = math.exp((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 ((y_46_re <= -0.00345) || !(y_46_re <= 8500000000.0)) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-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 ((y_46_re <= -0.00345) || ~((y_46_re <= 8500000000.0))) tmp = hypot(x_46_im, x_46_re) ^ y_46_re; else tmp = exp((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[y$46$re, -0.00345], N[Not[LessEqual[y$46$re, 8500000000.0]], $MachinePrecision]], N[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -0.00345 \lor \neg \left(y.re \leq 8500000000\right):\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -0.0034499999999999999 or 8.5e9 < y.re Initial program 41.1%
fma-neg41.1%
hypot-define41.1%
distribute-rgt-neg-out41.1%
fma-define41.1%
hypot-define80.6%
*-commutative80.6%
Simplified80.6%
Taylor expanded in y.im around inf 42.7%
unpow242.7%
unpow242.7%
hypot-undefine86.3%
Simplified86.3%
Taylor expanded in y.im around 0 41.9%
unpow241.9%
unpow241.9%
unpow241.9%
hypot-undefine70.2%
unpow270.2%
swap-sqr70.2%
unpow270.2%
Simplified70.2%
Taylor expanded in y.im around 0 79.1%
unpow279.1%
unpow279.1%
hypot-undefine79.1%
Simplified79.1%
if -0.0034499999999999999 < y.re < 8.5e9Initial program 46.4%
Taylor expanded in y.im around 0 50.4%
Taylor expanded in y.re around 0 50.4%
unpow250.4%
unpow250.4%
swap-sqr50.4%
unpow250.4%
Simplified50.4%
Taylor expanded in y.re around 0 78.5%
distribute-rgt-neg-in78.5%
Simplified78.5%
Final simplification78.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (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 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.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.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 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 = 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[Power[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}
\end{array}
Initial program 43.9%
fma-neg43.9%
hypot-define43.9%
distribute-rgt-neg-out43.9%
fma-define43.9%
hypot-define83.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in y.im around inf 44.6%
unpow244.6%
unpow244.6%
hypot-undefine85.9%
Simplified85.9%
Taylor expanded in y.im around 0 44.7%
unpow244.7%
unpow244.7%
unpow244.7%
hypot-undefine70.6%
unpow270.6%
swap-sqr70.6%
unpow270.6%
Simplified70.6%
Taylor expanded in y.im around 0 55.6%
unpow255.6%
unpow255.6%
hypot-undefine61.7%
Simplified61.7%
Final simplification61.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (/ -1.0 x.re) (- y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow((-1.0 / 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
code = ((-1.0d0) / 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) {
return Math.pow((-1.0 / x_46_re), -y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow((-1.0 / x_46_re), -y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(-1.0 / x_46_re) ^ Float64(-y_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (-1.0 / x_46_re) ^ -y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[(-1.0 / x$46$re), $MachinePrecision], (-y$46$re)], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{-1}{x.re}\right)}^{\left(-y.re\right)}
\end{array}
Initial program 43.9%
fma-neg43.9%
hypot-define43.9%
distribute-rgt-neg-out43.9%
fma-define43.9%
hypot-define83.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in y.im around inf 44.6%
unpow244.6%
unpow244.6%
hypot-undefine85.9%
Simplified85.9%
Taylor expanded in y.im around 0 81.8%
Taylor expanded in x.re around -inf 35.2%
+-commutative35.2%
neg-mul-135.2%
sub-neg35.2%
mul-1-neg35.2%
distribute-rgt-neg-in35.2%
Simplified35.2%
Taylor expanded in y.im around 0 25.0%
mul-1-neg25.0%
*-commutative25.0%
distribute-rgt-neg-in25.0%
exp-to-pow39.9%
Simplified39.9%
Final simplification39.9%
herbie shell --seed 2024075
(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)))))