
(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)))
(sin (+ (* 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))) * sin(((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))) * sin(((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.sin(((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.sin(((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))) * sin(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))) * sin(((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[Sin[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 \sin \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 7 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)))
(sin (+ (* 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))) * sin(((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))) * sin(((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.sin(((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.sin(((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))) * sin(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))) * sin(((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[Sin[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 \sin \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 (* y.im (atan2 x.im x.re)))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2 (log (hypot x.re x.im)))
(t_3 (* y.im t_2))
(t_4 (exp (- (* t_2 y.re) t_0)))
(t_5 (cbrt t_3)))
(if (<= y.im -9e+23)
(*
t_4
(sin
(+
(pow
(*
(pow (pow t_5 2.0) 0.3333333333333333)
(cbrt (cbrt (* y.im (cbrt (pow t_2 3.0))))))
3.0)
t_1)))
(if (<= y.im -2.4e-260)
(*
(/ (pow (hypot x.re x.im) y.re) (+ 1.0 t_0))
(sin (pow (cbrt (fma y.re (atan2 x.im x.re) t_3)) 3.0)))
(* t_4 (sin (+ t_1 (pow (pow (cbrt t_5) 3.0) 3.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 * atan2(x_46_im, x_46_re);
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = log(hypot(x_46_re, x_46_im));
double t_3 = y_46_im * t_2;
double t_4 = exp(((t_2 * y_46_re) - t_0));
double t_5 = cbrt(t_3);
double tmp;
if (y_46_im <= -9e+23) {
tmp = t_4 * sin((pow((pow(pow(t_5, 2.0), 0.3333333333333333) * cbrt(cbrt((y_46_im * cbrt(pow(t_2, 3.0)))))), 3.0) + t_1));
} else if (y_46_im <= -2.4e-260) {
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0)) * sin(pow(cbrt(fma(y_46_re, atan2(x_46_im, x_46_re), t_3)), 3.0));
} else {
tmp = t_4 * sin((t_1 + pow(pow(cbrt(t_5), 3.0), 3.0)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = log(hypot(x_46_re, x_46_im)) t_3 = Float64(y_46_im * t_2) t_4 = exp(Float64(Float64(t_2 * y_46_re) - t_0)) t_5 = cbrt(t_3) tmp = 0.0 if (y_46_im <= -9e+23) tmp = Float64(t_4 * sin(Float64((Float64(((t_5 ^ 2.0) ^ 0.3333333333333333) * cbrt(cbrt(Float64(y_46_im * cbrt((t_2 ^ 3.0)))))) ^ 3.0) + t_1))); elseif (y_46_im <= -2.4e-260) tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + t_0)) * sin((cbrt(fma(y_46_re, atan(x_46_im, x_46_re), t_3)) ^ 3.0))); else tmp = Float64(t_4 * sin(Float64(t_1 + ((cbrt(t_5) ^ 3.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[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$im * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Exp[N[(N[(t$95$2 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[t$95$3, 1/3], $MachinePrecision]}, If[LessEqual[y$46$im, -9e+23], N[(t$95$4 * N[Sin[N[(N[Power[N[(N[Power[N[Power[t$95$5, 2.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] * N[Power[N[Power[N[(y$46$im * N[Power[N[Power[t$95$2, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -2.4e-260], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sin[N[Power[N[Power[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + t$95$3), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$4 * N[Sin[N[(t$95$1 + N[Power[N[Power[N[Power[t$95$5, 1/3], $MachinePrecision], 3.0], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_3 := y.im \cdot t\_2\\
t_4 := e^{t\_2 \cdot y.re - t\_0}\\
t_5 := \sqrt[3]{t\_3}\\
\mathbf{if}\;y.im \leq -9 \cdot 10^{+23}:\\
\;\;\;\;t\_4 \cdot \sin \left({\left({\left({t\_5}^{2}\right)}^{0.3333333333333333} \cdot \sqrt[3]{\sqrt[3]{y.im \cdot \sqrt[3]{{t\_2}^{3}}}}\right)}^{3} + t\_1\right)\\
\mathbf{elif}\;y.im \leq -2.4 \cdot 10^{-260}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + t\_0} \cdot \sin \left({\left(\sqrt[3]{\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, t\_3\right)}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4 \cdot \sin \left(t\_1 + {\left({\left(\sqrt[3]{t\_5}\right)}^{3}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.im < -8.99999999999999958e23Initial program 38.8%
add-cube-cbrt40.8%
pow342.7%
*-commutative42.7%
hypot-define66.1%
Applied egg-rr66.1%
*-un-lft-identity66.1%
hypot-define74.6%
log-prod74.6%
metadata-eval74.6%
Applied egg-rr74.6%
+-lft-identity74.6%
Simplified74.6%
pow1/311.5%
add-cube-cbrt13.5%
unpow-prod-down11.5%
pow211.5%
*-commutative11.5%
pow1/375.7%
*-commutative75.7%
Applied egg-rr75.7%
add-cbrt-cube80.0%
pow380.0%
Applied egg-rr80.0%
if -8.99999999999999958e23 < y.im < -2.4000000000000001e-260Initial program 48.1%
exp-diff48.1%
exp-to-pow48.1%
hypot-define48.1%
*-commutative48.1%
exp-prod48.1%
fma-define48.1%
hypot-define82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in y.im around 0 81.7%
add-cube-cbrt85.8%
pow391.8%
hypot-define48.2%
*-commutative48.2%
fma-define48.2%
+-commutative48.2%
*-commutative48.2%
fma-define48.2%
*-commutative48.2%
hypot-define91.8%
Applied egg-rr91.8%
if -2.4000000000000001e-260 < y.im Initial program 41.4%
add-cube-cbrt41.9%
pow341.2%
*-commutative41.2%
hypot-define62.0%
Applied egg-rr62.0%
*-un-lft-identity62.0%
hypot-define76.3%
log-prod76.3%
metadata-eval76.3%
Applied egg-rr76.3%
+-lft-identity76.3%
Simplified76.3%
add-cube-cbrt76.2%
pow378.4%
*-commutative78.4%
Applied egg-rr78.4%
Final simplification82.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.im (atan2 x.im x.re)))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2 (log (hypot x.re x.im)))
(t_3 (* y.im t_2)))
(if (<= y.re 3e+270)
(* (exp (- (* t_2 y.re) t_0)) (sin (+ t_1 (pow (cbrt t_3) 3.0))))
(*
(/ (pow (hypot x.re x.im) y.re) (+ 1.0 t_0))
(sin (+ t_3 (pow (cbrt t_1) 3.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 * atan2(x_46_im, x_46_re);
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = log(hypot(x_46_re, x_46_im));
double t_3 = y_46_im * t_2;
double tmp;
if (y_46_re <= 3e+270) {
tmp = exp(((t_2 * y_46_re) - t_0)) * sin((t_1 + pow(cbrt(t_3), 3.0)));
} else {
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0)) * sin((t_3 + pow(cbrt(t_1), 3.0)));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * Math.atan2(x_46_im, x_46_re);
double t_1 = y_46_re * Math.atan2(x_46_im, x_46_re);
double t_2 = Math.log(Math.hypot(x_46_re, x_46_im));
double t_3 = y_46_im * t_2;
double tmp;
if (y_46_re <= 3e+270) {
tmp = Math.exp(((t_2 * y_46_re) - t_0)) * Math.sin((t_1 + Math.pow(Math.cbrt(t_3), 3.0)));
} else {
tmp = (Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + t_0)) * Math.sin((t_3 + Math.pow(Math.cbrt(t_1), 3.0)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = log(hypot(x_46_re, x_46_im)) t_3 = Float64(y_46_im * t_2) tmp = 0.0 if (y_46_re <= 3e+270) tmp = Float64(exp(Float64(Float64(t_2 * y_46_re) - t_0)) * sin(Float64(t_1 + (cbrt(t_3) ^ 3.0)))); else tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + t_0)) * sin(Float64(t_3 + (cbrt(t_1) ^ 3.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[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$im * t$95$2), $MachinePrecision]}, If[LessEqual[y$46$re, 3e+270], N[(N[Exp[N[(N[(t$95$2 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(t$95$1 + N[Power[N[Power[t$95$3, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(t$95$3 + N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_3 := y.im \cdot t\_2\\
\mathbf{if}\;y.re \leq 3 \cdot 10^{+270}:\\
\;\;\;\;e^{t\_2 \cdot y.re - t\_0} \cdot \sin \left(t\_1 + {\left(\sqrt[3]{t\_3}\right)}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + t\_0} \cdot \sin \left(t\_3 + {\left(\sqrt[3]{t\_1}\right)}^{3}\right)\\
\end{array}
\end{array}
if y.re < 3.00000000000000014e270Initial program 42.5%
add-cube-cbrt43.1%
pow343.5%
*-commutative43.5%
hypot-define66.5%
Applied egg-rr66.5%
*-un-lft-identity66.5%
hypot-define79.8%
log-prod79.8%
metadata-eval79.8%
Applied egg-rr79.8%
+-lft-identity79.8%
Simplified79.8%
if 3.00000000000000014e270 < y.re Initial program 45.5%
exp-diff45.5%
exp-to-pow45.5%
hypot-define45.5%
*-commutative45.5%
exp-prod45.5%
fma-define45.5%
hypot-define54.5%
*-commutative54.5%
Simplified54.5%
Taylor expanded in y.im around 0 63.6%
fma-undefine63.6%
hypot-define45.5%
*-commutative45.5%
+-commutative45.5%
*-commutative45.5%
*-commutative45.5%
hypot-define63.6%
Applied egg-rr63.6%
*-commutative63.6%
add-cube-cbrt81.8%
pow381.8%
*-commutative81.8%
Applied egg-rr81.8%
Final simplification79.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(*
(exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))
(sin (fma t_0 y.im (* y.re (atan2 x.im x.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));
return exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))) * sin(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * sin(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re))))) 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]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$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)\\
e^{t\_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\end{array}
\end{array}
Initial program 42.6%
fmm-def42.6%
hypot-define42.6%
distribute-rgt-neg-out42.6%
fma-define42.6%
hypot-define76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in y.re around inf 63.8%
+-commutative63.8%
+-commutative63.8%
unpow263.8%
unpow263.8%
hypot-undefine76.5%
neg-mul-176.5%
sub-neg76.5%
Simplified76.5%
Final simplification76.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im)))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2 (+ 1.0 (* y.im (atan2 x.im x.re)))))
(if (<= y.im -6.7e+72)
(*
(sin (+ t_1 (* y.im t_0)))
(/ (pow (+ x.re (* 0.5 (/ (pow x.im 2.0) x.re))) y.re) t_2))
(* (/ (pow (hypot x.re x.im) y.re) t_2) (sin (fma t_0 y.im t_1))))))
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 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = 1.0 + (y_46_im * atan2(x_46_im, x_46_re));
double tmp;
if (y_46_im <= -6.7e+72) {
tmp = sin((t_1 + (y_46_im * t_0))) * (pow((x_46_re + (0.5 * (pow(x_46_im, 2.0) / x_46_re))), y_46_re) / t_2);
} else {
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / t_2) * sin(fma(t_0, y_46_im, t_1));
}
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 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = Float64(1.0 + Float64(y_46_im * atan(x_46_im, x_46_re))) tmp = 0.0 if (y_46_im <= -6.7e+72) tmp = Float64(sin(Float64(t_1 + Float64(y_46_im * t_0))) * Float64((Float64(x_46_re + Float64(0.5 * Float64((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re) / t_2)); else tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / t_2) * sin(fma(t_0, y_46_im, t_1))); 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -6.7e+72], N[(N[Sin[N[(t$95$1 + N[(y$46$im * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[(x$46$re + N[(0.5 * N[(N[Power[x$46$im, 2.0], $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], y$46$re], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / t$95$2), $MachinePrecision] * N[Sin[N[(t$95$0 * y$46$im + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := 1 + y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;y.im \leq -6.7 \cdot 10^{+72}:\\
\;\;\;\;\sin \left(t\_1 + y.im \cdot t\_0\right) \cdot \frac{{\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{t\_2} \cdot \sin \left(\mathsf{fma}\left(t\_0, y.im, t\_1\right)\right)\\
\end{array}
\end{array}
if y.im < -6.6999999999999998e72Initial program 38.1%
exp-diff33.3%
exp-to-pow33.3%
hypot-define33.3%
*-commutative33.3%
exp-prod33.3%
fma-define33.3%
hypot-define54.9%
*-commutative54.9%
Simplified54.9%
Taylor expanded in y.im around 0 21.8%
fma-undefine21.8%
hypot-define13.3%
*-commutative13.3%
+-commutative13.3%
*-commutative13.3%
*-commutative13.3%
hypot-define21.8%
Applied egg-rr21.8%
Taylor expanded in x.im around 0 41.7%
if -6.6999999999999998e72 < y.im Initial program 43.5%
exp-diff41.1%
exp-to-pow41.1%
hypot-define41.1%
*-commutative41.1%
exp-prod40.6%
fma-define40.6%
hypot-define73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in y.im around 0 66.7%
Final simplification62.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (hypot x.re x.im))))
(*
(exp (- (* t_0 y.re) (* y.im (atan2 x.im x.re))))
(sin (+ (* y.re (atan2 x.im x.re)) (* y.im t_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));
return exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))) * sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * t_0)));
}
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.hypot(x_46_re, x_46_im));
return Math.exp(((t_0 * y_46_re) - (y_46_im * Math.atan2(x_46_im, x_46_re)))) * Math.sin(((y_46_re * Math.atan2(x_46_im, x_46_re)) + (y_46_im * t_0)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.log(math.hypot(x_46_re, x_46_im)) return math.exp(((t_0 * y_46_re) - (y_46_im * math.atan2(x_46_im, x_46_re)))) * math.sin(((y_46_re * math.atan2(x_46_im, x_46_re)) + (y_46_im * t_0)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * sin(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) + Float64(y_46_im * t_0)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(hypot(x_46_re, x_46_im)); tmp = exp(((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re)))) * sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * t_0))); 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]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[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]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
e^{t\_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot t\_0\right)
\end{array}
\end{array}
Initial program 42.6%
fmm-def42.6%
hypot-define42.6%
distribute-rgt-neg-out42.6%
fma-define42.6%
hypot-define76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in y.re around inf 63.8%
+-commutative63.8%
+-commutative63.8%
unpow263.8%
unpow263.8%
hypot-undefine76.5%
neg-mul-176.5%
sub-neg76.5%
Simplified76.5%
fma-undefine59.3%
hypot-define33.3%
*-commutative33.3%
+-commutative33.3%
*-commutative33.3%
*-commutative33.3%
hypot-define59.3%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(sin (+ (* y.re (atan2 x.im x.re)) (* y.im (log (hypot x.re x.im))))))
(t_1 (+ 1.0 (* y.im (atan2 x.im x.re)))))
(if (<= y.im -4.4e+72)
(* t_0 (/ (pow (+ x.re (* 0.5 (/ (pow x.im 2.0) x.re))) y.re) t_1))
(* (/ (pow (hypot x.re x.im) y.re) t_1) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(hypot(x_46_re, x_46_im)))));
double t_1 = 1.0 + (y_46_im * atan2(x_46_im, x_46_re));
double tmp;
if (y_46_im <= -4.4e+72) {
tmp = t_0 * (pow((x_46_re + (0.5 * (pow(x_46_im, 2.0) / x_46_re))), y_46_re) / t_1);
} else {
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / t_1) * t_0;
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.sin(((y_46_re * Math.atan2(x_46_im, x_46_re)) + (y_46_im * Math.log(Math.hypot(x_46_re, x_46_im)))));
double t_1 = 1.0 + (y_46_im * Math.atan2(x_46_im, x_46_re));
double tmp;
if (y_46_im <= -4.4e+72) {
tmp = t_0 * (Math.pow((x_46_re + (0.5 * (Math.pow(x_46_im, 2.0) / x_46_re))), y_46_re) / t_1);
} else {
tmp = (Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / t_1) * t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.sin(((y_46_re * math.atan2(x_46_im, x_46_re)) + (y_46_im * math.log(math.hypot(x_46_re, x_46_im))))) t_1 = 1.0 + (y_46_im * math.atan2(x_46_im, x_46_re)) tmp = 0 if y_46_im <= -4.4e+72: tmp = t_0 * (math.pow((x_46_re + (0.5 * (math.pow(x_46_im, 2.0) / x_46_re))), y_46_re) / t_1) else: tmp = (math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / t_1) * t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = sin(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) + Float64(y_46_im * log(hypot(x_46_re, x_46_im))))) t_1 = Float64(1.0 + Float64(y_46_im * atan(x_46_im, x_46_re))) tmp = 0.0 if (y_46_im <= -4.4e+72) tmp = Float64(t_0 * Float64((Float64(x_46_re + Float64(0.5 * Float64((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re) / t_1)); else tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / t_1) * t_0); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(hypot(x_46_re, x_46_im))))); t_1 = 1.0 + (y_46_im * atan2(x_46_im, x_46_re)); tmp = 0.0; if (y_46_im <= -4.4e+72) tmp = t_0 * (((x_46_re + (0.5 * ((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re) / t_1); else tmp = ((hypot(x_46_re, x_46_im) ^ y_46_re) / t_1) * t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Sin[N[(N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision] + N[(y$46$im * N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -4.4e+72], N[(t$95$0 * N[(N[Power[N[(x$46$re + N[(0.5 * N[(N[Power[x$46$im, 2.0], $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], y$46$re], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right)\\
t_1 := 1 + y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;y.im \leq -4.4 \cdot 10^{+72}:\\
\;\;\;\;t\_0 \cdot \frac{{\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{t\_1} \cdot t\_0\\
\end{array}
\end{array}
if y.im < -4.4e72Initial program 38.1%
exp-diff33.3%
exp-to-pow33.3%
hypot-define33.3%
*-commutative33.3%
exp-prod33.3%
fma-define33.3%
hypot-define54.9%
*-commutative54.9%
Simplified54.9%
Taylor expanded in y.im around 0 21.8%
fma-undefine21.8%
hypot-define13.3%
*-commutative13.3%
+-commutative13.3%
*-commutative13.3%
*-commutative13.3%
hypot-define21.8%
Applied egg-rr21.8%
Taylor expanded in x.im around 0 41.7%
if -4.4e72 < y.im Initial program 43.5%
exp-diff41.1%
exp-to-pow41.1%
hypot-define41.1%
*-commutative41.1%
exp-prod40.6%
fma-define40.6%
hypot-define73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in y.im around 0 66.7%
fma-undefine66.7%
hypot-define37.3%
*-commutative37.3%
+-commutative37.3%
*-commutative37.3%
*-commutative37.3%
hypot-define66.7%
Applied egg-rr66.7%
Final simplification62.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (/ (pow (hypot x.re x.im) y.re) (+ 1.0 (* y.im (atan2 x.im x.re)))) (sin (+ (* y.re (atan2 x.im x.re)) (* y.im (log (hypot x.re x.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (y_46_im * atan2(x_46_im, x_46_re)))) * sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(hypot(x_46_re, x_46_im)))));
}
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_re, x_46_im), y_46_re) / (1.0 + (y_46_im * Math.atan2(x_46_im, x_46_re)))) * Math.sin(((y_46_re * Math.atan2(x_46_im, x_46_re)) + (y_46_im * Math.log(Math.hypot(x_46_re, x_46_im)))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / (1.0 + (y_46_im * math.atan2(x_46_im, x_46_re)))) * math.sin(((y_46_re * math.atan2(x_46_im, x_46_re)) + (y_46_im * math.log(math.hypot(x_46_re, x_46_im)))))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + Float64(y_46_im * atan(x_46_im, x_46_re)))) * sin(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) + Float64(y_46_im * log(hypot(x_46_re, x_46_im)))))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((hypot(x_46_re, x_46_im) ^ y_46_re) / (1.0 + (y_46_im * atan2(x_46_im, x_46_re)))) * sin(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(hypot(x_46_re, x_46_im))))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision] + N[(y$46$im * N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right)
\end{array}
Initial program 42.6%
exp-diff39.9%
exp-to-pow39.9%
hypot-define39.9%
*-commutative39.9%
exp-prod39.4%
fma-define39.4%
hypot-define70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in y.im around 0 59.4%
fma-undefine59.3%
hypot-define33.3%
*-commutative33.3%
+-commutative33.3%
*-commutative33.3%
*-commutative33.3%
hypot-define59.3%
Applied egg-rr59.3%
herbie shell --seed 2024179
(FPCore (x.re x.im y.re y.im)
:name "powComplex, imaginary part"
:precision binary64
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))