
(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}
Herbie found 12 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 (/ (- x.re) y.re) (/ y.im y.re) (/ x.im y.re)))
(t_1 (- (* x.im y.re) (* x.re y.im))))
(if (<= y.re -1.65e+129)
t_0
(if (<= y.re -5.5e+31)
(fma (/ x.im y.im) (/ y.re y.im) (/ (- x.re) y.im))
(if (<= y.re -1.1e-90)
(/ t_1 (+ (* y.re y.re) (* y.im y.im)))
(if (<= y.re 5.5e-152)
(- (/ (- x.re (/ (* x.im y.re) y.im)) y.im))
(if (<= y.re 4e+96)
(/ t_1 (fma y.re y.re (pow y.im 2.0)))
t_0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma((-x_46_re / y_46_re), (y_46_im / y_46_re), (x_46_im / y_46_re));
double t_1 = (x_46_im * y_46_re) - (x_46_re * y_46_im);
double tmp;
if (y_46_re <= -1.65e+129) {
tmp = t_0;
} else if (y_46_re <= -5.5e+31) {
tmp = fma((x_46_im / y_46_im), (y_46_re / y_46_im), (-x_46_re / y_46_im));
} else if (y_46_re <= -1.1e-90) {
tmp = t_1 / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else if (y_46_re <= 5.5e-152) {
tmp = -((x_46_re - ((x_46_im * y_46_re) / y_46_im)) / y_46_im);
} else if (y_46_re <= 4e+96) {
tmp = t_1 / fma(y_46_re, y_46_re, pow(y_46_im, 2.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(Float64(Float64(-x_46_re) / y_46_re), Float64(y_46_im / y_46_re), Float64(x_46_im / y_46_re)) t_1 = Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) tmp = 0.0 if (y_46_re <= -1.65e+129) tmp = t_0; elseif (y_46_re <= -5.5e+31) tmp = fma(Float64(x_46_im / y_46_im), Float64(y_46_re / y_46_im), Float64(Float64(-x_46_re) / y_46_im)); elseif (y_46_re <= -1.1e-90) tmp = Float64(t_1 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); elseif (y_46_re <= 5.5e-152) tmp = Float64(-Float64(Float64(x_46_re - Float64(Float64(x_46_im * y_46_re) / y_46_im)) / y_46_im)); elseif (y_46_re <= 4e+96) tmp = Float64(t_1 / fma(y_46_re, y_46_re, (y_46_im ^ 2.0))); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.65e+129], t$95$0, If[LessEqual[y$46$re, -5.5e+31], N[(N[(x$46$im / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision] + N[((-x$46$re) / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.1e-90], N[(t$95$1 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.5e-152], (-N[(N[(x$46$re - N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 4e+96], N[(t$95$1 / N[(y$46$re * y$46$re + N[Power[y$46$im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-x.re}{y.re}, \frac{y.im}{y.re}, \frac{x.im}{y.re}\right)\\
t_1 := x.im \cdot y.re - x.re \cdot y.im\\
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{y.im}, \frac{y.re}{y.im}, \frac{-x.re}{y.im}\right)\\
\mathbf{elif}\;y.re \leq -1.1 \cdot 10^{-90}:\\
\;\;\;\;\frac{t\_1}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;-\frac{x.re - \frac{x.im \cdot y.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(y.re, y.re, {y.im}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129 or 4.0000000000000002e96 < y.re Initial program 35.3%
Taylor expanded in y.im around 0
Applied rewrites85.5%
if -1.64999999999999995e129 < y.re < -5.50000000000000002e31Initial program 72.2%
Taylor expanded in y.re around 0
Applied rewrites35.2%
if -5.50000000000000002e31 < y.re < -1.09999999999999993e-90Initial program 76.8%
if -1.09999999999999993e-90 < y.re < 5.4999999999999998e-152Initial program 70.7%
Applied rewrites70.7%
Taylor expanded in y.im around -inf
Applied rewrites91.3%
if 5.4999999999999998e-152 < y.re < 4.0000000000000002e96Initial program 76.9%
Applied rewrites76.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma (/ (- x.re) y.re) (/ y.im y.re) (/ x.im y.re))))
(if (<= y.re -1.85e+142)
t_0
(if (<= y.re -1.25e-90)
(*
(- x.im)
(/ (fma x.re (/ y.im x.im) (- y.re)) (fma y.im y.im (pow y.re 2.0))))
(if (<= y.re 5.5e-152)
(- (/ (- x.re (/ (* x.im y.re) y.im)) y.im))
(if (<= y.re 4e+96)
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.re y.re (pow y.im 2.0)))
t_0))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma((-x_46_re / y_46_re), (y_46_im / y_46_re), (x_46_im / y_46_re));
double tmp;
if (y_46_re <= -1.85e+142) {
tmp = t_0;
} else if (y_46_re <= -1.25e-90) {
tmp = -x_46_im * (fma(x_46_re, (y_46_im / x_46_im), -y_46_re) / fma(y_46_im, y_46_im, pow(y_46_re, 2.0)));
} else if (y_46_re <= 5.5e-152) {
tmp = -((x_46_re - ((x_46_im * y_46_re) / y_46_im)) / y_46_im);
} else if (y_46_re <= 4e+96) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / fma(y_46_re, y_46_re, pow(y_46_im, 2.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(Float64(Float64(-x_46_re) / y_46_re), Float64(y_46_im / y_46_re), Float64(x_46_im / y_46_re)) tmp = 0.0 if (y_46_re <= -1.85e+142) tmp = t_0; elseif (y_46_re <= -1.25e-90) tmp = Float64(Float64(-x_46_im) * Float64(fma(x_46_re, Float64(y_46_im / x_46_im), Float64(-y_46_re)) / fma(y_46_im, y_46_im, (y_46_re ^ 2.0)))); elseif (y_46_re <= 5.5e-152) tmp = Float64(-Float64(Float64(x_46_re - Float64(Float64(x_46_im * y_46_re) / y_46_im)) / y_46_im)); elseif (y_46_re <= 4e+96) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im ^ 2.0))); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.85e+142], t$95$0, If[LessEqual[y$46$re, -1.25e-90], N[((-x$46$im) * N[(N[(x$46$re * N[(y$46$im / x$46$im), $MachinePrecision] + (-y$46$re)), $MachinePrecision] / N[(y$46$im * y$46$im + N[Power[y$46$re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.5e-152], (-N[(N[(x$46$re - N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 4e+96], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[Power[y$46$im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-x.re}{y.re}, \frac{y.im}{y.re}, \frac{x.im}{y.re}\right)\\
\mathbf{if}\;y.re \leq -1.85 \cdot 10^{+142}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq -1.25 \cdot 10^{-90}:\\
\;\;\;\;\left(-x.im\right) \cdot \frac{\mathsf{fma}\left(x.re, \frac{y.im}{x.im}, -y.re\right)}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}\\
\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;-\frac{x.re - \frac{x.im \cdot y.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, {y.im}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.8499999999999999e142 or 4.0000000000000002e96 < y.re Initial program 34.6%
Taylor expanded in y.im around 0
Applied rewrites86.4%
if -1.8499999999999999e142 < y.re < -1.25000000000000005e-90Initial program 73.8%
Taylor expanded in x.im around -inf
Applied rewrites68.4%
if -1.25000000000000005e-90 < y.re < 5.4999999999999998e-152Initial program 70.7%
Applied rewrites70.7%
Taylor expanded in y.im around -inf
Applied rewrites91.3%
if 5.4999999999999998e-152 < y.re < 4.0000000000000002e96Initial program 76.9%
Applied rewrites76.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma (/ (- x.re) y.re) (/ y.im y.re) (/ x.im y.re)))
(t_1
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))))
(if (<= y.re -1.65e+129)
t_0
(if (<= y.re -5.5e+31)
(fma (/ x.im y.im) (/ y.re y.im) (/ (- x.re) y.im))
(if (<= y.re -1.1e-90)
t_1
(if (<= y.re 5.5e-152)
(- (/ (- x.re (/ (* x.im y.re) y.im)) y.im))
(if (<= y.re 4e+96) t_1 t_0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma((-x_46_re / y_46_re), (y_46_im / y_46_re), (x_46_im / y_46_re));
double t_1 = ((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 tmp;
if (y_46_re <= -1.65e+129) {
tmp = t_0;
} else if (y_46_re <= -5.5e+31) {
tmp = fma((x_46_im / y_46_im), (y_46_re / y_46_im), (-x_46_re / y_46_im));
} else if (y_46_re <= -1.1e-90) {
tmp = t_1;
} else if (y_46_re <= 5.5e-152) {
tmp = -((x_46_re - ((x_46_im * y_46_re) / y_46_im)) / y_46_im);
} else if (y_46_re <= 4e+96) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(Float64(Float64(-x_46_re) / y_46_re), Float64(y_46_im / y_46_re), Float64(x_46_im / y_46_re)) t_1 = 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))) tmp = 0.0 if (y_46_re <= -1.65e+129) tmp = t_0; elseif (y_46_re <= -5.5e+31) tmp = fma(Float64(x_46_im / y_46_im), Float64(y_46_re / y_46_im), Float64(Float64(-x_46_re) / y_46_im)); elseif (y_46_re <= -1.1e-90) tmp = t_1; elseif (y_46_re <= 5.5e-152) tmp = Float64(-Float64(Float64(x_46_re - Float64(Float64(x_46_im * y_46_re) / y_46_im)) / y_46_im)); elseif (y_46_re <= 4e+96) tmp = t_1; else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision] + N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[y$46$re, -1.65e+129], t$95$0, If[LessEqual[y$46$re, -5.5e+31], N[(N[(x$46$im / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision] + N[((-x$46$re) / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.1e-90], t$95$1, If[LessEqual[y$46$re, 5.5e-152], (-N[(N[(x$46$re - N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 4e+96], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-x.re}{y.re}, \frac{y.im}{y.re}, \frac{x.im}{y.re}\right)\\
t_1 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{y.im}, \frac{y.re}{y.im}, \frac{-x.re}{y.im}\right)\\
\mathbf{elif}\;y.re \leq -1.1 \cdot 10^{-90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;-\frac{x.re - \frac{x.im \cdot y.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129 or 4.0000000000000002e96 < y.re Initial program 35.3%
Taylor expanded in y.im around 0
Applied rewrites85.5%
if -1.64999999999999995e129 < y.re < -5.50000000000000002e31Initial program 72.2%
Taylor expanded in y.re around 0
Applied rewrites35.2%
if -5.50000000000000002e31 < y.re < -1.09999999999999993e-90 or 5.4999999999999998e-152 < y.re < 4.0000000000000002e96Initial program 76.8%
if -1.09999999999999993e-90 < y.re < 5.4999999999999998e-152Initial program 70.7%
Applied rewrites70.7%
Taylor expanded in y.im around -inf
Applied rewrites91.3%
(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)))))
(if (<= y.re -1.65e+129)
(/ (fma (- x.re) (/ y.im y.re) x.im) y.re)
(if (<= y.re -5.5e+31)
(fma (/ x.im y.im) (/ y.re y.im) (/ (- x.re) y.im))
(if (<= y.re -1.1e-90)
t_0
(if (<= y.re 5.5e-152)
(- (/ (- x.re (/ (* x.im y.re) y.im)) y.im))
(if (<= y.re 4e+96)
t_0
(/ (fma (/ (- x.re) y.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 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 tmp;
if (y_46_re <= -1.65e+129) {
tmp = fma(-x_46_re, (y_46_im / y_46_re), x_46_im) / y_46_re;
} else if (y_46_re <= -5.5e+31) {
tmp = fma((x_46_im / y_46_im), (y_46_re / y_46_im), (-x_46_re / y_46_im));
} else if (y_46_re <= -1.1e-90) {
tmp = t_0;
} else if (y_46_re <= 5.5e-152) {
tmp = -((x_46_re - ((x_46_im * y_46_re) / y_46_im)) / y_46_im);
} else if (y_46_re <= 4e+96) {
tmp = t_0;
} else {
tmp = fma((-x_46_re / y_46_re), y_46_im, 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(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))) tmp = 0.0 if (y_46_re <= -1.65e+129) tmp = Float64(fma(Float64(-x_46_re), Float64(y_46_im / y_46_re), x_46_im) / y_46_re); elseif (y_46_re <= -5.5e+31) tmp = fma(Float64(x_46_im / y_46_im), Float64(y_46_re / y_46_im), Float64(Float64(-x_46_re) / y_46_im)); elseif (y_46_re <= -1.1e-90) tmp = t_0; elseif (y_46_re <= 5.5e-152) tmp = Float64(-Float64(Float64(x_46_re - Float64(Float64(x_46_im * y_46_re) / y_46_im)) / y_46_im)); elseif (y_46_re <= 4e+96) tmp = t_0; else tmp = Float64(fma(Float64(Float64(-x_46_re) / y_46_re), y_46_im, 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[(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]}, If[LessEqual[y$46$re, -1.65e+129], 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$re, -5.5e+31], N[(N[(x$46$im / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision] + N[((-x$46$re) / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.1e-90], t$95$0, If[LessEqual[y$46$re, 5.5e-152], (-N[(N[(x$46$re - N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 4e+96], t$95$0, N[(N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * y$46$im + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]]
\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}\\
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x.re, \frac{y.im}{y.re}, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{y.im}, \frac{y.re}{y.im}, \frac{-x.re}{y.im}\right)\\
\mathbf{elif}\;y.re \leq -1.1 \cdot 10^{-90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;-\frac{x.re - \frac{x.im \cdot y.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-x.re}{y.re}, y.im, x.im\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129Initial program 34.9%
Taylor expanded in y.im around 0
Applied rewrites86.6%
Applied rewrites86.0%
if -1.64999999999999995e129 < y.re < -5.50000000000000002e31Initial program 72.2%
Taylor expanded in y.re around 0
Applied rewrites35.2%
if -5.50000000000000002e31 < y.re < -1.09999999999999993e-90 or 5.4999999999999998e-152 < y.re < 4.0000000000000002e96Initial program 76.8%
if -1.09999999999999993e-90 < y.re < 5.4999999999999998e-152Initial program 70.7%
Applied rewrites70.7%
Taylor expanded in y.im around -inf
Applied rewrites91.3%
if 4.0000000000000002e96 < y.re Initial program 35.7%
Applied rewrites35.7%
Taylor expanded in y.re around 0
Applied rewrites20.5%
Taylor expanded in y.re around inf
Applied rewrites85.2%
(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)))))
(if (<= y.re -1.65e+129)
(/ (fma (- x.re) (/ y.im y.re) x.im) y.re)
(if (<= y.re -5.5e+31)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
(if (<= y.re -1.1e-90)
t_0
(if (<= y.re 5.5e-152)
(- (/ (- x.re (/ (* x.im y.re) y.im)) y.im))
(if (<= y.re 4e+96)
t_0
(/ (fma (/ (- x.re) y.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 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 tmp;
if (y_46_re <= -1.65e+129) {
tmp = fma(-x_46_re, (y_46_im / y_46_re), x_46_im) / y_46_re;
} else if (y_46_re <= -5.5e+31) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_re <= -1.1e-90) {
tmp = t_0;
} else if (y_46_re <= 5.5e-152) {
tmp = -((x_46_re - ((x_46_im * y_46_re) / y_46_im)) / y_46_im);
} else if (y_46_re <= 4e+96) {
tmp = t_0;
} else {
tmp = fma((-x_46_re / y_46_re), y_46_im, 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(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))) tmp = 0.0 if (y_46_re <= -1.65e+129) tmp = Float64(fma(Float64(-x_46_re), Float64(y_46_im / y_46_re), x_46_im) / y_46_re); elseif (y_46_re <= -5.5e+31) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_re <= -1.1e-90) tmp = t_0; elseif (y_46_re <= 5.5e-152) tmp = Float64(-Float64(Float64(x_46_re - Float64(Float64(x_46_im * y_46_re) / y_46_im)) / y_46_im)); elseif (y_46_re <= 4e+96) tmp = t_0; else tmp = Float64(fma(Float64(Float64(-x_46_re) / y_46_re), y_46_im, 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[(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]}, If[LessEqual[y$46$re, -1.65e+129], 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$re, -5.5e+31], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, -1.1e-90], t$95$0, If[LessEqual[y$46$re, 5.5e-152], (-N[(N[(x$46$re - N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 4e+96], t$95$0, N[(N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * y$46$im + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]]
\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}\\
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x.re, \frac{y.im}{y.re}, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.re \leq -1.1 \cdot 10^{-90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;-\frac{x.re - \frac{x.im \cdot y.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-x.re}{y.re}, y.im, x.im\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129Initial program 34.9%
Taylor expanded in y.im around 0
Applied rewrites86.6%
Applied rewrites86.0%
if -1.64999999999999995e129 < y.re < -5.50000000000000002e31Initial program 72.2%
Taylor expanded in y.im around inf
Applied rewrites35.4%
if -5.50000000000000002e31 < y.re < -1.09999999999999993e-90 or 5.4999999999999998e-152 < y.re < 4.0000000000000002e96Initial program 76.8%
if -1.09999999999999993e-90 < y.re < 5.4999999999999998e-152Initial program 70.7%
Applied rewrites70.7%
Taylor expanded in y.im around -inf
Applied rewrites91.3%
if 4.0000000000000002e96 < y.re Initial program 35.7%
Applied rewrites35.7%
Taylor expanded in y.re around 0
Applied rewrites20.5%
Taylor expanded in y.re around inf
Applied rewrites85.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -1.5e+61)
(/ x.im y.re)
(if (<= y.re 2.5e-125)
(/ (- x.re) y.im)
(if (<= y.re 4e+96)
(/ (* y.re x.im) (+ (* y.re y.re) (* y.im 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 <= -1.5e+61) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 2.5e-125) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 4e+96) {
tmp = (y_46_re * x_46_im) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} 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) :: tmp
if (y_46re <= (-1.5d+61)) then
tmp = x_46im / y_46re
else if (y_46re <= 2.5d-125) then
tmp = -x_46re / y_46im
else if (y_46re <= 4d+96) then
tmp = (y_46re * x_46im) / ((y_46re * y_46re) + (y_46im * y_46im))
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 tmp;
if (y_46_re <= -1.5e+61) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 2.5e-125) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 4e+96) {
tmp = (y_46_re * x_46_im) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -1.5e+61: tmp = x_46_im / y_46_re elif y_46_re <= 2.5e-125: tmp = -x_46_re / y_46_im elif y_46_re <= 4e+96: tmp = (y_46_re * x_46_im) / ((y_46_re * y_46_re) + (y_46_im * 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 <= -1.5e+61) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= 2.5e-125) tmp = Float64(Float64(-x_46_re) / y_46_im); elseif (y_46_re <= 4e+96) tmp = Float64(Float64(y_46_re * x_46_im) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); 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) tmp = 0.0; if (y_46_re <= -1.5e+61) tmp = x_46_im / y_46_re; elseif (y_46_re <= 2.5e-125) tmp = -x_46_re / y_46_im; elseif (y_46_re <= 4e+96) tmp = (y_46_re * x_46_im) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); 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_] := If[LessEqual[y$46$re, -1.5e+61], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2.5e-125], N[((-x$46$re) / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 4e+96], N[(N[(y$46$re * x$46$im), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.5 \cdot 10^{+61}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq 2.5 \cdot 10^{-125}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+96}:\\
\;\;\;\;\frac{y.re \cdot x.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -1.5e61 or 4.0000000000000002e96 < y.re Initial program 40.6%
Taylor expanded in y.re around inf
Applied rewrites71.9%
if -1.5e61 < y.re < 2.49999999999999983e-125Initial program 72.8%
Taylor expanded in y.re around 0
Applied rewrites64.7%
if 2.49999999999999983e-125 < y.re < 4.0000000000000002e96Initial program 76.8%
Taylor expanded in x.re around 0
Applied rewrites51.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -1.65e+129)
(/ (fma (- x.re) (/ y.im y.re) x.im) y.re)
(if (<= y.re 48000000000.0)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
(/ (fma (/ (- x.re) y.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 <= -1.65e+129) {
tmp = fma(-x_46_re, (y_46_im / y_46_re), x_46_im) / y_46_re;
} else if (y_46_re <= 48000000000.0) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else {
tmp = fma((-x_46_re / y_46_re), y_46_im, 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 <= -1.65e+129) tmp = Float64(fma(Float64(-x_46_re), Float64(y_46_im / y_46_re), x_46_im) / y_46_re); elseif (y_46_re <= 48000000000.0) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); else tmp = Float64(fma(Float64(Float64(-x_46_re) / y_46_re), y_46_im, 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, -1.65e+129], 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$re, 48000000000.0], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(N[((-x$46$re) / y$46$re), $MachinePrecision] * y$46$im + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-x.re, \frac{y.im}{y.re}, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 48000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-x.re}{y.re}, y.im, x.im\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129Initial program 34.9%
Taylor expanded in y.im around 0
Applied rewrites86.6%
Applied rewrites86.0%
if -1.64999999999999995e129 < y.re < 4.8e10Initial program 73.5%
Taylor expanded in y.im around inf
Applied rewrites73.4%
if 4.8e10 < y.re Initial program 47.0%
Applied rewrites47.0%
Taylor expanded in y.re around 0
Applied rewrites26.6%
Taylor expanded in y.re around inf
Applied rewrites78.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)))
(if (<= y.re -1.65e+129)
t_0
(if (<= y.re 95000000000.0)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(-x_46_re, (y_46_im / y_46_re), x_46_im) / y_46_re;
double tmp;
if (y_46_re <= -1.65e+129) {
tmp = t_0;
} else if (y_46_re <= 95000000000.0) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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(-x_46_re), Float64(y_46_im / y_46_re), x_46_im) / y_46_re) tmp = 0.0 if (y_46_re <= -1.65e+129) tmp = t_0; elseif (y_46_re <= 95000000000.0) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.65e+129], t$95$0, If[LessEqual[y$46$re, 95000000000.0], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-x.re, \frac{y.im}{y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.re \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 95000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.64999999999999995e129 or 9.5e10 < y.re Initial program 42.3%
Taylor expanded in y.im around 0
Applied rewrites81.3%
Applied rewrites80.7%
if -1.64999999999999995e129 < y.re < 9.5e10Initial program 73.5%
Taylor expanded in y.im around inf
Applied rewrites73.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma x.im (/ y.re y.im) (- x.re)) y.im)))
(if (<= y.im -2.7e-12)
t_0
(if (<= y.im 9e-23) (/ (- x.im (/ (* y.im x.re) y.re)) 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 = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
double tmp;
if (y_46_im <= -2.7e-12) {
tmp = t_0;
} else if (y_46_im <= 9e-23) {
tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / 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(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -2.7e-12) tmp = t_0; elseif (y_46_im <= 9e-23) tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / 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[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.7e-12], t$95$0, If[LessEqual[y$46$im, 9e-23], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.7 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 9 \cdot 10^{-23}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -2.6999999999999998e-12 or 8.9999999999999995e-23 < y.im Initial program 49.9%
Taylor expanded in y.im around inf
Applied rewrites74.7%
if -2.6999999999999998e-12 < y.im < 8.9999999999999995e-23Initial program 74.0%
Taylor expanded in y.re around inf
Applied rewrites82.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- x.re) y.im)))
(if (<= y.im -2.9e-12)
t_0
(if (<= y.im 3.6e+78) (/ (- x.im (/ (* y.im x.re) y.re)) 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 <= -2.9e-12) {
tmp = t_0;
} else if (y_46_im <= 3.6e+78) {
tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
real(8) :: tmp
t_0 = -x_46re / y_46im
if (y_46im <= (-2.9d-12)) then
tmp = t_0
else if (y_46im <= 3.6d+78) then
tmp = (x_46im - ((y_46im * x_46re) / y_46re)) / y_46re
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -2.9e-12) {
tmp = t_0;
} else if (y_46_im <= 3.6e+78) {
tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = -x_46_re / y_46_im tmp = 0 if y_46_im <= -2.9e-12: tmp = t_0 elif y_46_im <= 3.6e+78: tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / 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 <= -2.9e-12) tmp = t_0; elseif (y_46_im <= 3.6e+78) tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = -x_46_re / y_46_im; tmp = 0.0; if (y_46_im <= -2.9e-12) tmp = t_0; elseif (y_46_im <= 3.6e+78) tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.9e-12], t$95$0, If[LessEqual[y$46$im, 3.6e+78], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / 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 -2.9 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 3.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -2.9000000000000002e-12 or 3.6000000000000002e78 < y.im Initial program 45.3%
Taylor expanded in y.re around 0
Applied rewrites66.9%
if -2.9000000000000002e-12 < y.im < 3.6000000000000002e78Initial program 74.2%
Taylor expanded in y.re around inf
Applied rewrites77.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -1.5e+61) (/ x.im y.re) (if (<= y.re 4.6e-33) (/ (- 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 <= -1.5e+61) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 4.6e-33) {
tmp = -x_46_re / y_46_im;
} 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) :: tmp
if (y_46re <= (-1.5d+61)) then
tmp = x_46im / y_46re
else if (y_46re <= 4.6d-33) then
tmp = -x_46re / y_46im
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 tmp;
if (y_46_re <= -1.5e+61) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= 4.6e-33) {
tmp = -x_46_re / y_46_im;
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -1.5e+61: tmp = x_46_im / y_46_re elif y_46_re <= 4.6e-33: 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 <= -1.5e+61) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= 4.6e-33) tmp = Float64(Float64(-x_46_re) / y_46_im); 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) tmp = 0.0; if (y_46_re <= -1.5e+61) tmp = x_46_im / y_46_re; elseif (y_46_re <= 4.6e-33) tmp = -x_46_re / y_46_im; 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_] := If[LessEqual[y$46$re, -1.5e+61], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 4.6e-33], 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 -1.5 \cdot 10^{+61}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq 4.6 \cdot 10^{-33}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -1.5e61 or 4.59999999999999971e-33 < y.re Initial program 48.2%
Taylor expanded in y.re around inf
Applied rewrites66.0%
if -1.5e61 < y.re < 4.59999999999999971e-33Initial program 73.7%
Taylor expanded in y.re around 0
Applied rewrites62.5%
(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 61.6%
Taylor expanded in y.re around inf
Applied rewrites43.4%
herbie shell --seed 2025101
(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))))