
(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 (log (hypot x.re x.im)))
(t_1 (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im)))))
(t_2 (cbrt (fma y.im t_0 (* y.re (atan2 x.im x.re))))))
(if (<= x.re 3.5e-272)
(* t_1 (log1p (expm1 (cos (* y.im (log (hypot x.im x.re)))))))
(* t_1 (cos (* t_2 (pow (pow (cbrt t_2) 2.0) 3.0)))))))
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 t_1 = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im)));
double t_2 = cbrt(fma(y_46_im, t_0, (y_46_re * atan2(x_46_im, x_46_re))));
double tmp;
if (x_46_re <= 3.5e-272) {
tmp = t_1 * log1p(expm1(cos((y_46_im * log(hypot(x_46_im, x_46_re))))));
} else {
tmp = t_1 * cos((t_2 * pow(pow(cbrt(t_2), 2.0), 3.0)));
}
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)) t_1 = exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) t_2 = cbrt(fma(y_46_im, t_0, Float64(y_46_re * atan(x_46_im, x_46_re)))) tmp = 0.0 if (x_46_re <= 3.5e-272) tmp = Float64(t_1 * log1p(expm1(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re))))))); else tmp = Float64(t_1 * cos(Float64(t_2 * ((cbrt(t_2) ^ 2.0) ^ 3.0)))); 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]}, Block[{t$95$1 = 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]}, Block[{t$95$2 = N[Power[N[(y$46$im * t$95$0 + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x$46$re, 3.5e-272], N[(t$95$1 * N[Log[1 + N[(Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[N[(t$95$2 * N[Power[N[Power[N[Power[t$95$2, 1/3], $MachinePrecision], 2.0], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)}\\
t_2 := \sqrt[3]{\mathsf{fma}\left(y.im, t\_0, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
\mathbf{if}\;x.re \leq 3.5 \cdot 10^{-272}:\\
\;\;\;\;t\_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos \left(t\_2 \cdot {\left({\left(\sqrt[3]{t\_2}\right)}^{2}\right)}^{3}\right)\\
\end{array}
\end{array}
if x.re < 3.4999999999999997e-272Initial program 42.9%
cancel-sign-sub-inv42.9%
fma-def42.9%
hypot-def42.9%
distribute-lft-neg-in42.9%
distribute-rgt-neg-out42.9%
fma-def42.9%
hypot-def83.9%
*-commutative83.9%
Simplified83.9%
add-cube-cbrt79.8%
pow381.1%
fma-udef81.1%
*-commutative81.1%
*-commutative81.1%
fma-def81.1%
Applied egg-rr81.1%
log1p-expm1-u81.1%
rem-cube-cbrt83.8%
Applied egg-rr83.8%
Taylor expanded in y.re around 0 43.2%
+-commutative43.2%
unpow243.2%
unpow243.2%
hypot-def87.9%
hypot-def43.2%
unpow243.2%
unpow243.2%
+-commutative43.2%
unpow243.2%
unpow243.2%
hypot-def87.9%
Simplified87.9%
if 3.4999999999999997e-272 < x.re Initial program 38.1%
cancel-sign-sub-inv38.1%
fma-def38.1%
hypot-def38.1%
distribute-lft-neg-in38.1%
distribute-rgt-neg-out38.1%
fma-def38.1%
hypot-def76.7%
*-commutative76.7%
Simplified76.7%
add-cube-cbrt79.0%
pow378.1%
fma-udef78.1%
*-commutative78.1%
*-commutative78.1%
fma-def78.1%
Applied egg-rr78.1%
add-cube-cbrt79.7%
unpow-prod-down78.7%
pow278.7%
pow379.4%
add-cube-cbrt82.9%
Applied egg-rr82.9%
Final simplification85.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_1 (exp (- (* y.re t_0) (* (atan2 x.im x.re) y.im)))))
(if (<= (* t_1 (cos (+ (* y.re (atan2 x.im x.re)) (* y.im t_0)))) 1.0)
(* (cos (* 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)))))))
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))));
double t_1 = exp(((y_46_re * t_0) - (atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if ((t_1 * cos(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * t_0)))) <= 1.0) {
tmp = cos((y_46_im * log(hypot(x_46_im, x_46_re)))) * t_1;
} else {
tmp = exp(fma(log(hypot(x_46_re, x_46_im)), y_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) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_1 = exp(Float64(Float64(y_46_re * t_0) - Float64(atan(x_46_im, x_46_re) * y_46_im))) tmp = 0.0 if (Float64(t_1 * cos(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) + Float64(y_46_im * t_0)))) <= 1.0) tmp = Float64(cos(Float64(y_46_im * log(hypot(x_46_im, x_46_re)))) * t_1); else 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)))); 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[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[Cos[N[(N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision] + N[(y$46$im * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1.0], N[(N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], 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}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_1 := e^{y.re \cdot t\_0 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{if}\;t\_1 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot t\_0\right) \leq 1:\\
\;\;\;\;\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;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}
\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)))) < 1Initial program 83.4%
Taylor expanded in y.re around 0 87.1%
unpow287.1%
unpow287.1%
hypot-def87.1%
Simplified87.1%
if 1 < (*.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 8.9%
cancel-sign-sub-inv8.9%
fma-def8.9%
hypot-def8.9%
distribute-lft-neg-in8.9%
distribute-rgt-neg-out8.9%
fma-def8.9%
hypot-def78.9%
*-commutative78.9%
Simplified78.9%
add-cube-cbrt78.7%
pow380.1%
fma-udef80.1%
*-commutative80.1%
*-commutative80.1%
fma-def80.1%
Applied egg-rr80.1%
Taylor expanded in y.im around inf 77.9%
Final simplification81.9%
(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)))) (log1p (expm1 (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))) * log1p(expm1(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)))) * log1p(expm1(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[Log[1 + N[(Exp[N[Cos[N[(y$46$im * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $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 \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right)
\end{array}
Initial program 40.9%
cancel-sign-sub-inv40.9%
fma-def40.9%
hypot-def40.9%
distribute-lft-neg-in40.9%
distribute-rgt-neg-out40.9%
fma-def40.9%
hypot-def80.8%
*-commutative80.8%
Simplified80.8%
add-cube-cbrt79.5%
pow379.9%
fma-udef79.9%
*-commutative79.9%
*-commutative79.9%
fma-def79.9%
Applied egg-rr79.9%
log1p-expm1-u79.9%
rem-cube-cbrt80.8%
Applied egg-rr80.8%
Taylor expanded in y.re around 0 41.9%
+-commutative41.9%
unpow241.9%
unpow241.9%
hypot-def83.6%
hypot-def41.9%
unpow241.9%
unpow241.9%
+-commutative41.9%
unpow241.9%
unpow241.9%
hypot-def83.6%
Simplified83.6%
Final simplification83.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -1.9) (not (<= y.re 6.0))) (exp (* y.re (log (hypot x.im x.re)))) (/ (pow (hypot x.re x.im) y.re) (pow (exp y.im) (atan2 x.im x.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.9) || !(y_46_re <= 6.0)) {
tmp = exp((y_46_re * log(hypot(x_46_im, x_46_re))));
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / pow(exp(y_46_im), atan2(x_46_im, x_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.9) || !(y_46_re <= 6.0)) {
tmp = Math.exp((y_46_re * Math.log(Math.hypot(x_46_im, x_46_re))));
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.pow(Math.exp(y_46_im), Math.atan2(x_46_im, x_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.9) or not (y_46_re <= 6.0): tmp = math.exp((y_46_re * math.log(math.hypot(x_46_im, x_46_re)))) else: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.pow(math.exp(y_46_im), math.atan2(x_46_im, x_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.9) || !(y_46_re <= 6.0)) tmp = exp(Float64(y_46_re * log(hypot(x_46_im, x_46_re)))); else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan(x_46_im, x_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.9) || ~((y_46_re <= 6.0))) tmp = exp((y_46_re * log(hypot(x_46_im, x_46_re)))); else tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / (exp(y_46_im) ^ atan2(x_46_im, x_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.9], N[Not[LessEqual[y$46$re, 6.0]], $MachinePrecision]], N[Exp[N[(y$46$re * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[Exp[y$46$im], $MachinePrecision], N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.9 \lor \neg \left(y.re \leq 6\right):\\
\;\;\;\;e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if y.re < -1.8999999999999999 or 6 < y.re Initial program 38.2%
cancel-sign-sub-inv38.2%
fma-def38.2%
hypot-def38.2%
distribute-lft-neg-in38.2%
distribute-rgt-neg-out38.2%
fma-def38.2%
hypot-def74.8%
*-commutative74.8%
Simplified74.8%
add-cube-cbrt75.6%
pow375.6%
fma-udef75.6%
*-commutative75.6%
*-commutative75.6%
fma-def75.6%
Applied egg-rr75.6%
Taylor expanded in y.im around inf 78.9%
Taylor expanded in y.re around inf 75.7%
unpow275.7%
unpow275.7%
hypot-def75.7%
Simplified75.7%
if -1.8999999999999999 < y.re < 6Initial program 43.4%
cancel-sign-sub-inv43.4%
fma-def43.4%
hypot-def43.4%
distribute-lft-neg-in43.4%
distribute-rgt-neg-out43.4%
fma-def43.4%
hypot-def86.4%
*-commutative86.4%
Simplified86.4%
add-cube-cbrt83.0%
pow383.8%
fma-udef83.8%
*-commutative83.8%
*-commutative83.8%
fma-def83.8%
Applied egg-rr83.8%
Taylor expanded in y.im around inf 81.5%
hypot-udef46.3%
distribute-rgt-neg-out46.3%
fma-neg46.3%
exp-diff46.2%
hypot-udef81.4%
exp-to-pow81.4%
*-commutative81.4%
exp-prod80.9%
Applied egg-rr80.9%
Final simplification78.4%
(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 40.9%
cancel-sign-sub-inv40.9%
fma-def40.9%
hypot-def40.9%
distribute-lft-neg-in40.9%
distribute-rgt-neg-out40.9%
fma-def40.9%
hypot-def80.8%
*-commutative80.8%
Simplified80.8%
add-cube-cbrt79.5%
pow379.9%
fma-udef79.9%
*-commutative79.9%
*-commutative79.9%
fma-def79.9%
Applied egg-rr79.9%
Taylor expanded in y.im around inf 80.2%
Final simplification80.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -4.3e-15) (not (<= y.re 720.0))) (exp (* y.re (log (hypot x.im x.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 <= -4.3e-15) || !(y_46_re <= 720.0)) {
tmp = exp((y_46_re * log(hypot(x_46_im, x_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 <= -4.3e-15) || !(y_46_re <= 720.0)) {
tmp = Math.exp((y_46_re * Math.log(Math.hypot(x_46_im, x_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 <= -4.3e-15) or not (y_46_re <= 720.0): tmp = math.exp((y_46_re * math.log(math.hypot(x_46_im, x_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 <= -4.3e-15) || !(y_46_re <= 720.0)) tmp = exp(Float64(y_46_re * log(hypot(x_46_im, x_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 <= -4.3e-15) || ~((y_46_re <= 720.0))) tmp = exp((y_46_re * log(hypot(x_46_im, x_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, -4.3e-15], N[Not[LessEqual[y$46$re, 720.0]], $MachinePrecision]], N[Exp[N[(y$46$re * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $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 -4.3 \cdot 10^{-15} \lor \neg \left(y.re \leq 720\right):\\
\;\;\;\;e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\
\end{array}
\end{array}
if y.re < -4.2999999999999997e-15 or 720 < y.re Initial program 37.6%
cancel-sign-sub-inv37.6%
fma-def37.6%
hypot-def37.6%
distribute-lft-neg-in37.6%
distribute-rgt-neg-out37.6%
fma-def37.6%
hypot-def75.2%
*-commutative75.2%
Simplified75.2%
add-cube-cbrt76.0%
pow376.0%
fma-udef76.0%
*-commutative76.0%
*-commutative76.0%
fma-def76.0%
Applied egg-rr76.0%
Taylor expanded in y.im around inf 78.8%
Taylor expanded in y.re around inf 74.6%
unpow274.6%
unpow274.6%
hypot-def75.8%
Simplified75.8%
if -4.2999999999999997e-15 < y.re < 720Initial program 44.1%
Taylor expanded in y.im around 0 46.6%
Taylor expanded in y.re around 0 46.4%
Taylor expanded in y.re around 0 80.9%
Final simplification78.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (exp y.im) (- (atan2 x.im x.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow(exp(y_46_im), -atan2(x_46_im, x_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 = exp(y_46im) ** -atan2(x_46im, x_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(Math.exp(y_46_im), -Math.atan2(x_46_im, x_46_re));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.exp(y_46_im), -math.atan2(x_46_im, x_46_re))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return exp(y_46_im) ^ Float64(-atan(x_46_im, x_46_re)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = exp(y_46_im) ^ -atan2(x_46_im, x_46_re); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[Exp[y$46$im], $MachinePrecision], (-N[ArcTan[x$46$im / x$46$re], $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{y.im}\right)}^{\left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}
\end{array}
Initial program 40.9%
Taylor expanded in y.im around 0 59.0%
Taylor expanded in y.re around 0 44.1%
Taylor expanded in y.re around 0 51.3%
distribute-rgt-neg-in51.3%
exp-prod51.3%
Applied egg-rr51.3%
Final simplification51.3%
(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 40.9%
Taylor expanded in y.im around 0 59.0%
Taylor expanded in y.re around 0 44.1%
Taylor expanded in y.re around 0 51.3%
Final simplification51.3%
(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 40.9%
Taylor expanded in y.im around 0 59.0%
Taylor expanded in y.re around 0 44.1%
Taylor expanded in y.re around 0 51.3%
Taylor expanded in y.im around 0 27.8%
neg-mul-127.8%
distribute-rgt-neg-in27.8%
Simplified27.8%
Final simplification27.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 40.9%
Taylor expanded in y.im around 0 59.0%
Taylor expanded in y.re around 0 44.1%
Taylor expanded in y.re around 0 51.3%
Taylor expanded in y.im around 0 27.6%
Final simplification27.6%
herbie shell --seed 2024031
(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)))))