
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
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}
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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
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 (* (atan2 x.im x.re) y.im))
(t_1 (* (atan2 x.im x.re) y.re))
(t_2 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_3 (exp (- (* t_2 y.re) t_0)))
(t_4 (log (hypot x.re x.im))))
(if (<= (* t_3 (cos (+ (* t_2 y.im) t_1))) (- INFINITY))
(*
t_3
(-
(sin (* 0.5 PI))
(*
(- y.im)
(*
(sin (fma 0.5 PI (/ PI 2.0)))
(log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
(* (exp (- (* t_4 y.re) t_0)) (sin (+ (fma t_4 y.im t_1) (/ PI 2.0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = atan2(x_46_im, x_46_re) * y_46_re;
double t_2 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_3 = exp(((t_2 * y_46_re) - t_0));
double t_4 = log(hypot(x_46_re, x_46_im));
double tmp;
if ((t_3 * cos(((t_2 * y_46_im) + t_1))) <= -((double) INFINITY)) {
tmp = t_3 * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
} else {
tmp = exp(((t_4 * y_46_re) - t_0)) * sin((fma(t_4, y_46_im, t_1) + (((double) M_PI) / 2.0)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im) t_1 = Float64(atan(x_46_im, x_46_re) * y_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(t_2 * y_46_re) - t_0)) t_4 = log(hypot(x_46_re, x_46_im)) tmp = 0.0 if (Float64(t_3 * cos(Float64(Float64(t_2 * y_46_im) + t_1))) <= Float64(-Inf)) tmp = Float64(t_3 * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5)))))); else tmp = Float64(exp(Float64(Float64(t_4 * y_46_re) - t_0)) * sin(Float64(fma(t_4, y_46_im, t_1) + Float64(pi / 2.0)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $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[(t$95$2 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$3 * N[Cos[N[(N[(t$95$2 * y$46$im), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(t$95$3 * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(t$95$4 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(t$95$4 * y$46$im + t$95$1), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
t_2 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_3 := e^{t\_2 \cdot y.re - t\_0}\\
t_4 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;t\_3 \cdot \cos \left(t\_2 \cdot y.im + t\_1\right) \leq -\infty:\\
\;\;\;\;t\_3 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{t\_4 \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(t\_4, y.im, t\_1\right) + \frac{\pi}{2}\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)))) < -inf.0Initial program 47.5%
Taylor expanded in y.re around 0
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lower-PI.f6452.4
Applied rewrites52.4%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lower-*.f64N/A
Applied rewrites56.2%
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 39.4%
Applied rewrites75.4%
lift-/.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-hypot.f64N/A
lift-exp.f64N/A
div-expN/A
Applied rewrites82.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im)))
(if (<= x.im -2.6e-267)
(*
(exp (- (* (log (hypot x.re x.im)) y.re) t_0))
(sin
(+
(fma (log (* -1.0 x.im)) y.im (* (atan2 x.im x.re) y.re))
(/ PI 2.0))))
(if (<= x.im 1.35e+50)
(*
(exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) t_0))
(sin (* 0.5 PI)))
(*
(cos (fma y.im (log x.im) (* y.re (atan2 x.im x.re))))
(/ (exp (* y.re (log x.im))) (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 t_0 = atan2(x_46_im, x_46_re) * y_46_im;
double tmp;
if (x_46_im <= -2.6e-267) {
tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * sin((fma(log((-1.0 * x_46_im)), y_46_im, (atan2(x_46_im, x_46_re) * y_46_re)) + (((double) M_PI) / 2.0)));
} else if (x_46_im <= 1.35e+50) {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0)) * sin((0.5 * ((double) M_PI)));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), (y_46_re * atan2(x_46_im, x_46_re)))) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im) tmp = 0.0 if (x_46_im <= -2.6e-267) tmp = Float64(exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * sin(Float64(fma(log(Float64(-1.0 * x_46_im)), y_46_im, Float64(atan(x_46_im, x_46_re) * y_46_re)) + Float64(pi / 2.0)))); elseif (x_46_im <= 1.35e+50) tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - t_0)) * sin(Float64(0.5 * pi))); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), Float64(y_46_re * atan(x_46_im, x_46_re)))) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, 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[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, If[LessEqual[x$46$im, -2.6e-267], N[(N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(N[Log[N[(-1.0 * x$46$im), $MachinePrecision]], $MachinePrecision] * y$46$im + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.35e+50], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
\mathbf{if}\;x.im \leq -2.6 \cdot 10^{-267}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(\log \left(-1 \cdot x.im\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)\\
\mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t\_0} \cdot \sin \left(0.5 \cdot \pi\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if x.im < -2.6000000000000001e-267Initial program 40.5%
Applied rewrites72.5%
lift-/.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-hypot.f64N/A
lift-exp.f64N/A
div-expN/A
Applied rewrites80.0%
Taylor expanded in x.im around -inf
lower-*.f6478.9
Applied rewrites78.9%
if -2.6000000000000001e-267 < x.im < 1.35e50Initial program 50.4%
Taylor expanded in y.re around 0
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lower-PI.f6450.3
Applied rewrites50.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lift-PI.f6467.2
Applied rewrites67.2%
if 1.35e50 < x.im Initial program 23.2%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites72.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im))
(t_1 (fma 0.5 PI (* y.re (atan2 x.im x.re))))
(t_2 (sin t_1))
(t_3 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_4 (exp (- (* t_3 y.re) t_0)))
(t_5 (log (hypot x.im x.re))))
(if (<= (* t_4 (cos (+ (* t_3 y.im) (* (atan2 x.im x.re) y.re)))) 0.9)
(*
t_4
(-
(sin (* 0.5 PI))
(*
(- y.im)
(*
(sin (fma 0.5 PI (/ PI 2.0)))
(log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
(*
(exp (- (* (log (hypot x.re x.im)) y.re) t_0))
(-
t_2
(*
(- y.im)
(fma -0.5 (* y.im (* (* t_5 t_5) t_2)) (* (cos t_1) t_5))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
double t_1 = fma(0.5, ((double) M_PI), (y_46_re * atan2(x_46_im, x_46_re)));
double t_2 = sin(t_1);
double t_3 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_4 = exp(((t_3 * y_46_re) - t_0));
double t_5 = log(hypot(x_46_im, x_46_re));
double tmp;
if ((t_4 * cos(((t_3 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)))) <= 0.9) {
tmp = t_4 * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
} else {
tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * (t_2 - (-y_46_im * fma(-0.5, (y_46_im * ((t_5 * t_5) * t_2)), (cos(t_1) * t_5))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im) t_1 = fma(0.5, pi, Float64(y_46_re * atan(x_46_im, x_46_re))) t_2 = sin(t_1) t_3 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_4 = exp(Float64(Float64(t_3 * y_46_re) - t_0)) t_5 = log(hypot(x_46_im, x_46_re)) tmp = 0.0 if (Float64(t_4 * cos(Float64(Float64(t_3 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) <= 0.9) tmp = Float64(t_4 * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5)))))); else tmp = Float64(exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * Float64(t_2 - Float64(Float64(-y_46_im) * fma(-0.5, Float64(y_46_im * Float64(Float64(t_5 * t_5) * t_2)), Float64(cos(t_1) * t_5))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * Pi + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[t$95$1], $MachinePrecision]}, Block[{t$95$3 = 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$4 = N[Exp[N[(N[(t$95$3 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$4 * N[Cos[N[(N[(t$95$3 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.9], N[(t$95$4 * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[(t$95$2 - N[((-y$46$im) * N[(-0.5 * N[(y$46$im * N[(N[(t$95$5 * t$95$5), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t$95$1], $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := \mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_2 := \sin t\_1\\
t_3 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_4 := e^{t\_3 \cdot y.re - t\_0}\\
t_5 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;t\_4 \cdot \cos \left(t\_3 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \leq 0.9:\\
\;\;\;\;t\_4 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \left(t\_2 - \left(-y.im\right) \cdot \mathsf{fma}\left(-0.5, y.im \cdot \left(\left(t\_5 \cdot t\_5\right) \cdot t\_2\right), \cos t\_1 \cdot t\_5\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)))) < 0.900000000000000022Initial program 78.3%
Taylor expanded in y.re around 0
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lower-PI.f6479.6
Applied rewrites79.6%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lower-*.f64N/A
Applied rewrites80.0%
if 0.900000000000000022 < (*.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 25.0%
Applied rewrites74.1%
lift-/.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-hypot.f64N/A
lift-exp.f64N/A
div-expN/A
Applied rewrites80.2%
Taylor expanded in y.im around 0
Applied rewrites70.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re))))
(if (<= x.im -4.8e+169)
(*
(sin (+ (fma -1.0 (log (pow (/ -1.0 x.im) y.im)) t_0) (/ PI 2.0)))
(exp
(fma
-1.0
(log (pow (/ -1.0 x.im) y.re))
(* (- y.im) (atan2 x.im x.re)))))
(if (<= x.im 1.35e+50)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(sin (* 0.5 PI)))
(*
(cos (fma y.im (log x.im) t_0))
(/ (exp (* y.re (log x.im))) (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 t_0 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -4.8e+169) {
tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_im), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_im), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
} else if (x_46_im <= 1.35e+50) {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * sin((0.5 * ((double) M_PI)));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), t_0)) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= -4.8e+169) tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re))))); elseif (x_46_im <= 1.35e+50) tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * sin(Float64(0.5 * pi))); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -4.8e+169], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.35e+50], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -4.8 \cdot 10^{+169}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
\mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(0.5 \cdot \pi\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if x.im < -4.7999999999999997e169Initial program 0.0%
Taylor expanded in x.im around -inf
lower-*.f64N/A
Applied rewrites45.3%
if -4.7999999999999997e169 < x.im < 1.35e50Initial program 51.8%
Taylor expanded in y.re around 0
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lower-PI.f6452.3
Applied rewrites52.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lift-PI.f6468.4
Applied rewrites68.4%
if 1.35e50 < x.im Initial program 23.2%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites72.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re))))
(if (<= x.re -1.9e+145)
(*
(sin (+ (fma -1.0 (log (pow (/ -1.0 x.re) y.im)) t_0) (/ PI 2.0)))
(exp
(fma
-1.0
(log (pow (/ -1.0 x.re) y.re))
(* (- y.im) (atan2 x.im x.re)))))
(if (<= x.re 6.5e-9)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(-
(sin (* 0.5 PI))
(*
(- y.im)
(*
(sin (fma 0.5 PI (/ PI 2.0)))
(log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
(*
(cos (fma y.im (log x.re) t_0))
(/ (exp (* y.re (log x.re))) (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 t_0 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= -1.9e+145) {
tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_re), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_re), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
} else if (x_46_re <= 6.5e-9) {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
} else {
tmp = cos(fma(y_46_im, log(x_46_re), t_0)) * (exp((y_46_re * log(x_46_re))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= -1.9e+145) tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_re) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_re) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re))))); elseif (x_46_re <= 6.5e-9) tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5)))))); else tmp = Float64(cos(fma(y_46_im, log(x_46_re), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_re))) / exp(Float64(y_46_im * atan(x_46_im, 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1.9e+145], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$re), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$re), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.5e-9], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.re \leq -1.9 \cdot 10^{+145}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
\mathbf{elif}\;x.re \leq 6.5 \cdot 10^{-9}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.re, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if x.re < -1.90000000000000006e145Initial program 2.8%
Taylor expanded in x.re around -inf
lower-*.f64N/A
Applied rewrites43.3%
if -1.90000000000000006e145 < x.re < 6.5000000000000003e-9Initial program 53.5%
Taylor expanded in y.re around 0
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lower-PI.f6453.9
Applied rewrites53.9%
Taylor expanded in y.im around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lower-*.f64N/A
Applied rewrites59.0%
if 6.5000000000000003e-9 < x.re Initial program 29.4%
Taylor expanded in x.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites72.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re))))
(if (<= x.im -2e-308)
(*
(sin (+ (fma -1.0 (log (pow (/ -1.0 x.im) y.im)) t_0) (/ PI 2.0)))
(exp
(fma
-1.0
(log (pow (/ -1.0 x.im) y.re))
(* (- y.im) (atan2 x.im x.re)))))
(*
(cos (fma y.im (log x.im) t_0))
(/ (exp (* y.re (log x.im))) (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 t_0 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_im <= -2e-308) {
tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_im), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_im), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
} else {
tmp = cos(fma(y_46_im, log(x_46_im), t_0)) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_im <= -2e-308) tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re))))); else tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -2e-308], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -2 \cdot 10^{-308}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\
\end{array}
\end{array}
if x.im < -1.9999999999999998e-308Initial program 40.6%
Taylor expanded in x.im around -inf
lower-*.f64N/A
Applied rewrites38.0%
if -1.9999999999999998e-308 < x.im Initial program 39.7%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites62.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (exp (* y.im (atan2 x.im x.re))))
(t_1 (* y.re (atan2 x.im x.re))))
(if (<= x.re 1.7e-282)
(* (cos (fma y.im (log x.im) t_1)) (/ (exp (* y.re (log x.im))) t_0))
(* (cos (fma y.im (log x.re) t_1)) (/ (exp (* y.re (log x.re))) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = exp((y_46_im * atan2(x_46_im, x_46_re)));
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (x_46_re <= 1.7e-282) {
tmp = cos(fma(y_46_im, log(x_46_im), t_1)) * (exp((y_46_re * log(x_46_im))) / t_0);
} else {
tmp = cos(fma(y_46_im, log(x_46_re), t_1)) * (exp((y_46_re * log(x_46_re))) / t_0);
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = exp(Float64(y_46_im * atan(x_46_im, x_46_re))) t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (x_46_re <= 1.7e-282) tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_1)) * Float64(exp(Float64(y_46_re * log(x_46_im))) / t_0)); else tmp = Float64(cos(fma(y_46_im, log(x_46_re), t_1)) * Float64(exp(Float64(y_46_re * log(x_46_re))) / t_0)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, 1.7e-282], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.re \leq 1.7 \cdot 10^{-282}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_1\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.re, t\_1\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{t\_0}\\
\end{array}
\end{array}
if x.re < 1.69999999999999999e-282Initial program 40.4%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites31.9%
if 1.69999999999999999e-282 < x.re Initial program 39.8%
Taylor expanded in x.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites67.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (cos (fma y.im (log x.im) (* y.re (atan2 x.im x.re)))) (/ (exp (* y.re (log x.im))) (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 cos(fma(y_46_im, log(x_46_im), (y_46_re * atan2(x_46_im, x_46_re)))) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(cos(fma(y_46_im, log(x_46_im), Float64(y_46_re * atan(x_46_im, x_46_re)))) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, x_46_re))))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}
\end{array}
Initial program 40.1%
Taylor expanded in x.re around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
exp-diffN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-exp.f64N/A
Applied rewrites31.3%
herbie shell --seed 2025101
(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)))))