
(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 8 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 (log (hypot x.re x.im))))
(if (<= x.im -1.45e-198)
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(cos (pow (cbrt (fma t_0 y.im (* y.re (atan2 x.im x.re)))) 3.0)))
(exp
(*
y.re
(- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im y.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double tmp;
if (x_46_im <= -1.45e-198) {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos(pow(cbrt(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re)))), 3.0));
} else {
tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) tmp = 0.0 if (x_46_im <= -1.45e-198) tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos((cbrt(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))) ^ 3.0))); else tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / y_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -1.45e-198], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -1.45 \cdot 10^{-198}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\
\end{array}
\end{array}
if x.im < -1.45e-198Initial program 44.4%
fma-neg44.4%
hypot-define44.4%
distribute-rgt-neg-out44.4%
fma-define44.4%
hypot-define82.5%
*-commutative82.5%
Simplified82.5%
fma-undefine82.5%
hypot-define44.4%
*-commutative44.4%
add-cube-cbrt47.2%
pow348.2%
fma-define48.2%
hypot-define90.1%
Applied egg-rr90.1%
if -1.45e-198 < x.im Initial program 42.8%
Taylor expanded in y.im around 0 68.9%
Taylor expanded in y.re around 0 70.4%
Taylor expanded in y.re around inf 70.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-undefine86.1%
mul-1-neg86.1%
unsub-neg86.1%
hypot-undefine70.4%
unpow270.4%
unpow270.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-define86.1%
*-commutative86.1%
associate-/l*86.1%
Simplified86.1%
Final simplification87.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(if (<= x.im -3e-199)
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(cos (* (pow (cbrt y.im) 2.0) (* t_0 (cbrt y.im)))))
(exp
(*
y.re
(- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im y.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double tmp;
if (x_46_im <= -3e-199) {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos((pow(cbrt(y_46_im), 2.0) * (t_0 * cbrt(y_46_im))));
} else {
tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) tmp = 0.0 if (x_46_im <= -3e-199) tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos(Float64((cbrt(y_46_im) ^ 2.0) * Float64(t_0 * cbrt(y_46_im))))); else tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / y_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -3e-199], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[Power[N[Power[y$46$im, 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$0 * N[Power[y$46$im, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -3 \cdot 10^{-199}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im}\right)}^{2} \cdot \left(t\_0 \cdot \sqrt[3]{y.im}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\
\end{array}
\end{array}
if x.im < -2.99999999999999983e-199Initial program 44.4%
fma-neg44.4%
hypot-define44.4%
distribute-rgt-neg-out44.4%
fma-define44.4%
hypot-define82.5%
*-commutative82.5%
Simplified82.5%
fma-undefine82.5%
hypot-define44.4%
*-commutative44.4%
add-cube-cbrt47.2%
pow348.2%
fma-define48.2%
hypot-define90.1%
Applied egg-rr90.1%
Taylor expanded in y.im around inf 45.3%
+-commutative45.3%
unpow245.3%
unpow245.3%
hypot-undefine88.2%
Simplified88.2%
rem-cube-cbrt85.3%
add-cube-cbrt89.1%
hypot-define46.3%
associate-*l*45.3%
pow245.3%
hypot-define89.1%
Applied egg-rr89.1%
if -2.99999999999999983e-199 < x.im Initial program 42.8%
Taylor expanded in y.im around 0 68.9%
Taylor expanded in y.re around 0 70.4%
Taylor expanded in y.re around inf 70.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-undefine86.1%
mul-1-neg86.1%
unsub-neg86.1%
hypot-undefine70.4%
unpow270.4%
unpow270.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-define86.1%
*-commutative86.1%
associate-/l*86.1%
Simplified86.1%
Final simplification87.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(if (<= x.im -4e-198)
(*
(exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
(cos (pow (cbrt (* t_0 y.im)) 3.0)))
(exp
(*
y.re
(- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im y.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(hypot(x_46_re, x_46_im));
double tmp;
if (x_46_im <= -4e-198) {
tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos(pow(cbrt((t_0 * y_46_im)), 3.0));
} else {
tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) tmp = 0.0 if (x_46_im <= -4e-198) tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos((cbrt(Float64(t_0 * y_46_im)) ^ 3.0))); else tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / y_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -4e-198], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(t$95$0 * y$46$im), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -4 \cdot 10^{-198}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{t\_0 \cdot y.im}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\
\end{array}
\end{array}
if x.im < -3.9999999999999996e-198Initial program 44.4%
fma-neg44.4%
hypot-define44.4%
distribute-rgt-neg-out44.4%
fma-define44.4%
hypot-define82.5%
*-commutative82.5%
Simplified82.5%
fma-undefine82.5%
hypot-define44.4%
*-commutative44.4%
add-cube-cbrt47.2%
pow348.2%
fma-define48.2%
hypot-define90.1%
Applied egg-rr90.1%
Taylor expanded in y.im around inf 45.3%
+-commutative45.3%
unpow245.3%
unpow245.3%
hypot-undefine88.2%
Simplified88.2%
if -3.9999999999999996e-198 < x.im Initial program 42.8%
Taylor expanded in y.im around 0 68.9%
Taylor expanded in y.re around 0 70.4%
Taylor expanded in y.re around inf 70.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-undefine86.1%
mul-1-neg86.1%
unsub-neg86.1%
hypot-undefine70.4%
unpow270.4%
unpow270.4%
+-commutative70.4%
unpow270.4%
unpow270.4%
hypot-define86.1%
*-commutative86.1%
associate-/l*86.1%
Simplified86.1%
Final simplification86.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (exp (* y.re (- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_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.exp((y_46_re * (Math.log(Math.hypot(x_46_im, x_46_re)) - (Math.atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((y_46_re * (math.log(math.hypot(x_46_im, x_46_re)) - (math.atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / y_46_re))))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re))))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}
\end{array}
Initial program 43.5%
Taylor expanded in y.im around 0 68.2%
Taylor expanded in y.re around 0 69.1%
Taylor expanded in y.re around inf 69.1%
+-commutative69.1%
unpow269.1%
unpow269.1%
hypot-undefine84.6%
mul-1-neg84.6%
unsub-neg84.6%
hypot-undefine69.1%
unpow269.1%
unpow269.1%
+-commutative69.1%
unpow269.1%
unpow269.1%
hypot-define84.6%
*-commutative84.6%
associate-/l*84.6%
Simplified84.6%
Final simplification84.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -5.8e+19) (not (<= y.re 2.2))) (exp (* (log (hypot x.re x.im)) 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 <= -5.8e+19) || !(y_46_re <= 2.2)) {
tmp = exp((log(hypot(x_46_re, x_46_im)) * 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 <= -5.8e+19) || !(y_46_re <= 2.2)) {
tmp = Math.exp((Math.log(Math.hypot(x_46_re, x_46_im)) * 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 <= -5.8e+19) or not (y_46_re <= 2.2): tmp = math.exp((math.log(math.hypot(x_46_re, x_46_im)) * 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 <= -5.8e+19) || !(y_46_re <= 2.2)) tmp = exp(Float64(log(hypot(x_46_re, x_46_im)) * 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 <= -5.8e+19) || ~((y_46_re <= 2.2))) tmp = exp((log(hypot(x_46_re, x_46_im)) * 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, -5.8e+19], N[Not[LessEqual[y$46$re, 2.2]], $MachinePrecision]], N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision]], $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 -5.8 \cdot 10^{+19} \lor \neg \left(y.re \leq 2.2\right):\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -5.8e19 or 2.2000000000000002 < y.re Initial program 41.6%
Taylor expanded in y.im around 0 78.9%
Taylor expanded in y.re around 0 81.1%
Taylor expanded in y.re around inf 78.2%
+-commutative78.2%
unpow278.2%
unpow278.2%
hypot-undefine78.2%
Simplified78.2%
if -5.8e19 < y.re < 2.2000000000000002Initial program 45.6%
Taylor expanded in y.im around 0 56.0%
Taylor expanded in y.re around 0 55.4%
Taylor expanded in y.re around 0 83.4%
mul-1-neg83.4%
*-commutative83.4%
distribute-rgt-neg-in83.4%
Simplified83.4%
Final simplification80.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (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) {
return exp((atan2(x_46_im, x_46_re) * -y_46_im));
}
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 = exp((atan2(x_46im, x_46re) * -y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((math.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(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}
\end{array}
Initial program 43.5%
Taylor expanded in y.im around 0 68.2%
Taylor expanded in y.re around 0 69.1%
Taylor expanded in y.re around 0 56.0%
mul-1-neg56.0%
*-commutative56.0%
distribute-rgt-neg-in56.0%
Simplified56.0%
Final simplification56.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (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) {
return exp((atan2(x_46_im, x_46_re) * y_46_im));
}
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 = exp((atan2(x_46im, x_46re) * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.exp((Math.atan2(x_46_im, x_46_re) * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp((math.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(Float64(atan(x_46_im, x_46_re) * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp((atan2(x_46_im, x_46_re) * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}
\end{array}
Initial program 43.5%
Taylor expanded in y.im around 0 68.2%
Taylor expanded in y.re around 0 69.1%
Taylor expanded in y.re around 0 56.0%
mul-1-neg56.0%
*-commutative56.0%
distribute-rgt-neg-in56.0%
Simplified56.0%
add-sqr-sqrt27.4%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod14.0%
add-sqr-sqrt26.1%
add-log-exp26.2%
log-pow26.3%
*-un-lft-identity26.3%
log-prod26.3%
metadata-eval26.3%
pow-exp26.1%
rem-log-exp26.1%
Applied egg-rr26.1%
+-lft-identity26.1%
Simplified26.1%
Final simplification26.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (- 1.0 (* (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 1.0 - (atan2(x_46_im, x_46_re) * y_46_im);
}
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 - (atan2(x_46im, x_46re) * y_46im)
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 - (Math.atan2(x_46_im, x_46_re) * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0 - (math.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 Float64(1.0 - Float64(atan(x_46_im, x_46_re) * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0 - (atan2(x_46_im, x_46_re) * y_46_im); 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), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im
\end{array}
Initial program 43.5%
Taylor expanded in y.im around 0 68.2%
Taylor expanded in y.re around 0 69.1%
Taylor expanded in y.re around 0 56.0%
mul-1-neg56.0%
*-commutative56.0%
distribute-rgt-neg-in56.0%
Simplified56.0%
Taylor expanded in y.im around 0 21.2%
mul-1-neg21.2%
Simplified21.2%
Final simplification21.2%
herbie shell --seed 2024085
(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)))))