
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
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 = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
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 = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
(if (<= y.im -1.95e+52)
(fma (/ x.re y.im) (/ y.re y.im) (/ x.im y.im))
(if (<= y.im -1.1e-174)
t_0
(if (<= y.im 6.2e-18)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(if (<= y.im 5.2e+97)
t_0
(/
(fma
(fma (* x.im (/ (/ y.re y.im) y.im)) -1.0 (/ x.re y.im))
y.re
x.im)
y.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -1.95e+52) {
tmp = fma((x_46_re / y_46_im), (y_46_re / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= -1.1e-174) {
tmp = t_0;
} else if (y_46_im <= 6.2e-18) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_im <= 5.2e+97) {
tmp = t_0;
} else {
tmp = fma(fma((x_46_im * ((y_46_re / y_46_im) / y_46_im)), -1.0, (x_46_re / y_46_im)), y_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) tmp = 0.0 if (y_46_im <= -1.95e+52) tmp = fma(Float64(x_46_re / y_46_im), Float64(y_46_re / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= -1.1e-174) tmp = t_0; elseif (y_46_im <= 6.2e-18) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_im <= 5.2e+97) tmp = t_0; else tmp = Float64(fma(fma(Float64(x_46_im * Float64(Float64(y_46_re / y_46_im) / y_46_im)), -1.0, Float64(x_46_re / y_46_im)), y_46_re, x_46_im) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.95e+52], N[(N[(x$46$re / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -1.1e-174], t$95$0, If[LessEqual[y$46$im, 6.2e-18], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+97], t$95$0, N[(N[(N[(N[(x$46$im * N[(N[(y$46$re / y$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;y.im \leq -1.95 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.re}{y.im}, \frac{y.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq -1.1 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 6.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x.im \cdot \frac{\frac{y.re}{y.im}}{y.im}, -1, \frac{x.re}{y.im}\right), y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -1.95e52Initial program 47.7%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
if -1.95e52 < y.im < -1.10000000000000011e-174 or 6.20000000000000014e-18 < y.im < 5.2e97Initial program 76.6%
if -1.10000000000000011e-174 < y.im < 6.20000000000000014e-18Initial program 72.2%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
if 5.2e97 < y.im Initial program 40.2%
Taylor expanded in y.im around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6421.1
Applied rewrites21.1%
Taylor expanded in y.im around inf
lower-/.f64N/A
Applied rewrites82.6%
Taylor expanded in y.re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f64N/A
lower-/.f6483.6
Applied rewrites83.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
(t_1 (fma (/ x.re y.im) (/ y.re y.im) (/ x.im y.im))))
(if (<= y.im -1.95e+52)
t_1
(if (<= y.im -1.1e-174)
t_0
(if (<= y.im 6.2e-18)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(if (<= y.im 5.2e+97) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = fma((x_46_re / y_46_im), (y_46_re / y_46_im), (x_46_im / y_46_im));
double tmp;
if (y_46_im <= -1.95e+52) {
tmp = t_1;
} else if (y_46_im <= -1.1e-174) {
tmp = t_0;
} else if (y_46_im <= 6.2e-18) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_im <= 5.2e+97) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) t_1 = fma(Float64(x_46_re / y_46_im), Float64(y_46_re / y_46_im), Float64(x_46_im / y_46_im)) tmp = 0.0 if (y_46_im <= -1.95e+52) tmp = t_1; elseif (y_46_im <= -1.1e-174) tmp = t_0; elseif (y_46_im <= 6.2e-18) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_im <= 5.2e+97) tmp = t_0; else tmp = t_1; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.95e+52], t$95$1, If[LessEqual[y$46$im, -1.1e-174], t$95$0, If[LessEqual[y$46$im, 6.2e-18], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+97], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \mathsf{fma}\left(\frac{x.re}{y.im}, \frac{y.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{if}\;y.im \leq -1.95 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -1.1 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 6.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -1.95e52 or 5.2e97 < y.im Initial program 44.2%
Taylor expanded in y.re around 0
+-commutativeN/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6482.8
Applied rewrites82.8%
if -1.95e52 < y.im < -1.10000000000000011e-174 or 6.20000000000000014e-18 < y.im < 5.2e97Initial program 76.6%
if -1.10000000000000011e-174 < y.im < 6.20000000000000014e-18Initial program 72.2%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
(t_1 (/ (fma x.re (/ y.re y.im) x.im) y.im)))
(if (<= y.im -1.95e+52)
t_1
(if (<= y.im -1.1e-174)
t_0
(if (<= y.im 6.2e-18)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(if (<= y.im 5.2e+97) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -1.95e+52) {
tmp = t_1;
} else if (y_46_im <= -1.1e-174) {
tmp = t_0;
} else if (y_46_im <= 6.2e-18) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_im <= 5.2e+97) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) t_1 = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -1.95e+52) tmp = t_1; elseif (y_46_im <= -1.1e-174) tmp = t_0; elseif (y_46_im <= 6.2e-18) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_im <= 5.2e+97) tmp = t_0; else tmp = t_1; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.95e+52], t$95$1, If[LessEqual[y$46$im, -1.1e-174], t$95$0, If[LessEqual[y$46$im, 6.2e-18], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+97], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -1.95 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -1.1 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 6.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -1.95e52 or 5.2e97 < y.im Initial program 44.2%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
if -1.95e52 < y.im < -1.10000000000000011e-174 or 6.20000000000000014e-18 < y.im < 5.2e97Initial program 76.6%
if -1.10000000000000011e-174 < y.im < 6.20000000000000014e-18Initial program 72.2%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2.9e+97)
(/ x.re y.re)
(if (<= y.re -4.2e+84)
(/ x.im y.im)
(if (<= y.re -1e-76)
(* x.re (/ y.re (fma y.im y.im (* y.re y.re))))
(if (<= y.re 1000.0) (/ x.im y.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 <= -2.9e+97) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= -4.2e+84) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= -1e-76) {
tmp = x_46_re * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else if (y_46_re <= 1000.0) {
tmp = x_46_im / y_46_im;
} else {
tmp = 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 <= -2.9e+97) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= -4.2e+84) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= -1e-76) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); elseif (y_46_re <= 1000.0) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(x_46_re / y_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.9e+97], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -4.2e+84], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, -1e-76], N[(x$46$re * N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1000.0], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.9 \cdot 10^{+97}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq -4.2 \cdot 10^{+84}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq -1 \cdot 10^{-76}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{elif}\;y.re \leq 1000:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -2.89999999999999987e97 or 1e3 < y.re Initial program 46.2%
Taylor expanded in y.re around inf
lower-/.f6470.1
Applied rewrites70.1%
if -2.89999999999999987e97 < y.re < -4.20000000000000037e84 or -9.99999999999999927e-77 < y.re < 1e3Initial program 74.1%
Taylor expanded in y.re around 0
lower-/.f6467.0
Applied rewrites67.0%
if -4.20000000000000037e84 < y.re < -9.99999999999999927e-77Initial program 76.5%
Taylor expanded in x.re around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6453.6
Applied rewrites53.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re)))
(if (<= y.re -800000000.0)
t_0
(if (<= y.re 6.5e-68) (/ (fma x.re (/ y.re y.im) x.im) y.im) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -800000000.0) {
tmp = t_0;
} else if (y_46_re <= 6.5e-68) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -800000000.0) tmp = t_0; elseif (y_46_re <= 6.5e-68) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); 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[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -800000000.0], t$95$0, If[LessEqual[y$46$re, 6.5e-68], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -800000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 6.5 \cdot 10^{-68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -8e8 or 6.4999999999999997e-68 < y.re Initial program 52.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6472.8
Applied rewrites72.8%
if -8e8 < y.re < 6.4999999999999997e-68Initial program 74.9%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.9e+50)
(/ x.im y.im)
(if (<= y.im 5.8e+132)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(/ x.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -3.9e+50) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 5.8e+132) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -3.9e+50) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 5.8e+132) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -3.9e+50], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 5.8e+132], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.9 \cdot 10^{+50}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -3.89999999999999967e50 or 5.7999999999999997e132 < y.im Initial program 42.0%
Taylor expanded in y.re around 0
lower-/.f6473.3
Applied rewrites73.3%
if -3.89999999999999967e50 < y.im < 5.7999999999999997e132Initial program 73.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6471.8
Applied rewrites71.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.1e+50)
(/ x.im y.im)
(if (<= y.im -1.6e-195)
(/ (fma y.re x.re (* y.im x.im)) (* y.re y.re))
(if (<= y.im 5.8e+132) (/ x.re y.re) (/ x.im y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -3.1e+50) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -1.6e-195) {
tmp = fma(y_46_re, x_46_re, (y_46_im * x_46_im)) / (y_46_re * y_46_re);
} else if (y_46_im <= 5.8e+132) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -3.1e+50) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -1.6e-195) tmp = Float64(fma(y_46_re, x_46_re, Float64(y_46_im * x_46_im)) / Float64(y_46_re * y_46_re)); elseif (y_46_im <= 5.8e+132) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -3.1e+50], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -1.6e-195], N[(N[(y$46$re * x$46$re + N[(y$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.8e+132], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.1 \cdot 10^{+50}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -1.6 \cdot 10^{-195}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)}{y.re \cdot y.re}\\
\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -3.10000000000000003e50 or 5.7999999999999997e132 < y.im Initial program 42.1%
Taylor expanded in y.re around 0
lower-/.f6473.4
Applied rewrites73.4%
if -3.10000000000000003e50 < y.im < -1.6000000000000001e-195Initial program 76.4%
Taylor expanded in y.re around inf
pow2N/A
lift-*.f6448.6
Applied rewrites48.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6448.6
Applied rewrites48.6%
if -1.6000000000000001e-195 < y.im < 5.7999999999999997e132Initial program 72.8%
Taylor expanded in y.re around inf
lower-/.f6457.9
Applied rewrites57.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -2.4e+49)
(/ x.im y.im)
(if (<= y.im -3e-185)
(* x.im (/ y.im (fma y.im y.im (* y.re y.re))))
(if (<= y.im 5.8e+132) (/ x.re y.re) (/ x.im y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -2.4e+49) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -3e-185) {
tmp = x_46_im * (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else if (y_46_im <= 5.8e+132) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -2.4e+49) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -3e-185) tmp = Float64(x_46_im * Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); elseif (y_46_im <= 5.8e+132) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -2.4e+49], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -3e-185], N[(x$46$im * N[(y$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.8e+132], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.4 \cdot 10^{+49}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -3 \cdot 10^{-185}:\\
\;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -2.4e49 or 5.7999999999999997e132 < y.im Initial program 42.2%
Taylor expanded in y.re around 0
lower-/.f6473.2
Applied rewrites73.2%
if -2.4e49 < y.im < -3.0000000000000003e-185Initial program 76.6%
Taylor expanded in x.re around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6447.6
Applied rewrites47.6%
if -3.0000000000000003e-185 < y.im < 5.7999999999999997e132Initial program 72.7%
Taylor expanded in y.re around inf
lower-/.f6458.2
Applied rewrites58.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -540000000.0)
(/ x.re y.re)
(if (<= y.re 130.0)
(/ (fma y.im x.im (* y.re x.re)) (* y.im y.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 <= -540000000.0) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 130.0) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / (y_46_im * y_46_im);
} else {
tmp = 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 <= -540000000.0) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 130.0) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / Float64(y_46_im * y_46_im)); else tmp = Float64(x_46_re / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -540000000.0], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 130.0], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -540000000:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 130:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -5.4e8 or 130 < y.re Initial program 50.0%
Taylor expanded in y.re around inf
lower-/.f6466.0
Applied rewrites66.0%
if -5.4e8 < y.re < 130Initial program 75.0%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.0
Applied rewrites80.0%
Taylor expanded in y.im around 0
+-commutativeN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-*.f6459.1
Applied rewrites59.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -9.4e-11) (/ x.re y.re) (if (<= y.re 1000.0) (/ x.im y.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 <= -9.4e-11) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 1000.0) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
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) :: tmp
if (y_46re <= (-9.4d-11)) then
tmp = x_46re / y_46re
else if (y_46re <= 1000.0d0) then
tmp = x_46im / y_46im
else
tmp = x_46re / y_46re
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 tmp;
if (y_46_re <= -9.4e-11) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 1000.0) {
tmp = x_46_im / y_46_im;
} else {
tmp = 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 <= -9.4e-11: tmp = x_46_re / y_46_re elif y_46_re <= 1000.0: tmp = x_46_im / y_46_im else: tmp = 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 <= -9.4e-11) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 1000.0) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(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 <= -9.4e-11) tmp = x_46_re / y_46_re; elseif (y_46_re <= 1000.0) tmp = x_46_im / y_46_im; else tmp = 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, -9.4e-11], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1000.0], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.4 \cdot 10^{-11}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 1000:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -9.39999999999999985e-11 or 1e3 < y.re Initial program 50.9%
Taylor expanded in y.re around inf
lower-/.f6465.0
Applied rewrites65.0%
if -9.39999999999999985e-11 < y.re < 1e3Initial program 75.0%
Taylor expanded in y.re around 0
lower-/.f6464.7
Applied rewrites64.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
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 = x_46im / y_46im
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_im) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.im}
\end{array}
Initial program 62.9%
Taylor expanded in y.re around 0
lower-/.f6443.3
Applied rewrites43.3%
herbie shell --seed 2025093
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, real part"
:precision binary64
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))