
(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}
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}
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}
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}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re))))
(if (<= y.re -7737125245533627/77371252455336267181195264)
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos t_0))
(if (<=
y.re
7656353255721115/21267647932558653966460912964485513216)
(* (exp (- (* y.im (atan2 x.im x.re)))) 1)
(if (<=
y.re
340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760)
(*
(sin (- t_0 (* -1/2 PI)))
(pow (sqrt (+ (pow x.im 2) (pow x.re 2))) y.re))
(*
(pow (+ (* x.im x.im) (* x.re x.re)) (* y.re 1/2))
(cos (* (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 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (y_46_re <= -1e-10) {
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))) * cos(t_0);
} else if (y_46_re <= 3.6e-22) {
tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
} else if (y_46_re <= 3.4e+164) {
tmp = sin((t_0 - (-0.5 * ((double) M_PI)))) * pow(sqrt((pow(x_46_im, 2.0) + pow(x_46_re, 2.0))), y_46_re);
} else {
tmp = pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_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 t_0 = y_46_re * Math.atan2(x_46_im, x_46_re);
double tmp;
if (y_46_re <= -1e-10) {
tmp = Math.exp(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(t_0);
} else if (y_46_re <= 3.6e-22) {
tmp = Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
} else if (y_46_re <= 3.4e+164) {
tmp = Math.sin((t_0 - (-0.5 * Math.PI))) * Math.pow(Math.sqrt((Math.pow(x_46_im, 2.0) + Math.pow(x_46_re, 2.0))), y_46_re);
} else {
tmp = Math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = y_46_re * math.atan2(x_46_im, x_46_re) tmp = 0 if y_46_re <= -1e-10: tmp = math.exp(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(t_0) elif y_46_re <= 3.6e-22: tmp = math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0 elif y_46_re <= 3.4e+164: tmp = math.sin((t_0 - (-0.5 * math.pi))) * math.pow(math.sqrt((math.pow(x_46_im, 2.0) + math.pow(x_46_re, 2.0))), y_46_re) else: tmp = math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * math.cos((math.atan2(x_46_im, x_46_re) * y_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 (y_46_re <= -1e-10) 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))) * cos(t_0)); elseif (y_46_re <= 3.6e-22) tmp = Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); elseif (y_46_re <= 3.4e+164) tmp = Float64(sin(Float64(t_0 - Float64(-0.5 * pi))) * (sqrt(Float64((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re)); else tmp = Float64((Float64(Float64(x_46_im * x_46_im) + Float64(x_46_re * x_46_re)) ^ Float64(y_46_re * 0.5)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = y_46_re * atan2(x_46_im, x_46_re); tmp = 0.0; if (y_46_re <= -1e-10) 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))) * cos(t_0); elseif (y_46_re <= 3.6e-22) tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0; elseif (y_46_re <= 3.4e+164) tmp = sin((t_0 - (-0.5 * pi))) * (sqrt(((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re); else tmp = (((x_46_im * x_46_im) + (x_46_re * x_46_re)) ^ (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); end tmp_2 = 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[y$46$re, -7737125245533627/77371252455336267181195264], 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[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 7656353255721115/21267647932558653966460912964485513216], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision], If[LessEqual[y$46$re, 340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760], N[(N[Sin[N[(t$95$0 - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[N[(N[Power[x$46$im, 2], $MachinePrecision] + N[Power[x$46$re, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(y$46$re * 1/2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;y.re \leq \frac{-7737125245533627}{77371252455336267181195264}:\\
\;\;\;\;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 \cos t\_0\\
\mathbf{elif}\;y.re \leq \frac{7656353255721115}{21267647932558653966460912964485513216}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{elif}\;y.re \leq 340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760:\\
\;\;\;\;\sin \left(t\_0 - \frac{-1}{2} \cdot \pi\right) \cdot {\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}^{y.re}\\
\mathbf{else}:\\
\;\;\;\;{\left(x.im \cdot x.im + x.re \cdot x.re\right)}^{\left(y.re \cdot \frac{1}{2}\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\end{array}
if y.re < -1e-10Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
if -1e-10 < y.re < 3.5999999999999998e-22Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
if 3.5999999999999998e-22 < y.re < 3.4000000000000001e164Initial program 40.3%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites40.1%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-pow.f64N/A
Applied rewrites52.5%
if 3.4000000000000001e164 < y.re Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.1%
lift-pow.f64N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
lift-+.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6452.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6452.1%
Applied rewrites52.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (sqrt (+ (pow x.im 2) (pow x.re 2))) y.re))
(t_1 (* y.re (atan2 x.im x.re))))
(if (<= y.re -7253554917687775/4835703278458516698824704)
(* (sin (- (* 1/2 PI) t_1)) t_0)
(if (<=
y.re
7656353255721115/21267647932558653966460912964485513216)
(* (exp (- (* y.im (atan2 x.im x.re)))) 1)
(if (<=
y.re
340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760)
(* (sin (- t_1 (* -1/2 PI))) t_0)
(*
(pow (+ (* x.im x.im) (* x.re x.re)) (* y.re 1/2))
(cos (* (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 = pow(sqrt((pow(x_46_im, 2.0) + pow(x_46_re, 2.0))), y_46_re);
double t_1 = y_46_re * atan2(x_46_im, x_46_re);
double tmp;
if (y_46_re <= -1.5e-9) {
tmp = sin(((0.5 * ((double) M_PI)) - t_1)) * t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
} else if (y_46_re <= 3.4e+164) {
tmp = sin((t_1 - (-0.5 * ((double) M_PI)))) * t_0;
} else {
tmp = pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_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 t_0 = Math.pow(Math.sqrt((Math.pow(x_46_im, 2.0) + Math.pow(x_46_re, 2.0))), y_46_re);
double t_1 = y_46_re * Math.atan2(x_46_im, x_46_re);
double tmp;
if (y_46_re <= -1.5e-9) {
tmp = Math.sin(((0.5 * Math.PI) - t_1)) * t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
} else if (y_46_re <= 3.4e+164) {
tmp = Math.sin((t_1 - (-0.5 * Math.PI))) * t_0;
} else {
tmp = Math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.pow(math.sqrt((math.pow(x_46_im, 2.0) + math.pow(x_46_re, 2.0))), y_46_re) t_1 = y_46_re * math.atan2(x_46_im, x_46_re) tmp = 0 if y_46_re <= -1.5e-9: tmp = math.sin(((0.5 * math.pi) - t_1)) * t_0 elif y_46_re <= 3.6e-22: tmp = math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0 elif y_46_re <= 3.4e+164: tmp = math.sin((t_1 - (-0.5 * math.pi))) * t_0 else: tmp = math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = sqrt(Float64((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re t_1 = Float64(y_46_re * atan(x_46_im, x_46_re)) tmp = 0.0 if (y_46_re <= -1.5e-9) tmp = Float64(sin(Float64(Float64(0.5 * pi) - t_1)) * t_0); elseif (y_46_re <= 3.6e-22) tmp = Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); elseif (y_46_re <= 3.4e+164) tmp = Float64(sin(Float64(t_1 - Float64(-0.5 * pi))) * t_0); else tmp = Float64((Float64(Float64(x_46_im * x_46_im) + Float64(x_46_re * x_46_re)) ^ Float64(y_46_re * 0.5)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = sqrt(((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re; t_1 = y_46_re * atan2(x_46_im, x_46_re); tmp = 0.0; if (y_46_re <= -1.5e-9) tmp = sin(((0.5 * pi) - t_1)) * t_0; elseif (y_46_re <= 3.6e-22) tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0; elseif (y_46_re <= 3.4e+164) tmp = sin((t_1 - (-0.5 * pi))) * t_0; else tmp = (((x_46_im * x_46_im) + (x_46_re * x_46_re)) ^ (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Power[N[Sqrt[N[(N[Power[x$46$im, 2], $MachinePrecision] + N[Power[x$46$re, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -7253554917687775/4835703278458516698824704], N[(N[Sin[N[(N[(1/2 * Pi), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[y$46$re, 7656353255721115/21267647932558653966460912964485513216], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision], If[LessEqual[y$46$re, 340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760], N[(N[Sin[N[(t$95$1 - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Power[N[(N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(y$46$re * 1/2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := {\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}^{y.re}\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;y.re \leq \frac{-7253554917687775}{4835703278458516698824704}:\\
\;\;\;\;\sin \left(\frac{1}{2} \cdot \pi - t\_1\right) \cdot t\_0\\
\mathbf{elif}\;y.re \leq \frac{7656353255721115}{21267647932558653966460912964485513216}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{elif}\;y.re \leq 340000000000000010835684632195335587940734187291272085893391588303017776817771367411377474482174590749800488441601817097709833895132759223546687528950569012832501760:\\
\;\;\;\;\sin \left(t\_1 - \frac{-1}{2} \cdot \pi\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(x.im \cdot x.im + x.re \cdot x.re\right)}^{\left(y.re \cdot \frac{1}{2}\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\end{array}
if y.re < -1.5e-9Initial program 40.3%
Taylor expanded in x.im around -inf
lower-*.f6418.7%
Applied rewrites18.7%
Taylor expanded in x.im around -inf
lower-*.f6435.9%
Applied rewrites35.9%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
Applied rewrites35.6%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
Applied rewrites51.6%
if -1.5e-9 < y.re < 3.5999999999999998e-22Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
if 3.5999999999999998e-22 < y.re < 3.4000000000000001e164Initial program 40.3%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites40.1%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-pow.f64N/A
Applied rewrites52.5%
if 3.4000000000000001e164 < y.re Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.1%
lift-pow.f64N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
lift-+.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6452.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6452.1%
Applied rewrites52.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -7253554917687775/4835703278458516698824704)
(*
(sin (- (* 1/2 PI) (* y.re (atan2 x.im x.re))))
(pow (sqrt (+ (pow x.im 2) (pow x.re 2))) y.re))
(if (<=
y.re
7656353255721115/21267647932558653966460912964485513216)
(* (exp (- (* y.im (atan2 x.im x.re)))) 1)
(*
(pow (+ (* x.im x.im) (* x.re x.re)) (* y.re 1/2))
(cos (* (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 tmp;
if (y_46_re <= -1.5e-9) {
tmp = sin(((0.5 * ((double) M_PI)) - (y_46_re * atan2(x_46_im, x_46_re)))) * pow(sqrt((pow(x_46_im, 2.0) + pow(x_46_re, 2.0))), y_46_re);
} else if (y_46_re <= 3.6e-22) {
tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_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.5e-9) {
tmp = Math.sin(((0.5 * Math.PI) - (y_46_re * Math.atan2(x_46_im, x_46_re)))) * Math.pow(Math.sqrt((Math.pow(x_46_im, 2.0) + Math.pow(x_46_re, 2.0))), y_46_re);
} else if (y_46_re <= 3.6e-22) {
tmp = Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = Math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_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.5e-9: tmp = math.sin(((0.5 * math.pi) - (y_46_re * math.atan2(x_46_im, x_46_re)))) * math.pow(math.sqrt((math.pow(x_46_im, 2.0) + math.pow(x_46_re, 2.0))), y_46_re) elif y_46_re <= 3.6e-22: tmp = math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0 else: tmp = math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * math.cos((math.atan2(x_46_im, x_46_re) * y_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.5e-9) tmp = Float64(sin(Float64(Float64(0.5 * pi) - Float64(y_46_re * atan(x_46_im, x_46_re)))) * (sqrt(Float64((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re)); elseif (y_46_re <= 3.6e-22) tmp = Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); else tmp = Float64((Float64(Float64(x_46_im * x_46_im) + Float64(x_46_re * x_46_re)) ^ Float64(y_46_re * 0.5)) * cos(Float64(atan(x_46_im, x_46_re) * y_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.5e-9) tmp = sin(((0.5 * pi) - (y_46_re * atan2(x_46_im, x_46_re)))) * (sqrt(((x_46_im ^ 2.0) + (x_46_re ^ 2.0))) ^ y_46_re); elseif (y_46_re <= 3.6e-22) tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0; else tmp = (((x_46_im * x_46_im) + (x_46_re * x_46_re)) ^ (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -7253554917687775/4835703278458516698824704], N[(N[Sin[N[(N[(1/2 * Pi), $MachinePrecision] - N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[N[Sqrt[N[(N[Power[x$46$im, 2], $MachinePrecision] + N[Power[x$46$re, 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 7656353255721115/21267647932558653966460912964485513216], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision], N[(N[Power[N[(N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(y$46$re * 1/2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y.re \leq \frac{-7253554917687775}{4835703278458516698824704}:\\
\;\;\;\;\sin \left(\frac{1}{2} \cdot \pi - y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}^{y.re}\\
\mathbf{elif}\;y.re \leq \frac{7656353255721115}{21267647932558653966460912964485513216}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;{\left(x.im \cdot x.im + x.re \cdot x.re\right)}^{\left(y.re \cdot \frac{1}{2}\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\end{array}
if y.re < -1.5e-9Initial program 40.3%
Taylor expanded in x.im around -inf
lower-*.f6418.7%
Applied rewrites18.7%
Taylor expanded in x.im around -inf
lower-*.f6435.9%
Applied rewrites35.9%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
Applied rewrites35.6%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
Applied rewrites51.6%
if -1.5e-9 < y.re < 3.5999999999999998e-22Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
if 3.5999999999999998e-22 < y.re Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.1%
lift-pow.f64N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
lift-+.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6452.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6452.1%
Applied rewrites52.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(*
(pow (+ (* x.im x.im) (* x.re x.re)) (* y.re 1/2))
(cos (* (atan2 x.im x.re) y.re)))))
(if (<= y.re -7253554917687775/4835703278458516698824704)
t_0
(if (<=
y.re
7656353255721115/21267647932558653966460912964485513216)
(* (exp (- (* y.im (atan2 x.im x.re)))) 1)
t_0))))double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_re <= -1.5e-9) {
tmp = t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
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
real(8) :: tmp
t_0 = (((x_46im * x_46im) + (x_46re * x_46re)) ** (y_46re * 0.5d0)) * cos((atan2(x_46im, x_46re) * y_46re))
if (y_46re <= (-1.5d-9)) then
tmp = t_0
else if (y_46re <= 3.6d-22) then
tmp = exp(-(y_46im * atan2(x_46im, x_46re))) * 1.0d0
else
tmp = t_0
end if
code = tmp
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.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * Math.cos((Math.atan2(x_46_im, x_46_re) * y_46_re));
double tmp;
if (y_46_re <= -1.5e-9) {
tmp = t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.pow(((x_46_im * x_46_im) + (x_46_re * x_46_re)), (y_46_re * 0.5)) * math.cos((math.atan2(x_46_im, x_46_re) * y_46_re)) tmp = 0 if y_46_re <= -1.5e-9: tmp = t_0 elif y_46_re <= 3.6e-22: tmp = math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0 else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64((Float64(Float64(x_46_im * x_46_im) + Float64(x_46_re * x_46_re)) ^ Float64(y_46_re * 0.5)) * cos(Float64(atan(x_46_im, x_46_re) * y_46_re))) tmp = 0.0 if (y_46_re <= -1.5e-9) tmp = t_0; elseif (y_46_re <= 3.6e-22) tmp = Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = (((x_46_im * x_46_im) + (x_46_re * x_46_re)) ^ (y_46_re * 0.5)) * cos((atan2(x_46_im, x_46_re) * y_46_re)); tmp = 0.0; if (y_46_re <= -1.5e-9) tmp = t_0; elseif (y_46_re <= 3.6e-22) tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0; else tmp = 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[(N[Power[N[(N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(y$46$re * 1/2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -7253554917687775/4835703278458516698824704], t$95$0, If[LessEqual[y$46$re, 7656353255721115/21267647932558653966460912964485513216], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := {\left(x.im \cdot x.im + x.re \cdot x.re\right)}^{\left(y.re \cdot \frac{1}{2}\right)} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{if}\;y.re \leq \frac{-7253554917687775}{4835703278458516698824704}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq \frac{7656353255721115}{21267647932558653966460912964485513216}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y.re < -1.5e-9 or 3.5999999999999998e-22 < y.re Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.1%
lift-pow.f64N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
lift-+.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6452.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6452.1%
Applied rewrites52.1%
if -1.5e-9 < y.re < 3.5999999999999998e-22Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1 (pow (sqrt (pow x.im 2)) y.re))))
(if (<= y.re -360000)
t_0
(if (<=
y.re
7656353255721115/21267647932558653966460912964485513216)
(* (exp (- (* y.im (atan2 x.im x.re)))) 1)
t_0))))double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 1.0 * pow(sqrt(pow(x_46_im, 2.0)), y_46_re);
double tmp;
if (y_46_re <= -360000.0) {
tmp = t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
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
real(8) :: tmp
t_0 = 1.0d0 * (sqrt((x_46im ** 2.0d0)) ** y_46re)
if (y_46re <= (-360000.0d0)) then
tmp = t_0
else if (y_46re <= 3.6d-22) then
tmp = exp(-(y_46im * atan2(x_46im, x_46re))) * 1.0d0
else
tmp = t_0
end if
code = tmp
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 = 1.0 * Math.pow(Math.sqrt(Math.pow(x_46_im, 2.0)), y_46_re);
double tmp;
if (y_46_re <= -360000.0) {
tmp = t_0;
} else if (y_46_re <= 3.6e-22) {
tmp = Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = 1.0 * math.pow(math.sqrt(math.pow(x_46_im, 2.0)), y_46_re) tmp = 0 if y_46_re <= -360000.0: tmp = t_0 elif y_46_re <= 3.6e-22: tmp = math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0 else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(1.0 * (sqrt((x_46_im ^ 2.0)) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -360000.0) tmp = t_0; elseif (y_46_re <= 3.6e-22) tmp = Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 1.0 * (sqrt((x_46_im ^ 2.0)) ^ y_46_re); tmp = 0.0; if (y_46_re <= -360000.0) tmp = t_0; elseif (y_46_re <= 3.6e-22) tmp = exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0; else tmp = 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[(1 * N[Power[N[Sqrt[N[Power[x$46$im, 2], $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -360000], t$95$0, If[LessEqual[y$46$re, 7656353255721115/21267647932558653966460912964485513216], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{{x.im}^{2}}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -360000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq \frac{7656353255721115}{21267647932558653966460912964485513216}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y.re < -3.6e5 or 3.5999999999999998e-22 < y.re Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
Taylor expanded in y.re around 0
Applied rewrites26.5%
Taylor expanded in y.re around 0
Applied rewrites26.6%
Taylor expanded in x.re around 0
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-pow.f6445.2%
Applied rewrites45.2%
if -3.6e5 < y.re < 3.5999999999999998e-22Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (exp (- (* y.im (atan2 x.im x.re)))) 1))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp(-(y_46_im * atan2(x_46_im, x_46_re))) * 1.0;
}
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
code = exp(-(y_46im * atan2(x_46im, x_46re))) * 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 Math.exp(-(y_46_im * Math.atan2(x_46_im, x_46_re))) * 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.exp(-(y_46_im * math.atan2(x_46_im, x_46_re))) * 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(exp(Float64(-Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0) 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))) * 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1), $MachinePrecision]
e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1
Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* (+ 1 (* -1 (* y.im (atan2 x.im x.re)))) 1))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (1.0 + (-1.0 * (y_46_im * atan2(x_46_im, x_46_re)))) * 1.0;
}
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
code = (1.0d0 + ((-1.0d0) * (y_46im * atan2(x_46im, x_46re)))) * 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 + (-1.0 * (y_46_im * Math.atan2(x_46_im, x_46_re)))) * 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (1.0 + (-1.0 * (y_46_im * math.atan2(x_46_im, x_46_re)))) * 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(1.0 + Float64(-1.0 * Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (1.0 + (-1.0 * (y_46_im * atan2(x_46_im, x_46_re)))) * 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(1 + N[(-1 * N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1), $MachinePrecision]
\left(1 + -1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot 1
Initial program 40.3%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f6461.7%
Applied rewrites61.7%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-atan2.f6453.1%
Applied rewrites53.1%
Taylor expanded in y.re around 0
Applied rewrites53.4%
Taylor expanded in y.im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-atan2.f6426.7%
Applied rewrites26.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 1 1))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0 * 1.0;
}
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
code = 1.0d0 * 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 * 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0 * 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(1.0 * 1.0) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0 * 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(1 * 1), $MachinePrecision]
1 \cdot 1
Initial program 40.3%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-pow.f64N/A
lower-pow.f6452.1%
Applied rewrites52.1%
Taylor expanded in y.re around 0
Applied rewrites26.5%
Taylor expanded in y.re around 0
Applied rewrites26.6%
herbie shell --seed 2025285 -o generate:evaluate
(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)))))