
(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 7 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 (/ (- x.im (* y.im (/ x.re y.re))) y.re)))
(if (<= y.re -8.2e+116)
t_0
(if (<= y.re -5.6e-99)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
(if (<= y.re 4.4e-26)
(/ (fma (/ y.re y.im) x.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 = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
double tmp;
if (y_46_re <= -8.2e+116) {
tmp = t_0;
} else if (y_46_re <= -5.6e-99) {
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 if (y_46_re <= 4.4e-26) {
tmp = fma((y_46_re / y_46_im), x_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(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / y_46_re) tmp = 0.0 if (y_46_re <= -8.2e+116) tmp = t_0; elseif (y_46_re <= -5.6e-99) 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))); elseif (y_46_re <= 4.4e-26) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_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$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -8.2e+116], t$95$0, If[LessEqual[y$46$re, -5.6e-99], 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, 4.4e-26], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
\mathbf{if}\;y.re \leq -8.2 \cdot 10^{+116}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq -5.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 4.4 \cdot 10^{-26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -8.1999999999999996e116 or 4.4000000000000002e-26 < y.re Initial program 47.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-*.f6483.7
Applied rewrites83.7%
Applied rewrites87.1%
if -8.1999999999999996e116 < y.re < -5.6000000000000001e-99Initial program 83.7%
if -5.6000000000000001e-99 < y.re < 4.4000000000000002e-26Initial program 62.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
fp-cancel-sub-sign-invN/A
associate-/l*N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.6
Applied rewrites87.6%
(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))))
(if (<= y.re -4.7e+117)
(/ x.im y.re)
(if (<= y.re -2.35e-17)
t_0
(if (<= y.re 5.2e-27)
(/ (- x.re) y.im)
(if (<= y.re 6.4e+85) t_0 (/ x.im y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_re * y_46_re);
double tmp;
if (y_46_re <= -4.7e+117) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= -2.35e-17) {
tmp = t_0;
} else if (y_46_re <= 5.2e-27) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 6.4e+85) {
tmp = t_0;
} 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)) / (y_46re * y_46re)
if (y_46re <= (-4.7d+117)) then
tmp = x_46im / y_46re
else if (y_46re <= (-2.35d-17)) then
tmp = t_0
else if (y_46re <= 5.2d-27) then
tmp = -x_46re / y_46im
else if (y_46re <= 6.4d+85) then
tmp = t_0
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)) / (y_46_re * y_46_re);
double tmp;
if (y_46_re <= -4.7e+117) {
tmp = x_46_im / y_46_re;
} else if (y_46_re <= -2.35e-17) {
tmp = t_0;
} else if (y_46_re <= 5.2e-27) {
tmp = -x_46_re / y_46_im;
} else if (y_46_re <= 6.4e+85) {
tmp = t_0;
} 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)) / (y_46_re * y_46_re) tmp = 0 if y_46_re <= -4.7e+117: tmp = x_46_im / y_46_re elif y_46_re <= -2.35e-17: tmp = t_0 elif y_46_re <= 5.2e-27: tmp = -x_46_re / y_46_im elif y_46_re <= 6.4e+85: tmp = t_0 else: tmp = x_46_im / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(y_46_re * y_46_re)) tmp = 0.0 if (y_46_re <= -4.7e+117) tmp = Float64(x_46_im / y_46_re); elseif (y_46_re <= -2.35e-17) tmp = t_0; elseif (y_46_re <= 5.2e-27) tmp = Float64(Float64(-x_46_re) / y_46_im); elseif (y_46_re <= 6.4e+85) tmp = t_0; 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)) / (y_46_re * y_46_re); tmp = 0.0; if (y_46_re <= -4.7e+117) tmp = x_46_im / y_46_re; elseif (y_46_re <= -2.35e-17) tmp = t_0; elseif (y_46_re <= 5.2e-27) tmp = -x_46_re / y_46_im; elseif (y_46_re <= 6.4e+85) tmp = t_0; 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[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -4.7e+117], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -2.35e-17], t$95$0, If[LessEqual[y$46$re, 5.2e-27], N[((-x$46$re) / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.4e+85], t$95$0, N[(x$46$im / 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}\\
\mathbf{if}\;y.re \leq -4.7 \cdot 10^{+117}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{elif}\;y.re \leq -2.35 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 5.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{elif}\;y.re \leq 6.4 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.re < -4.70000000000000006e117 or 6.40000000000000037e85 < y.re Initial program 38.7%
Taylor expanded in y.re around inf
lower-/.f6475.3
Applied rewrites75.3%
if -4.70000000000000006e117 < y.re < -2.35e-17 or 5.20000000000000034e-27 < y.re < 6.40000000000000037e85Initial program 88.4%
Taylor expanded in y.re around inf
unpow2N/A
lower-*.f6468.6
Applied rewrites68.6%
if -2.35e-17 < y.re < 5.20000000000000034e-27Initial program 63.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.f6468.7
Applied rewrites68.7%
Final simplification71.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -3.4e+50) (not (<= y.re 4.4e-26))) (/ (- x.im (* y.im (/ x.re y.re))) 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 <= -3.4e+50) || !(y_46_re <= 4.4e-26)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / 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 <= -3.4e+50) || !(y_46_re <= 4.4e-26)) tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / 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, -3.4e+50], N[Not[LessEqual[y$46$re, 4.4e-26]], $MachinePrecision]], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(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 -3.4 \cdot 10^{+50} \lor \neg \left(y.re \leq 4.4 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{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 < -3.3999999999999998e50 or 4.4000000000000002e-26 < y.re Initial program 50.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-*.f6483.5
Applied rewrites83.5%
Applied rewrites86.6%
if -3.3999999999999998e50 < y.re < 4.4000000000000002e-26Initial program 66.8%
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
fp-cancel-sub-sign-invN/A
associate-/l*N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6481.0
Applied rewrites81.0%
Final simplification83.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -3.4e+50) (not (<= y.re 4.4e-26))) (/ (- x.im (* y.im (/ x.re y.re))) y.re) (/ (fma y.re (/ x.im y.im) (- x.re)) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -3.4e+50) || !(y_46_re <= 4.4e-26)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
} else {
tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -3.4e+50) || !(y_46_re <= 4.4e-26)) tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / y_46_re); else tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -3.4e+50], N[Not[LessEqual[y$46$re, 4.4e-26]], $MachinePrecision]], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -3.4 \cdot 10^{+50} \lor \neg \left(y.re \leq 4.4 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\end{array}
\end{array}
if y.re < -3.3999999999999998e50 or 4.4000000000000002e-26 < y.re Initial program 50.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-*.f6483.5
Applied rewrites83.5%
Applied rewrites86.6%
if -3.3999999999999998e50 < y.re < 4.4000000000000002e-26Initial program 66.8%
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
fp-cancel-sub-sign-invN/A
associate-/l*N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6481.0
Applied rewrites81.0%
Applied rewrites78.8%
Final simplification82.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.35e-17) (not (<= y.re 5.3e-27))) (/ (- x.im (* y.im (/ x.re y.re))) 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 <= -2.35e-17) || !(y_46_re <= 5.3e-27)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / 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 <= (-2.35d-17)) .or. (.not. (y_46re <= 5.3d-27))) then
tmp = (x_46im - (y_46im * (x_46re / y_46re))) / 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 <= -2.35e-17) || !(y_46_re <= 5.3e-27)) {
tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / 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 <= -2.35e-17) or not (y_46_re <= 5.3e-27): tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / 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 <= -2.35e-17) || !(y_46_re <= 5.3e-27)) tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / 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 <= -2.35e-17) || ~((y_46_re <= 5.3e-27))) tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / 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, -2.35e-17], N[Not[LessEqual[y$46$re, 5.3e-27]], $MachinePrecision]], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[((-x$46$re) / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.35 \cdot 10^{-17} \lor \neg \left(y.re \leq 5.3 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -2.35e-17 or 5.30000000000000006e-27 < y.re Initial program 54.3%
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-*.f6479.6
Applied rewrites79.6%
Applied rewrites82.3%
if -2.35e-17 < y.re < 5.30000000000000006e-27Initial program 63.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.f6468.7
Applied rewrites68.7%
Final simplification76.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.05e+40) (not (<= y.re 1.5e-19))) (/ 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 <= -2.05e+40) || !(y_46_re <= 1.5e-19)) {
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 <= (-2.05d+40)) .or. (.not. (y_46re <= 1.5d-19))) 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 <= -2.05e+40) || !(y_46_re <= 1.5e-19)) {
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 <= -2.05e+40) or not (y_46_re <= 1.5e-19): 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 <= -2.05e+40) || !(y_46_re <= 1.5e-19)) 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 <= -2.05e+40) || ~((y_46_re <= 1.5e-19))) 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, -2.05e+40], N[Not[LessEqual[y$46$re, 1.5e-19]], $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 -2.05 \cdot 10^{+40} \lor \neg \left(y.re \leq 1.5 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -2.0500000000000001e40 or 1.49999999999999996e-19 < y.re Initial program 50.0%
Taylor expanded in y.re around inf
lower-/.f6470.7
Applied rewrites70.7%
if -2.0500000000000001e40 < y.re < 1.49999999999999996e-19Initial program 66.8%
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.f6463.9
Applied rewrites63.9%
Final simplification67.2%
(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 58.7%
Taylor expanded in y.re around inf
lower-/.f6443.6
Applied rewrites43.6%
herbie shell --seed 2024357
(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))))