
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
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 (* y.im (atan2 x.im x.re)))
(t_1 (log (fabs x.im)))
(t_2 (* y.re (atan2 x.im x.re)))
(t_3 (log (/ -1.0 x.re))))
(if (<= x.re -4.7e-59)
(*
(exp (- (* -1.0 (* y.re t_3)) t_0))
(sin (fma -1.0 (* y.im t_3) (fma 0.5 PI t_2))))
(if (<= x.re 3800000000.0)
(* (cos (fma y.im t_1 t_2)) (exp (- (* y.re t_1) t_0)))
(*
(exp (- (* y.re (log x.re)) t_0))
(sin (fma 0.5 PI (fma y.im (log x.re) t_2))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = y_46_im * atan2(x_46_im, x_46_re);
double t_1 = log(fabs(x_46_im));
double t_2 = y_46_re * atan2(x_46_im, x_46_re);
double t_3 = log((-1.0 / x_46_re));
double tmp;
if (x_46_re <= -4.7e-59) {
tmp = exp(((-1.0 * (y_46_re * t_3)) - t_0)) * sin(fma(-1.0, (y_46_im * t_3), fma(0.5, ((double) M_PI), t_2)));
} else if (x_46_re <= 3800000000.0) {
tmp = cos(fma(y_46_im, t_1, t_2)) * exp(((y_46_re * t_1) - t_0));
} else {
tmp = exp(((y_46_re * log(x_46_re)) - t_0)) * sin(fma(0.5, ((double) M_PI), fma(y_46_im, log(x_46_re), t_2)));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_1 = log(abs(x_46_im)) t_2 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_3 = log(Float64(-1.0 / x_46_re)) tmp = 0.0 if (x_46_re <= -4.7e-59) tmp = Float64(exp(Float64(Float64(-1.0 * Float64(y_46_re * t_3)) - t_0)) * sin(fma(-1.0, Float64(y_46_im * t_3), fma(0.5, pi, t_2)))); elseif (x_46_re <= 3800000000.0) tmp = Float64(cos(fma(y_46_im, t_1, t_2)) * exp(Float64(Float64(y_46_re * t_1) - t_0))); else tmp = Float64(exp(Float64(Float64(y_46_re * log(x_46_re)) - t_0)) * sin(fma(0.5, pi, fma(y_46_im, log(x_46_re), t_2)))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[Abs[x$46$im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Log[N[(-1.0 / x$46$re), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$re, -4.7e-59], N[(N[Exp[N[(N[(-1.0 * N[(y$46$re * t$95$3), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-1.0 * N[(y$46$im * t$95$3), $MachinePrecision] + N[(0.5 * Pi + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 3800000000.0], N[(N[Cos[N[(y$46$im * t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(y$46$re * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi + N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \log \left(\left|x.im\right|\right)\\
t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_3 := \log \left(\frac{-1}{x.re}\right)\\
\mathbf{if}\;x.re \leq -4.7 \cdot 10^{-59}:\\
\;\;\;\;e^{-1 \cdot \left(y.re \cdot t\_3\right) - t\_0} \cdot \sin \left(\mathsf{fma}\left(-1, y.im \cdot t\_3, \mathsf{fma}\left(0.5, \pi, t\_2\right)\right)\right)\\
\mathbf{elif}\;x.re \leq 3800000000:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, t\_1, t\_2\right)\right) \cdot e^{y.re \cdot t\_1 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, \mathsf{fma}\left(y.im, \log x.re, t\_2\right)\right)\right)\\
\end{array}
\end{array}
if x.re < -4.6999999999999999e-59Initial program 41.4%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-atan2.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites41.5%
Taylor expanded in x.re around -inf
sin-+PI/2-revN/A
lower-*.f64N/A
Applied rewrites36.6%
if -4.6999999999999999e-59 < x.re < 3.8e9Initial program 41.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
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6470.7
Applied rewrites70.7%
if 3.8e9 < x.re Initial program 41.4%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-atan2.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites41.5%
Taylor expanded in x.im around 0
sin-+PI/2-revN/A
lower-*.f64N/A
Applied rewrites36.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* y.re (atan2 x.im x.re)))
(t_1 (* y.im (atan2 x.im x.re)))
(t_2 (log (* -1.0 x.re)))
(t_3 (log (fabs x.im))))
(if (<= x.re -4.3e-14)
(*
(exp (- (* t_2 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_2 y.im) (* (atan2 x.im x.re) y.re))))
(if (<= x.re 3800000000.0)
(* (cos (fma y.im t_3 t_0)) (exp (- (* y.re t_3) t_1)))
(*
(exp (- (* y.re (log x.re)) t_1))
(sin (fma 0.5 PI (fma y.im (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 = y_46_re * atan2(x_46_im, x_46_re);
double t_1 = y_46_im * atan2(x_46_im, x_46_re);
double t_2 = log((-1.0 * x_46_re));
double t_3 = log(fabs(x_46_im));
double tmp;
if (x_46_re <= -4.3e-14) {
tmp = exp(((t_2 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_2 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
} else if (x_46_re <= 3800000000.0) {
tmp = cos(fma(y_46_im, t_3, t_0)) * exp(((y_46_re * t_3) - t_1));
} else {
tmp = exp(((y_46_re * log(x_46_re)) - t_1)) * sin(fma(0.5, ((double) M_PI), fma(y_46_im, log(x_46_re), t_0)));
}
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)) t_1 = Float64(y_46_im * atan(x_46_im, x_46_re)) t_2 = log(Float64(-1.0 * x_46_re)) t_3 = log(abs(x_46_im)) tmp = 0.0 if (x_46_re <= -4.3e-14) tmp = Float64(exp(Float64(Float64(t_2 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_2 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))); elseif (x_46_re <= 3800000000.0) tmp = Float64(cos(fma(y_46_im, t_3, t_0)) * exp(Float64(Float64(y_46_re * t_3) - t_1))); else tmp = Float64(exp(Float64(Float64(y_46_re * log(x_46_re)) - t_1)) * sin(fma(0.5, pi, fma(y_46_im, 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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[(-1.0 * x$46$re), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Log[N[Abs[x$46$im], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$re, -4.3e-14], N[(N[Exp[N[(N[(t$95$2 * 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$2 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 3800000000.0], N[(N[Cos[N[(y$46$im * t$95$3 + t$95$0), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(y$46$re * t$95$3), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi + N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := \log \left(-1 \cdot x.re\right)\\
t_3 := \log \left(\left|x.im\right|\right)\\
\mathbf{if}\;x.re \leq -4.3 \cdot 10^{-14}:\\
\;\;\;\;e^{t\_2 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_2 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\
\mathbf{elif}\;x.re \leq 3800000000:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, t\_3, t\_0\right)\right) \cdot e^{y.re \cdot t\_3 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - t\_1} \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, \mathsf{fma}\left(y.im, \log x.re, t\_0\right)\right)\right)\\
\end{array}
\end{array}
if x.re < -4.29999999999999998e-14Initial program 41.4%
Taylor expanded in x.re around -inf
lower-*.f6418.6
Applied rewrites18.6%
Taylor expanded in x.re around -inf
lower-*.f6436.7
Applied rewrites36.7%
if -4.29999999999999998e-14 < x.re < 3.8e9Initial program 41.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
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6470.7
Applied rewrites70.7%
if 3.8e9 < x.re Initial program 41.4%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-atan2.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
Applied rewrites41.5%
Taylor expanded in x.im around 0
sin-+PI/2-revN/A
lower-*.f64N/A
Applied rewrites36.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (fabs x.im)))
(t_1 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_2 (exp (- (* t_1 y.re) (* (atan2 x.im x.re) y.im)))))
(if (<= (* t_2 (cos (+ (* t_1 y.im) (* (atan2 x.im x.re) y.re)))) INFINITY)
(* t_2 (cos (* y.im (log (sqrt (fma x.im x.im (* x.re x.re)))))))
(*
(cos (fma y.im t_0 (* y.re (atan2 x.im x.re))))
(exp (- (* y.re t_0) (* 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 = log(fabs(x_46_im));
double t_1 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_2 = exp(((t_1 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
double tmp;
if ((t_2 * cos(((t_1 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)))) <= ((double) INFINITY)) {
tmp = t_2 * cos((y_46_im * log(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))))));
} else {
tmp = cos(fma(y_46_im, t_0, (y_46_re * atan2(x_46_im, x_46_re)))) * exp(((y_46_re * t_0) - (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 = log(abs(x_46_im)) t_1 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_2 = exp(Float64(Float64(t_1 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) tmp = 0.0 if (Float64(t_2 * cos(Float64(Float64(t_1 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) <= Inf) tmp = Float64(t_2 * cos(Float64(y_46_im * log(sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))))))); else tmp = Float64(cos(fma(y_46_im, t_0, Float64(y_46_re * atan(x_46_im, x_46_re)))) * exp(Float64(Float64(y_46_re * t_0) - 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[Log[N[Abs[x$46$im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = 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$2 = N[Exp[N[(N[(t$95$1 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 * N[Cos[N[(N[(t$95$1 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$2 * N[Cos[N[(y$46$im * N[Log[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * t$95$0 + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - 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 := \log \left(\left|x.im\right|\right)\\
t_1 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_2 := e^{t\_1 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{if}\;t\_2 \cdot \cos \left(t\_1 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \leq \infty:\\
\;\;\;\;t\_2 \cdot \cos \left(y.im \cdot \log \left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, t\_0, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot t\_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\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 41.4%
Taylor expanded in y.re around 0
lower-*.f64N/A
lower-log.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6442.4
Applied rewrites42.4%
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 41.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
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lift-atan2.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6434.8
Applied rewrites34.8%
lift-log.f64N/A
log-fabsN/A
lower-log.f64N/A
lower-fabs.f6470.7
Applied rewrites70.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
1.0)))
(if (<= y.re -1.7e-11)
t_0
(if (<= y.re 4.6e-33) (* (exp (- (* y.im (atan2 x.im x.re)))) 1.0) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = 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))) * 1.0;
double tmp;
if (y_46_re <= -1.7e-11) {
tmp = t_0;
} else if (y_46_re <= 4.6e-33) {
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 = exp(((log(sqrt(((x_46re * x_46re) + (x_46im * x_46im)))) * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * 1.0d0
if (y_46re <= (-1.7d-11)) then
tmp = t_0
else if (y_46re <= 4.6d-33) 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.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))) * 1.0;
double tmp;
if (y_46_re <= -1.7e-11) {
tmp = t_0;
} else if (y_46_re <= 4.6e-33) {
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.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))) * 1.0 tmp = 0 if y_46_re <= -1.7e-11: tmp = t_0 elif y_46_re <= 4.6e-33: 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(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))) * 1.0) tmp = 0.0 if (y_46_re <= -1.7e-11) tmp = t_0; elseif (y_46_re <= 4.6e-33) 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 = 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))) * 1.0; tmp = 0.0; if (y_46_re <= -1.7e-11) tmp = t_0; elseif (y_46_re <= 4.6e-33) 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[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] * 1.0), $MachinePrecision]}, If[LessEqual[y$46$re, -1.7e-11], t$95$0, If[LessEqual[y$46$re, 4.6e-33], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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 1\\
\mathbf{if}\;y.re \leq -1.7 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 4.6 \cdot 10^{-33}:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.6999999999999999e-11 or 4.59999999999999971e-33 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f6462.2
Applied rewrites62.2%
Taylor expanded in y.re around 0
Applied rewrites64.3%
if -1.6999999999999999e-11 < y.re < 4.59999999999999971e-33Initial program 41.4%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f6462.2
Applied rewrites62.2%
Taylor expanded in y.re around 0
Applied rewrites64.3%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lift-atan2.f64N/A
lift-*.f6452.7
Applied rewrites52.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -1.85e-11)
t_0
(if (<= y.re 60000.0) (* (exp (- (* y.im (atan2 x.im x.re)))) 1.0) 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(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -1.85e-11) {
tmp = t_0;
} else if (y_46_re <= 60000.0) {
tmp = exp(-(y_46_im * 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(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -1.85e-11) tmp = t_0; elseif (y_46_re <= 60000.0) 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
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.85e-11], t$95$0, If[LessEqual[y$46$re, 60000.0], N[(N[Exp[(-N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision])], $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.85 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 60000:\\
\;\;\;\;e^{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.8500000000000001e-11 or 6e4 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
Applied rewrites54.0%
if -1.8500000000000001e-11 < y.re < 6e4Initial program 41.4%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f6462.2
Applied rewrites62.2%
Taylor expanded in y.re around 0
Applied rewrites64.3%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lift-atan2.f64N/A
lift-*.f6452.7
Applied rewrites52.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* 1.0 (pow (sqrt (fma x.im x.im (* x.re x.re))) y.re))))
(if (<= y.re -1.25e-49)
t_0
(if (<= y.re 1.45e-24)
(* (+ 1.0 (* -1.0 (* y.im (atan2 x.im x.re)))) 1.0)
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(fma(x_46_im, x_46_im, (x_46_re * x_46_re))), y_46_re);
double tmp;
if (y_46_re <= -1.25e-49) {
tmp = t_0;
} else if (y_46_re <= 1.45e-24) {
tmp = (1.0 + (-1.0 * (y_46_im * 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(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))) ^ y_46_re)) tmp = 0.0 if (y_46_re <= -1.25e-49) tmp = t_0; elseif (y_46_re <= 1.45e-24) tmp = Float64(Float64(1.0 + Float64(-1.0 * Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 * N[Power[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.25e-49], t$95$0, If[LessEqual[y$46$re, 1.45e-24], N[(N[(1.0 + N[(-1.0 * N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot {\left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.25 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.45 \cdot 10^{-24}:\\
\;\;\;\;\left(1 + -1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.25e-49 or 1.4499999999999999e-24 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
Applied rewrites54.0%
if -1.25e-49 < y.re < 1.4499999999999999e-24Initial program 41.4%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f6462.2
Applied rewrites62.2%
Taylor expanded in y.re around 0
Applied rewrites64.3%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lift-atan2.f64N/A
lift-*.f6452.7
Applied rewrites52.7%
Taylor expanded in y.im around 0
lower-+.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lift-*.f6425.8
Applied rewrites25.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re 1.45e-24) (* (+ 1.0 (* -1.0 (* y.im (atan2 x.im x.re)))) 1.0) (+ 1.0 (* y.re (log (sqrt (fma x.im x.im (* x.re x.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= 1.45e-24) {
tmp = (1.0 + (-1.0 * (y_46_im * atan2(x_46_im, x_46_re)))) * 1.0;
} else {
tmp = 1.0 + (y_46_re * log(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re)))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 1.45e-24) tmp = Float64(Float64(1.0 + Float64(-1.0 * Float64(y_46_im * atan(x_46_im, x_46_re)))) * 1.0); else tmp = Float64(1.0 + Float64(y_46_re * log(sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 1.45e-24], N[(N[(1.0 + N[(-1.0 * N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(1.0 + N[(y$46$re * N[Log[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 1.45 \cdot 10^{-24}:\\
\;\;\;\;\left(1 + -1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;1 + y.re \cdot \log \left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)\\
\end{array}
\end{array}
if y.re < 1.4499999999999999e-24Initial program 41.4%
Taylor expanded in y.im around 0
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f6462.2
Applied rewrites62.2%
Taylor expanded in y.re around 0
Applied rewrites64.3%
Taylor expanded in y.re around 0
lower-exp.f64N/A
lower-neg.f64N/A
lift-atan2.f64N/A
lift-*.f6452.7
Applied rewrites52.7%
Taylor expanded in y.im around 0
lower-+.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lift-*.f6425.8
Applied rewrites25.8%
if 1.4499999999999999e-24 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re 1.45e-24) 1.0 (+ 1.0 (* y.re (log (sqrt (fma x.im x.im (* x.re x.re))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= 1.45e-24) {
tmp = 1.0;
} else {
tmp = 1.0 + (y_46_re * log(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re)))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 1.45e-24) tmp = 1.0; else tmp = Float64(1.0 + Float64(y_46_re * log(sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 1.45e-24], 1.0, N[(1.0 + N[(y$46$re * N[Log[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 1.45 \cdot 10^{-24}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + y.re \cdot \log \left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)\\
\end{array}
\end{array}
if y.re < 1.4499999999999999e-24Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
Taylor expanded in x.re around 0
lower-+.f64N/A
lift-log.f64N/A
lift-*.f6412.7
Applied rewrites12.7%
Taylor expanded in y.re around 0
Applied rewrites25.7%
if 1.4499999999999999e-24 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re 2.6e+15) 1.0 (* y.re (log (sqrt (fma x.im x.im (* x.re x.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= 2.6e+15) {
tmp = 1.0;
} else {
tmp = y_46_re * log(sqrt(fma(x_46_im, x_46_im, (x_46_re * x_46_re))));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= 2.6e+15) tmp = 1.0; else tmp = Float64(y_46_re * log(sqrt(fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re))))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, 2.6e+15], 1.0, N[(y$46$re * N[Log[N[Sqrt[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq 2.6 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;y.re \cdot \log \left(\sqrt{\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)}\right)\\
\end{array}
\end{array}
if y.re < 2.6e15Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
Taylor expanded in x.re around 0
lower-+.f64N/A
lift-log.f64N/A
lift-*.f6412.7
Applied rewrites12.7%
Taylor expanded in y.re around 0
Applied rewrites25.7%
if 2.6e15 < y.re Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
Taylor expanded in x.re around 0
lower-+.f64N/A
lift-log.f64N/A
lift-*.f6412.7
Applied rewrites12.7%
Taylor expanded in y.re around inf
lower-*.f64N/A
pow2N/A
pow2N/A
lower-log.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6412.6
Applied rewrites12.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 1.0)
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
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
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return 1.0;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return 1.0
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 1.0 end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 1.0; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 41.4%
Taylor expanded in y.im around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-atan2.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sqrt.f6424.4
Applied rewrites24.4%
Taylor expanded in x.re around 0
lower-+.f64N/A
lift-log.f64N/A
lift-*.f6412.7
Applied rewrites12.7%
Taylor expanded in y.re around 0
Applied rewrites25.7%
herbie shell --seed 2025132
(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)))))