
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * 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.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * 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.im \cdot y.re - x.re \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
(if (<= y.im -9.5e+136)
(/ (fma y.re (/ x.im y.im) (- x.re)) y.im)
(if (<= y.im -3.5e-18)
(*
(/ (fma x.im (/ y.re x.re) (- y.im)) (fma y.im y.im (* y.re y.re)))
x.re)
(if (<= y.im 5.6e-123)
(/ (fma x.re (/ y.im y.re) (- x.im)) (- y.re))
(if (<= y.im 2e+146)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
(/ (fma x.im (/ y.re y.im) (- x.re)) 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 <= -9.5e+136) {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_im <= -3.5e-18) {
tmp = (fma(x_46_im, (y_46_re / x_46_re), -y_46_im) / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_re;
} else if (y_46_im <= 5.6e-123) {
tmp = fma(x_46_re, (y_46_im / y_46_re), -x_46_im) / -y_46_re;
} else if (y_46_im <= 2e+146) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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 <= -9.5e+136) tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_im <= -3.5e-18) tmp = Float64(Float64(fma(x_46_im, Float64(y_46_re / x_46_re), Float64(-y_46_im)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_re); elseif (y_46_im <= 5.6e-123) tmp = Float64(fma(x_46_re, Float64(y_46_im / y_46_re), Float64(-x_46_im)) / Float64(-y_46_re)); elseif (y_46_im <= 2e+146) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); else tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / 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, -9.5e+136], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -3.5e-18], N[(N[(N[(x$46$im * N[(y$46$re / x$46$re), $MachinePrecision] + (-y$46$im)), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.6e-123], N[(N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision], If[LessEqual[y$46$im, 2e+146], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -9.5 \cdot 10^{+136}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.im \leq -3.5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{x.re}, -y.im\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.re\\
\mathbf{elif}\;y.im \leq 5.6 \cdot 10^{-123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.im}{y.re}, -x.im\right)}{-y.re}\\
\mathbf{elif}\;y.im \leq 2 \cdot 10^{+146}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -9.49999999999999907e136Initial program 36.8%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6427.8
Applied rewrites27.8%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6485.3
Applied rewrites85.3%
if -9.49999999999999907e136 < y.im < -3.4999999999999999e-18Initial program 59.4%
Taylor expanded in x.re around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.1%
if -3.4999999999999999e-18 < y.im < 5.5999999999999998e-123Initial program 74.7%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6491.3
Applied rewrites91.3%
if 5.5999999999999998e-123 < y.im < 1.99999999999999987e146Initial program 79.4%
if 1.99999999999999987e146 < y.im Initial program 23.3%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6486.9
Applied rewrites86.9%
Final simplification85.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -180.0)
(/ (fma y.re (/ x.im y.im) (- x.re)) y.im)
(if (<= y.im 5.6e-123)
(/ (fma x.re (/ y.im y.re) (- x.im)) (- y.re))
(if (<= y.im 2e+146)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
(/ (fma x.im (/ y.re y.im) (- x.re)) 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 <= -180.0) {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_im <= 5.6e-123) {
tmp = fma(x_46_re, (y_46_im / y_46_re), -x_46_im) / -y_46_re;
} else if (y_46_im <= 2e+146) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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 <= -180.0) tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_im <= 5.6e-123) tmp = Float64(fma(x_46_re, Float64(y_46_im / y_46_re), Float64(-x_46_im)) / Float64(-y_46_re)); elseif (y_46_im <= 2e+146) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); else tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / 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, -180.0], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 5.6e-123], N[(N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision], If[LessEqual[y$46$im, 2e+146], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -180:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.im \leq 5.6 \cdot 10^{-123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.im}{y.re}, -x.im\right)}{-y.re}\\
\mathbf{elif}\;y.im \leq 2 \cdot 10^{+146}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -180Initial program 44.8%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6435.7
Applied rewrites35.7%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6474.0
Applied rewrites74.0%
if -180 < y.im < 5.5999999999999998e-123Initial program 75.2%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6490.6
Applied rewrites90.6%
if 5.5999999999999998e-123 < y.im < 1.99999999999999987e146Initial program 79.4%
if 1.99999999999999987e146 < y.im Initial program 23.3%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6486.9
Applied rewrites86.9%
Final simplification83.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (- x.re) y.im (* y.re x.im)) (* y.re y.re))))
(if (<= y.re -1e+116)
(/ x.im y.re)
(if (<= y.re -2.15e-93)
t_0
(if (<= y.re 1.9e-44)
(/ (- x.re) y.im)
(if (<= y.re 3.5e+146) t_0 (/ x.im y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(-x_46_re, y_46_im, (y_46_re * x_46_im)) / (y_46_re * y_46_re);
double tmp;
if (y_46_re <= -1e+116) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= -2.15e-93) {
tmp = t_0;
} else if (y_46_re <= 1.9e-44) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 3.5e+146) {
tmp = t_0;
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(-x_46_re), y_46_im, Float64(y_46_re * x_46_im)) / Float64(y_46_re * y_46_re)) tmp = 0.0 if (y_46_re <= -1e+116) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= -2.15e-93) tmp = t_0; elseif (y_46_re <= 1.9e-44) tmp = Float64(Float64(-x_46_re) / y_46_im); elseif (y_46_re <= 3.5e+146) tmp = t_0; else tmp = Float64(x_46_im / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) * y$46$im + N[(y$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1e+116], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -2.15e-93], t$95$0, If[LessEqual[y$46$re, 1.9e-44], N[((-x$46$re) / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 3.5e+146], t$95$0, N[(x$46$im / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-x.re, y.im, y.re \cdot x.im\right)}{y.re \cdot y.re}\\
\mathbf{if}\;y.re \leq -1 \cdot 10^{+116}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq -2.15 \cdot 10^{-93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.9 \cdot 10^{-44}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 3.5 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -1.00000000000000002e116 or 3.5000000000000001e146 < y.re Initial program 33.6%
Taylor expanded in y.re around inf
lower-/.f6471.8
Applied rewrites71.8%
if -1.00000000000000002e116 < y.re < -2.14999999999999981e-93 or 1.9e-44 < y.re < 3.5000000000000001e146Initial program 77.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6461.7
Applied rewrites61.7%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
cancel-sign-sub-invN/A
lower-/.f64N/A
cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lift-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
lift-*.f6461.3
Applied rewrites61.3%
if -2.14999999999999981e-93 < y.re < 1.9e-44Initial program 65.2%
Taylor expanded in y.re around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6472.1
Applied rewrites72.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* x.im (/ y.re (fma y.im y.im (* y.re y.re))))))
(if (<= y.re -5.4e+153)
(/ x.im y.re)
(if (<= y.re -3.6e-109)
t_0
(if (<= y.re 3.2e-97)
(/ (- x.re) y.im)
(if (<= y.re 1.55e+146) t_0 (/ x.im y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = x_46_im * (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
double tmp;
if (y_46_re <= -5.4e+153) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= -3.6e-109) {
tmp = t_0;
} else if (y_46_re <= 3.2e-97) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 1.55e+146) {
tmp = t_0;
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(x_46_im * Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))) tmp = 0.0 if (y_46_re <= -5.4e+153) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= -3.6e-109) tmp = t_0; elseif (y_46_re <= 3.2e-97) tmp = Float64(Float64(-x_46_re) / y_46_im); elseif (y_46_re <= 1.55e+146) tmp = t_0; else tmp = Float64(x_46_im / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(x$46$im * 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, -5.4e+153], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -3.6e-109], t$95$0, If[LessEqual[y$46$re, 3.2e-97], N[((-x$46$re) / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.55e+146], t$95$0, N[(x$46$im / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{if}\;y.re \leq -5.4 \cdot 10^{+153}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 3.2 \cdot 10^{-97}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 1.55 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -5.4000000000000001e153 or 1.5500000000000001e146 < y.re Initial program 31.4%
Taylor expanded in y.re around inf
lower-/.f6471.5
Applied rewrites71.5%
if -5.4000000000000001e153 < y.re < -3.6000000000000001e-109 or 3.1999999999999998e-97 < y.re < 1.5500000000000001e146Initial program 77.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-*.f6456.2
Applied rewrites56.2%
if -3.6000000000000001e-109 < y.re < 3.1999999999999998e-97Initial program 63.5%
Taylor expanded in y.re around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.4
Applied rewrites76.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -1080000000000.0)
(/ x.im y.re)
(if (<= y.re 1.85e+20)
(/ (- (/ (* y.re x.im) y.im) x.re) y.im)
(if (<= y.re 7e+145)
(/ (fma (- x.re) y.im (* y.re x.im)) (* y.re y.re))
(/ x.im 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 <= -1080000000000.0) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 1.85e+20) {
tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
} else if (y_46_re <= 7e+145) {
tmp = fma(-x_46_re, y_46_im, (y_46_re * x_46_im)) / (y_46_re * y_46_re);
} else {
tmp = x_46_im / 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 <= -1080000000000.0) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= 1.85e+20) tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im); elseif (y_46_re <= 7e+145) tmp = Float64(fma(Float64(-x_46_re), y_46_im, Float64(y_46_re * x_46_im)) / Float64(y_46_re * y_46_re)); else tmp = Float64(x_46_im / 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, -1080000000000.0], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.85e+20], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 7e+145], N[(N[((-x$46$re) * y$46$im + N[(y$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1080000000000:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 7 \cdot 10^{+145}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x.re, y.im, y.re \cdot x.im\right)}{y.re \cdot y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -1.08e12 or 7.0000000000000002e145 < y.re Initial program 44.2%
Taylor expanded in y.re around inf
lower-/.f6467.9
Applied rewrites67.9%
if -1.08e12 < y.re < 1.85e20Initial program 69.0%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6476.7
Applied rewrites76.7%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f6476.7
Applied rewrites76.7%
if 1.85e20 < y.re < 7.0000000000000002e145Initial program 81.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.9
Applied rewrites73.9%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
cancel-sign-sub-invN/A
lower-/.f64N/A
cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lift-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
pow2N/A
lift-*.f6473.7
Applied rewrites73.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -180.0)
(/ (fma y.re (/ x.im y.im) (- x.re)) y.im)
(if (<= y.im 1.6e+92)
(/ (fma x.re (/ y.im y.re) (- x.im)) (- y.re))
(/ (fma x.im (/ y.re y.im) (- x.re)) 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 <= -180.0) {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_im <= 1.6e+92) {
tmp = fma(x_46_re, (y_46_im / y_46_re), -x_46_im) / -y_46_re;
} else {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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 <= -180.0) tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_im <= 1.6e+92) tmp = Float64(fma(x_46_re, Float64(y_46_im / y_46_re), Float64(-x_46_im)) / Float64(-y_46_re)); else tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / 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, -180.0], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.6e+92], N[(N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -180:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.im \leq 1.6 \cdot 10^{+92}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.im}{y.re}, -x.im\right)}{-y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -180Initial program 44.8%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6435.7
Applied rewrites35.7%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6474.0
Applied rewrites74.0%
if -180 < y.im < 1.60000000000000013e92Initial program 76.1%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.7
Applied rewrites82.7%
if 1.60000000000000013e92 < y.im Initial program 35.5%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.8
Applied rewrites80.8%
Final simplification80.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -180.0) (not (<= y.im 1.6e+92))) (/ (fma x.im (/ y.re y.im) (- x.re)) y.im) (/ (- x.im (/ (* y.im x.re) y.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_im <= -180.0) || !(y_46_im <= 1.6e+92)) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else {
tmp = (x_46_im - ((y_46_im * x_46_re) / y_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_im <= -180.0) || !(y_46_im <= 1.6e+92)) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -180.0], N[Not[LessEqual[y$46$im, 1.6e+92]], $MachinePrecision]], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -180 \lor \neg \left(y.im \leq 1.6 \cdot 10^{+92}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -180 or 1.60000000000000013e92 < y.im Initial program 40.7%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.3
Applied rewrites76.3%
if -180 < y.im < 1.60000000000000013e92Initial program 76.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.3
Applied rewrites81.3%
Final simplification79.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -8e-92) (not (<= y.re 1.7e+20))) (/ (- x.im (* y.im (/ x.re y.re))) y.re) (/ (- (/ (* y.re x.im) y.im) x.re) 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_re <= -8e-92) || !(y_46_re <= 1.7e+20)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
} else {
tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
}
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 <= (-8d-92)) .or. (.not. (y_46re <= 1.7d+20))) then
tmp = (x_46im - (y_46im * (x_46re / y_46re))) / y_46re
else
tmp = (((y_46re * x_46im) / y_46im) - x_46re) / y_46im
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 <= -8e-92) || !(y_46_re <= 1.7e+20)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
} else {
tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -8e-92) or not (y_46_re <= 1.7e+20): tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re else: tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / 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_re <= -8e-92) || !(y_46_re <= 1.7e+20)) tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / y_46_re); else tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im); 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 <= -8e-92) || ~((y_46_re <= 1.7e+20))) tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re; else tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -8e-92], N[Not[LessEqual[y$46$re, 1.7e+20]], $MachinePrecision]], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -8 \cdot 10^{-92} \lor \neg \left(y.re \leq 1.7 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -7.9999999999999999e-92 or 1.7e20 < y.re Initial program 55.2%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.6
Applied rewrites72.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.3
Applied rewrites75.3%
if -7.9999999999999999e-92 < y.re < 1.7e20Initial program 66.0%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6482.4
Applied rewrites82.4%
Taylor expanded in y.im around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f6482.4
Applied rewrites82.4%
Final simplification78.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -180.0)
(/ (fma y.re (/ x.im y.im) (- x.re)) y.im)
(if (<= y.im 1.6e+92)
(/ (- x.im (/ (* y.im x.re) y.re)) y.re)
(/ (fma x.im (/ y.re y.im) (- x.re)) 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 <= -180.0) {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_im <= 1.6e+92) {
tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
} else {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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 <= -180.0) tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_im <= 1.6e+92) tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re); else tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / 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, -180.0], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.6e+92], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -180:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.im \leq 1.6 \cdot 10^{+92}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -180Initial program 44.8%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6435.7
Applied rewrites35.7%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6474.0
Applied rewrites74.0%
if -180 < y.im < 1.60000000000000013e92Initial program 76.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.3
Applied rewrites81.3%
if 1.60000000000000013e92 < y.im Initial program 35.5%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.8
Applied rewrites80.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -800000000000.0) (not (<= y.re 2.5e-44))) (/ x.im y.re) (/ (- x.re) 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_re <= -800000000000.0) || !(y_46_re <= 2.5e-44)) {
tmp = x_46_im / y_46_re;
} else {
tmp = -x_46_re / y_46_im;
}
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 <= (-800000000000.0d0)) .or. (.not. (y_46re <= 2.5d-44))) then
tmp = x_46im / y_46re
else
tmp = -x_46re / y_46im
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 <= -800000000000.0) || !(y_46_re <= 2.5e-44)) {
tmp = x_46_im / y_46_re;
} else {
tmp = -x_46_re / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -800000000000.0) or not (y_46_re <= 2.5e-44): tmp = x_46_im / y_46_re else: tmp = -x_46_re / 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_re <= -800000000000.0) || !(y_46_re <= 2.5e-44)) tmp = Float64(x_46_im / y_46_re); else tmp = Float64(Float64(-x_46_re) / y_46_im); 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 <= -800000000000.0) || ~((y_46_re <= 2.5e-44))) tmp = x_46_im / y_46_re; else tmp = -x_46_re / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -800000000000.0], N[Not[LessEqual[y$46$re, 2.5e-44]], $MachinePrecision]], N[(x$46$im / y$46$re), $MachinePrecision], N[((-x$46$re) / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -800000000000 \lor \neg \left(y.re \leq 2.5 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -8e11 or 2.50000000000000019e-44 < y.re Initial program 52.5%
Taylor expanded in y.re around inf
lower-/.f6460.9
Applied rewrites60.9%
if -8e11 < y.re < 2.50000000000000019e-44Initial program 68.8%
Taylor expanded in y.re around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6466.6
Applied rewrites66.6%
Final simplification63.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / 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
code = x_46im / y_46re
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_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.re}
\end{array}
Initial program 59.6%
Taylor expanded in y.re around inf
lower-/.f6441.2
Applied rewrites41.2%
herbie shell --seed 2025064
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, imaginary part"
:precision binary64
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))