
(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 15 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
(let* ((t_0 (fma y.im y.im (* y.re y.re)))
(t_1 (fma (/ y.re t_0) x.im (* (- y.im) (/ x.re t_0))))
(t_2 (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)))
(if (<= y.im -2.8e+126)
t_2
(if (<= y.im -7.1e-130)
t_1
(if (<= y.im 5.8e-144)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(if (<= y.im 8.3e+88) t_1 t_2))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma((y_46_re / t_0), x_46_im, (-y_46_im * (x_46_re / t_0)));
double t_2 = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2.8e+126) {
tmp = t_2;
} else if (y_46_im <= -7.1e-130) {
tmp = t_1;
} else if (y_46_im <= 5.8e-144) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 8.3e+88) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) t_1 = fma(Float64(y_46_re / t_0), x_46_im, Float64(Float64(-y_46_im) * Float64(x_46_re / t_0))) t_2 = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2.8e+126) tmp = t_2; elseif (y_46_im <= -7.1e-130) tmp = t_1; elseif (y_46_im <= 5.8e-144) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 8.3e+88) tmp = t_1; else tmp = 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 * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$re / t$95$0), $MachinePrecision] * x$46$im + N[((-y$46$im) * N[(x$46$re / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.8e+126], t$95$2, If[LessEqual[y$46$im, -7.1e-130], t$95$1, If[LessEqual[y$46$im, 5.8e-144], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 8.3e+88], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(\frac{y.re}{t\_0}, x.im, \left(-y.im\right) \cdot \frac{x.re}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.8 \cdot 10^{+126}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y.im \leq -7.1 \cdot 10^{-130}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{-144}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 8.3 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y.im < -2.80000000000000009e126 or 8.2999999999999996e88 < y.im Initial program 27.3%
Applied rewrites31.3%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.2
Applied rewrites83.2%
if -2.80000000000000009e126 < y.im < -7.1000000000000001e-130 or 5.8000000000000004e-144 < y.im < 8.2999999999999996e88Initial program 81.8%
Applied rewrites86.9%
if -7.1000000000000001e-130 < y.im < 5.8000000000000004e-144Initial program 62.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6491.4
Applied rewrites91.4%
Final simplification87.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)))
(if (<= y.im -2.6e+86)
t_0
(if (<= y.im -1.95e-141)
(*
(/ (fma (/ y.im x.im) (- x.re) y.re) (fma y.im y.im (* y.re y.re)))
x.im)
(if (<= y.im 5.6e-170)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(if (<= y.im 7.6e+78)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.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((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2.6e+86) {
tmp = t_0;
} else if (y_46_im <= -1.95e-141) {
tmp = (fma((y_46_im / x_46_im), -x_46_re, y_46_re) / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
} else if (y_46_im <= 5.6e-170) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 7.6e+78) {
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 = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2.6e+86) tmp = t_0; elseif (y_46_im <= -1.95e-141) tmp = Float64(Float64(fma(Float64(y_46_im / x_46_im), Float64(-x_46_re), y_46_re) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im); elseif (y_46_im <= 5.6e-170) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 7.6e+78) 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 = 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[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.6e+86], t$95$0, If[LessEqual[y$46$im, -1.95e-141], N[(N[(N[(N[(y$46$im / x$46$im), $MachinePrecision] * (-x$46$re) + y$46$re), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], If[LessEqual[y$46$im, 5.6e-170], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7.6e+78], 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], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.6 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -1.95 \cdot 10^{-141}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{x.im}, -x.re, y.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{elif}\;y.im \leq 5.6 \cdot 10^{-170}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 7.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -2.5999999999999998e86 or 7.5999999999999998e78 < y.im Initial program 28.7%
Applied rewrites34.6%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.2
Applied rewrites80.2%
if -2.5999999999999998e86 < y.im < -1.9499999999999999e-141Initial program 89.3%
Taylor expanded in x.im around inf
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-inN/A
Applied rewrites91.6%
if -1.9499999999999999e-141 < y.im < 5.59999999999999991e-170Initial program 58.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
if 5.59999999999999991e-170 < y.im < 7.5999999999999998e78Initial program 82.5%
Final simplification85.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)))
(if (<= y.im -2e+126)
t_0
(if (<= y.im -2e-141)
(*
(/ (- (/ (* x.im y.re) x.re) y.im) (fma y.im y.im (* y.re y.re)))
x.re)
(if (<= y.im 5.6e-170)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(if (<= y.im 7.6e+78)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.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((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2e+126) {
tmp = t_0;
} else if (y_46_im <= -2e-141) {
tmp = ((((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-170) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 7.6e+78) {
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 = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2e+126) tmp = t_0; elseif (y_46_im <= -2e-141) tmp = Float64(Float64(Float64(Float64(Float64(x_46_im * y_46_re) / x_46_re) - 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-170) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 7.6e+78) 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 = 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[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2e+126], t$95$0, If[LessEqual[y$46$im, -2e-141], N[(N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / 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-170], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7.6e+78], 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], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2 \cdot 10^{+126}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -2 \cdot 10^{-141}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{x.re} - y.im}{\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^{-170}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 7.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -1.99999999999999985e126 or 7.5999999999999998e78 < y.im Initial program 27.0%
Applied rewrites30.9%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.2
Applied rewrites82.2%
if -1.99999999999999985e126 < y.im < -2.0000000000000001e-141Initial program 85.0%
Taylor expanded in x.re around inf
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-lft-out--N/A
distribute-lft-out--N/A
associate-/l*N/A
fp-cancel-sub-signN/A
distribute-lft-neg-inN/A
Applied rewrites86.6%
if -2.0000000000000001e-141 < y.im < 5.59999999999999991e-170Initial program 58.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
if 5.59999999999999991e-170 < y.im < 7.5999999999999998e78Initial program 82.5%
Final simplification85.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
(t_1 (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)))
(if (<= y.im -2.2e+91)
t_1
(if (<= y.im -8.1e-143)
t_0
(if (<= y.im 5.6e-170)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(if (<= y.im 7.6e+78) 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_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2.2e+91) {
tmp = t_1;
} else if (y_46_im <= -8.1e-143) {
tmp = t_0;
} else if (y_46_im <= 5.6e-170) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 7.6e+78) {
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_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))) t_1 = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2.2e+91) tmp = t_1; elseif (y_46_im <= -8.1e-143) tmp = t_0; elseif (y_46_im <= 5.6e-170) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 7.6e+78) 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$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]}, Block[{t$95$1 = N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.2e+91], t$95$1, If[LessEqual[y$46$im, -8.1e-143], t$95$0, If[LessEqual[y$46$im, 5.6e-170], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7.6e+78], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.2 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -8.1 \cdot 10^{-143}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 5.6 \cdot 10^{-170}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 7.6 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -2.19999999999999999e91 or 7.5999999999999998e78 < y.im Initial program 27.9%
Applied rewrites33.8%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.0
Applied rewrites80.0%
if -2.19999999999999999e91 < y.im < -8.0999999999999998e-143 or 5.59999999999999991e-170 < y.im < 7.5999999999999998e78Initial program 85.8%
if -8.0999999999999998e-143 < y.im < 5.59999999999999991e-170Initial program 58.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
Final simplification85.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (fma (- x.re) y.im (* x.im y.re)) (fma y.im y.im (* y.re y.re))))
(t_1 (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)))
(if (<= y.im -2.2e+91)
t_1
(if (<= y.im -8.1e-143)
t_0
(if (<= y.im 5.6e-170)
(/ (- x.im (/ (* x.re y.im) y.re)) y.re)
(if (<= y.im 7.6e+78) 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 = fma(-x_46_re, y_46_im, (x_46_im * y_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2.2e+91) {
tmp = t_1;
} else if (y_46_im <= -8.1e-143) {
tmp = t_0;
} else if (y_46_im <= 5.6e-170) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 7.6e+78) {
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(fma(Float64(-x_46_re), y_46_im, Float64(x_46_im * y_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) t_1 = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2.2e+91) tmp = t_1; elseif (y_46_im <= -8.1e-143) tmp = t_0; elseif (y_46_im <= 5.6e-170) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 7.6e+78) 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[((-x$46$re) * y$46$im + N[(x$46$im * y$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.2e+91], t$95$1, If[LessEqual[y$46$im, -8.1e-143], t$95$0, If[LessEqual[y$46$im, 5.6e-170], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7.6e+78], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-x.re, y.im, x.im \cdot y.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.2 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -8.1 \cdot 10^{-143}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 5.6 \cdot 10^{-170}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 7.6 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -2.19999999999999999e91 or 7.5999999999999998e78 < y.im Initial program 27.9%
Applied rewrites33.8%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.0
Applied rewrites80.0%
if -2.19999999999999999e91 < y.im < -8.0999999999999998e-143 or 5.59999999999999991e-170 < y.im < 7.5999999999999998e78Initial program 85.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-neg.f6485.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
Applied rewrites85.7%
if -8.0999999999999998e-143 < y.im < 5.59999999999999991e-170Initial program 58.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
Final simplification85.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- x.re) y.im)))
(if (<= y.im -1e+127)
t_0
(if (<= y.im -3.8e-85)
(* (- x.re) (/ y.im (fma y.im y.im (* y.re y.re))))
(if (<= y.im 1.8e+37)
(/ x.im y.re)
(if (<= y.im 4.3e+122)
(/ (- (* x.im y.re) (* x.re y.im)) (* y.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 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -1e+127) {
tmp = t_0;
} else if (y_46_im <= -3.8e-85) {
tmp = -x_46_re * (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else if (y_46_im <= 1.8e+37) {
tmp = x_46_im / y_46_re;
} else if (y_46_im <= 4.3e+122) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_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(Float64(-x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -1e+127) tmp = t_0; elseif (y_46_im <= -3.8e-85) tmp = Float64(Float64(-x_46_re) * Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); elseif (y_46_im <= 1.8e+37) tmp = Float64(x_46_im / y_46_re); elseif (y_46_im <= 4.3e+122) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(y_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[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1e+127], t$95$0, If[LessEqual[y$46$im, -3.8e-85], N[((-x$46$re) * 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, 1.8e+37], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 4.3e+122], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -1 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -3.8 \cdot 10^{-85}:\\
\;\;\;\;\left(-x.re\right) \cdot \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{elif}\;y.im \leq 1.8 \cdot 10^{+37}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.im \leq 4.3 \cdot 10^{+122}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -9.99999999999999955e126 or 4.29999999999999971e122 < y.im Initial program 24.1%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6464.0
Applied rewrites64.0%
if -9.99999999999999955e126 < y.im < -3.7999999999999999e-85Initial program 83.4%
Taylor expanded in x.re around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.9
Applied rewrites63.9%
if -3.7999999999999999e-85 < y.im < 1.79999999999999999e37Initial program 70.7%
Taylor expanded in y.re around inf
lower-/.f6468.4
Applied rewrites68.4%
if 1.79999999999999999e37 < y.im < 4.29999999999999971e122Initial program 69.0%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6463.4
Applied rewrites63.4%
Final simplification66.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (- (* x.im y.re) (* x.re y.im))))
(if (<= y.re -8.4e-23)
(/ x.im y.re)
(if (<= y.re 2.75e-112)
(/ t_0 (* y.im y.im))
(if (<= y.re 1.25e+122) (/ t_0 (* 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 t_0 = (x_46_im * y_46_re) - (x_46_re * y_46_im);
double tmp;
if (y_46_re <= -8.4e-23) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 2.75e-112) {
tmp = t_0 / (y_46_im * y_46_im);
} else if (y_46_re <= 1.25e+122) {
tmp = t_0 / (y_46_re * y_46_re);
} else {
tmp = x_46_im / 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) :: t_0
real(8) :: tmp
t_0 = (x_46im * y_46re) - (x_46re * y_46im)
if (y_46re <= (-8.4d-23)) then
tmp = x_46im / y_46re
else if (y_46re <= 2.75d-112) then
tmp = t_0 / (y_46im * y_46im)
else if (y_46re <= 1.25d+122) then
tmp = t_0 / (y_46re * y_46re)
else
tmp = x_46im / 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 t_0 = (x_46_im * y_46_re) - (x_46_re * y_46_im);
double tmp;
if (y_46_re <= -8.4e-23) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 2.75e-112) {
tmp = t_0 / (y_46_im * y_46_im);
} else if (y_46_re <= 1.25e+122) {
tmp = t_0 / (y_46_re * y_46_re);
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = (x_46_im * y_46_re) - (x_46_re * y_46_im) tmp = 0 if y_46_re <= -8.4e-23: tmp = x_46_im / y_46_re elif y_46_re <= 2.75e-112: tmp = t_0 / (y_46_im * y_46_im) elif y_46_re <= 1.25e+122: tmp = t_0 / (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) t_0 = Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) tmp = 0.0 if (y_46_re <= -8.4e-23) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= 2.75e-112) tmp = Float64(t_0 / Float64(y_46_im * y_46_im)); elseif (y_46_re <= 1.25e+122) tmp = Float64(t_0 / Float64(y_46_re * y_46_re)); else tmp = Float64(x_46_im / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = (x_46_im * y_46_re) - (x_46_re * y_46_im); tmp = 0.0; if (y_46_re <= -8.4e-23) tmp = x_46_im / y_46_re; elseif (y_46_re <= 2.75e-112) tmp = t_0 / (y_46_im * y_46_im); elseif (y_46_re <= 1.25e+122) tmp = t_0 / (y_46_re * y_46_re); else tmp = x_46_im / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -8.4e-23], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2.75e-112], N[(t$95$0 / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.25e+122], N[(t$95$0 / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot y.re - x.re \cdot y.im\\
\mathbf{if}\;y.re \leq -8.4 \cdot 10^{-23}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq 2.75 \cdot 10^{-112}:\\
\;\;\;\;\frac{t\_0}{y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 1.25 \cdot 10^{+122}:\\
\;\;\;\;\frac{t\_0}{y.re \cdot y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -8.4000000000000003e-23 or 1.24999999999999997e122 < y.re Initial program 42.6%
Taylor expanded in y.re around inf
lower-/.f6470.6
Applied rewrites70.6%
if -8.4000000000000003e-23 < y.re < 2.75e-112Initial program 73.5%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6468.4
Applied rewrites68.4%
if 2.75e-112 < y.re < 1.24999999999999997e122Initial program 65.8%
Taylor expanded in y.re around inf
unpow2N/A
lower-*.f6452.7
Applied rewrites52.7%
Final simplification65.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -7.5e-85) (not (<= y.im 2.1e+37))) (/ (fma y.re (/ x.im y.im) (- x.re)) y.im) (/ (- x.im (/ (* x.re y.im) 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 <= -7.5e-85) || !(y_46_im <= 2.1e+37)) {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / 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 <= -7.5e-85) || !(y_46_im <= 2.1e+37)) tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / 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, -7.5e-85], N[Not[LessEqual[y$46$im, 2.1e+37]], $MachinePrecision]], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -7.5 \cdot 10^{-85} \lor \neg \left(y.im \leq 2.1 \cdot 10^{+37}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -7.5000000000000003e-85 or 2.1000000000000001e37 < y.im Initial program 48.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6422.7
Applied rewrites22.7%
Applied rewrites28.7%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.8
Applied rewrites74.8%
if -7.5000000000000003e-85 < y.im < 2.1000000000000001e37Initial program 70.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.4
Applied rewrites85.4%
Final simplification80.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -4.1e-85) (not (<= y.im 2.15e+37))) (/ (fma (/ y.re y.im) x.im (- x.re)) y.im) (/ (- x.im (/ (* x.re y.im) 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 <= -4.1e-85) || !(y_46_im <= 2.15e+37)) {
tmp = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / 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 <= -4.1e-85) || !(y_46_im <= 2.15e+37)) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / 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, -4.1e-85], N[Not[LessEqual[y$46$im, 2.15e+37]], $MachinePrecision]], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4.1 \cdot 10^{-85} \lor \neg \left(y.im \leq 2.15 \cdot 10^{+37}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -4.09999999999999994e-85 or 2.1499999999999998e37 < y.im Initial program 48.0%
Applied rewrites52.7%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.8
Applied rewrites74.8%
if -4.09999999999999994e-85 < y.im < 2.1499999999999998e37Initial program 70.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.4
Applied rewrites85.4%
Final simplification80.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -4.1e-85) (not (<= y.im 2.15e+37))) (/ (fma (/ y.re y.im) x.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 <= -4.1e-85) || !(y_46_im <= 2.15e+37)) {
tmp = fma((y_46_re / y_46_im), x_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 <= -4.1e-85) || !(y_46_im <= 2.15e+37)) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(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, -4.1e-85], N[Not[LessEqual[y$46$im, 2.15e+37]], $MachinePrecision]], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4.1 \cdot 10^{-85} \lor \neg \left(y.im \leq 2.15 \cdot 10^{+37}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -4.09999999999999994e-85 or 2.1499999999999998e37 < y.im Initial program 48.0%
Applied rewrites52.7%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.8
Applied rewrites74.8%
if -4.09999999999999994e-85 < y.im < 2.1499999999999998e37Initial program 70.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.4
Applied rewrites85.4%
Applied rewrites83.8%
Final simplification79.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -8.4e-23) (not (<= y.re 1.72e+81))) (/ x.im y.re) (/ (fma (/ y.re y.im) x.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 <= -8.4e-23) || !(y_46_re <= 1.72e+81)) {
tmp = x_46_im / y_46_re;
} else {
tmp = fma((y_46_re / y_46_im), x_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 <= -8.4e-23) || !(y_46_re <= 1.72e+81)) tmp = Float64(x_46_im / y_46_re); else tmp = Float64(fma(Float64(y_46_re / y_46_im), x_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[Or[LessEqual[y$46$re, -8.4e-23], N[Not[LessEqual[y$46$re, 1.72e+81]], $MachinePrecision]], N[(x$46$im / y$46$re), $MachinePrecision], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -8.4 \cdot 10^{-23} \lor \neg \left(y.re \leq 1.72 \cdot 10^{+81}\right):\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.re < -8.4000000000000003e-23 or 1.72000000000000002e81 < y.re Initial program 46.4%
Taylor expanded in y.re around inf
lower-/.f6469.0
Applied rewrites69.0%
if -8.4000000000000003e-23 < y.re < 1.72000000000000002e81Initial program 69.9%
Applied rewrites66.7%
Taylor expanded in y.re around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.8
Applied rewrites76.8%
Final simplification73.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- x.re) y.im)))
(if (<= y.im -1e+127)
t_0
(if (<= y.im -3.8e-85)
(* (- x.re) (/ y.im (fma y.im y.im (* y.re y.re))))
(if (<= y.im 2.1e+37) (/ x.im y.re) t_0)))))
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_im;
double tmp;
if (y_46_im <= -1e+127) {
tmp = t_0;
} else if (y_46_im <= -3.8e-85) {
tmp = -x_46_re * (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re)));
} else if (y_46_im <= 2.1e+37) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(-x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -1e+127) tmp = t_0; elseif (y_46_im <= -3.8e-85) tmp = Float64(Float64(-x_46_re) * Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))); elseif (y_46_im <= 2.1e+37) tmp = Float64(x_46_im / y_46_re); 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[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1e+127], t$95$0, If[LessEqual[y$46$im, -3.8e-85], N[((-x$46$re) * 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, 2.1e+37], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -1 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -3.8 \cdot 10^{-85}:\\
\;\;\;\;\left(-x.re\right) \cdot \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{elif}\;y.im \leq 2.1 \cdot 10^{+37}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -9.99999999999999955e126 or 2.1000000000000001e37 < y.im Initial program 32.0%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6458.8
Applied rewrites58.8%
if -9.99999999999999955e126 < y.im < -3.7999999999999999e-85Initial program 83.4%
Taylor expanded in x.re around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.9
Applied rewrites63.9%
if -3.7999999999999999e-85 < y.im < 2.1000000000000001e37Initial program 70.7%
Taylor expanded in y.re around inf
lower-/.f6468.4
Applied rewrites68.4%
Final simplification64.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2e+151)
(/ x.im y.re)
(if (<= y.re -7.2e-73)
(* (/ y.re (fma y.im y.im (* y.re y.re))) x.im)
(if (<= y.re 1.55e+81) (/ (- x.re) y.im) (/ 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 <= -2e+151) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= -7.2e-73) {
tmp = (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
} else if (y_46_re <= 1.55e+81) {
tmp = -x_46_re / y_46_im;
} 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 <= -2e+151) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= -7.2e-73) tmp = Float64(Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im); elseif (y_46_re <= 1.55e+81) tmp = Float64(Float64(-x_46_re) / y_46_im); 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, -2e+151], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -7.2e-73], N[(N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.55e+81], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2 \cdot 10^{+151}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq -7.2 \cdot 10^{-73}:\\
\;\;\;\;\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{elif}\;y.re \leq 1.55 \cdot 10^{+81}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -2.00000000000000003e151 or 1.55e81 < y.re Initial program 38.6%
Taylor expanded in y.re around inf
lower-/.f6477.0
Applied rewrites77.0%
if -2.00000000000000003e151 < y.re < -7.1999999999999999e-73Initial program 69.9%
Applied rewrites75.3%
Taylor expanded in x.re around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6455.7
Applied rewrites55.7%
if -7.1999999999999999e-73 < y.re < 1.55e81Initial program 69.5%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6457.1
Applied rewrites57.1%
Final simplification63.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -8.4e-23) (not (<= y.re 1.55e+81))) (/ 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 <= -8.4e-23) || !(y_46_re <= 1.55e+81)) {
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 <= (-8.4d-23)) .or. (.not. (y_46re <= 1.55d+81))) 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 <= -8.4e-23) || !(y_46_re <= 1.55e+81)) {
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 <= -8.4e-23) or not (y_46_re <= 1.55e+81): 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 <= -8.4e-23) || !(y_46_re <= 1.55e+81)) 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 <= -8.4e-23) || ~((y_46_re <= 1.55e+81))) 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, -8.4e-23], N[Not[LessEqual[y$46$re, 1.55e+81]], $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 -8.4 \cdot 10^{-23} \lor \neg \left(y.re \leq 1.55 \cdot 10^{+81}\right):\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -8.4000000000000003e-23 or 1.55e81 < y.re Initial program 46.4%
Taylor expanded in y.re around inf
lower-/.f6469.0
Applied rewrites69.0%
if -8.4000000000000003e-23 < y.re < 1.55e81Initial program 69.9%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6456.1
Applied rewrites56.1%
Final simplification62.1%
(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.0%
Taylor expanded in y.re around inf
lower-/.f6444.0
Applied rewrites44.0%
Final simplification44.0%
herbie shell --seed 2024346
(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))))