
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(*
(/ (fma x.re (/ y.re x.im) y.im) (fma y.im y.im (* y.re y.re)))
x.im)))
(if (<= y.re -1.7e+63)
(/ (fma y.im (/ x.im y.re) x.re) y.re)
(if (<= y.re -3.6e-98)
t_0
(if (<= y.re 8e-123)
(- (/ (+ (- (/ (* y.re x.re) y.im)) (- x.im)) y.im))
(if (<= y.re 1.66e+43)
t_0
(- (fma (/ x.im y.re) (/ y.im (- y.re)) (/ (- x.re) y.re)))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (fma(x_46_re, (y_46_re / x_46_im), y_46_im) / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
double tmp;
if (y_46_re <= -1.7e+63) {
tmp = fma(y_46_im, (x_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_re <= -3.6e-98) {
tmp = t_0;
} else if (y_46_re <= 8e-123) {
tmp = -((-((y_46_re * x_46_re) / y_46_im) + -x_46_im) / y_46_im);
} else if (y_46_re <= 1.66e+43) {
tmp = t_0;
} else {
tmp = -fma((x_46_im / y_46_re), (y_46_im / -y_46_re), (-x_46_re / y_46_re));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(fma(x_46_re, Float64(y_46_re / x_46_im), y_46_im) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im) tmp = 0.0 if (y_46_re <= -1.7e+63) tmp = Float64(fma(y_46_im, Float64(x_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_re <= -3.6e-98) tmp = t_0; elseif (y_46_re <= 8e-123) tmp = Float64(-Float64(Float64(Float64(-Float64(Float64(y_46_re * x_46_re) / y_46_im)) + Float64(-x_46_im)) / y_46_im)); elseif (y_46_re <= 1.66e+43) tmp = t_0; else tmp = Float64(-fma(Float64(x_46_im / y_46_re), Float64(y_46_im / Float64(-y_46_re)), Float64(Float64(-x_46_re) / 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$re * N[(y$46$re / x$46$im), $MachinePrecision] + y$46$im), $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$re, -1.7e+63], N[(N[(y$46$im * N[(x$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -3.6e-98], t$95$0, If[LessEqual[y$46$re, 8e-123], (-N[(N[((-N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]) + (-x$46$im)), $MachinePrecision] / y$46$im), $MachinePrecision]), If[LessEqual[y$46$re, 1.66e+43], t$95$0, (-N[(N[(x$46$im / y$46$re), $MachinePrecision] * N[(y$46$im / (-y$46$re)), $MachinePrecision] + N[((-x$46$re) / y$46$re), $MachinePrecision]), $MachinePrecision])]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.re, \frac{y.re}{x.im}, y.im\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{if}\;y.re \leq -1.7 \cdot 10^{+63}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 8 \cdot 10^{-123}:\\
\;\;\;\;-\frac{\left(-\frac{y.re \cdot x.re}{y.im}\right) + \left(-x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 1.66 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{x.im}{y.re}, \frac{y.im}{-y.re}, \frac{-x.re}{y.re}\right)\\
\end{array}
\end{array}
if y.re < -1.6999999999999999e63Initial program 43.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6481.6
Applied rewrites81.6%
lift-/.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6481.5
Applied rewrites81.5%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
if -1.6999999999999999e63 < y.re < -3.6000000000000002e-98 or 8.0000000000000005e-123 < y.re < 1.6600000000000001e43Initial program 77.9%
Taylor expanded in x.im around inf
*-commutativeN/A
lower-*.f64N/A
associate-/r*N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f6470.6
Applied rewrites70.6%
if -3.6000000000000002e-98 < y.re < 8.0000000000000005e-123Initial program 71.2%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6490.4
Applied rewrites90.4%
if 1.6600000000000001e43 < y.re Initial program 77.9%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6446.0
Applied rewrites46.0%
Taylor expanded in x.re around 0
+-commutativeN/A
associate-*r/N/A
associate-*r*N/A
pow2N/A
sqr-neg-revN/A
times-fracN/A
mul-1-negN/A
frac-2negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6445.1
Applied rewrites45.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma y.re x.re (* y.im x.im)) (+ (* y.re y.re) (* y.im y.im))))
(t_1 (/ (fma x.re (/ y.re y.im) x.im) y.im)))
(if (<= y.im -8e+127)
t_1
(if (<= y.im -2.8e-98)
t_0
(if (<= y.im 4.1e-113)
(/ (+ (* (/ y.im y.re) x.im) x.re) y.re)
(if (<= y.im 5.7e+79) 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(y_46_re, x_46_re, (y_46_im * x_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -8e+127) {
tmp = t_1;
} else if (y_46_im <= -2.8e-98) {
tmp = t_0;
} else if (y_46_im <= 4.1e-113) {
tmp = (((y_46_im / y_46_re) * x_46_im) + x_46_re) / y_46_re;
} else if (y_46_im <= 5.7e+79) {
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(y_46_re, x_46_re, Float64(y_46_im * x_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) t_1 = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -8e+127) tmp = t_1; elseif (y_46_im <= -2.8e-98) tmp = t_0; elseif (y_46_im <= 4.1e-113) tmp = Float64(Float64(Float64(Float64(y_46_im / y_46_re) * x_46_im) + x_46_re) / y_46_re); elseif (y_46_im <= 5.7e+79) 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[(y$46$re * x$46$re + N[(y$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -8e+127], t$95$1, If[LessEqual[y$46$im, -2.8e-98], t$95$0, If[LessEqual[y$46$im, 4.1e-113], N[(N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.7e+79], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -8 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -2.8 \cdot 10^{-98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 4.1 \cdot 10^{-113}:\\
\;\;\;\;\frac{\frac{y.im}{y.re} \cdot x.im + x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 5.7 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -7.99999999999999964e127 or 5.6999999999999997e79 < y.im Initial program 38.1%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.9
Applied rewrites84.9%
if -7.99999999999999964e127 < y.im < -2.7999999999999999e-98 or 4.1e-113 < y.im < 5.6999999999999997e79Initial program 75.6%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
if -2.7999999999999999e-98 < y.im < 4.1e-113Initial program 71.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6488.8
Applied rewrites88.8%
lift-/.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6488.8
Applied rewrites88.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -3.8e-52)
(/ (fma y.im (/ x.im y.re) x.re) y.re)
(if (<= y.re 1.45e+47)
(- (/ (+ (- (/ (* y.re x.re) y.im)) (- x.im)) y.im))
(- (fma (/ x.im y.re) (/ y.im (- y.re)) (/ (- x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -3.8e-52) {
tmp = fma(y_46_im, (x_46_im / y_46_re), x_46_re) / y_46_re;
} else if (y_46_re <= 1.45e+47) {
tmp = -((-((y_46_re * x_46_re) / y_46_im) + -x_46_im) / y_46_im);
} else {
tmp = -fma((x_46_im / y_46_re), (y_46_im / -y_46_re), (-x_46_re / y_46_re));
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -3.8e-52) tmp = Float64(fma(y_46_im, Float64(x_46_im / y_46_re), x_46_re) / y_46_re); elseif (y_46_re <= 1.45e+47) tmp = Float64(-Float64(Float64(Float64(-Float64(Float64(y_46_re * x_46_re) / y_46_im)) + Float64(-x_46_im)) / y_46_im)); else tmp = Float64(-fma(Float64(x_46_im / y_46_re), Float64(y_46_im / Float64(-y_46_re)), Float64(Float64(-x_46_re) / y_46_re))); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -3.8e-52], N[(N[(y$46$im * N[(x$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.45e+47], (-N[(N[((-N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]) + (-x$46$im)), $MachinePrecision] / y$46$im), $MachinePrecision]), (-N[(N[(x$46$im / y$46$re), $MachinePrecision] * N[(y$46$im / (-y$46$re)), $MachinePrecision] + N[((-x$46$re) / y$46$re), $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -3.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 1.45 \cdot 10^{+47}:\\
\;\;\;\;-\frac{\left(-\frac{y.re \cdot x.re}{y.im}\right) + \left(-x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{x.im}{y.re}, \frac{y.im}{-y.re}, \frac{-x.re}{y.re}\right)\\
\end{array}
\end{array}
if y.re < -3.8000000000000003e-52Initial program 54.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6470.9
Applied rewrites70.9%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
if -3.8000000000000003e-52 < y.re < 1.4499999999999999e47Initial program 73.9%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6480.6
Applied rewrites80.6%
if 1.4499999999999999e47 < y.re Initial program 44.3%
Taylor expanded in y.re around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6475.6
Applied rewrites75.6%
Taylor expanded in x.re around 0
+-commutativeN/A
associate-*r/N/A
associate-*r*N/A
pow2N/A
sqr-neg-revN/A
times-fracN/A
mul-1-negN/A
frac-2negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6480.0
Applied rewrites80.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma y.im (/ x.im y.re) x.re) y.re)))
(if (<= y.re -3.8e-52)
t_0
(if (<= y.re 1.45e+47)
(- (/ (+ (- (/ (* y.re x.re) y.im)) (- x.im)) y.im))
t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, (x_46_im / y_46_re), x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -3.8e-52) {
tmp = t_0;
} else if (y_46_re <= 1.45e+47) {
tmp = -((-((y_46_re * x_46_re) / y_46_im) + -x_46_im) / y_46_im);
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(y_46_im, Float64(x_46_im / y_46_re), x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -3.8e-52) tmp = t_0; elseif (y_46_re <= 1.45e+47) tmp = Float64(-Float64(Float64(Float64(-Float64(Float64(y_46_re * x_46_re) / y_46_im)) + Float64(-x_46_im)) / y_46_im)); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$im * N[(x$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -3.8e-52], t$95$0, If[LessEqual[y$46$re, 1.45e+47], (-N[(N[((-N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]) + (-x$46$im)), $MachinePrecision] / y$46$im), $MachinePrecision]), t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -3.8 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.45 \cdot 10^{+47}:\\
\;\;\;\;-\frac{\left(-\frac{y.re \cdot x.re}{y.im}\right) + \left(-x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -3.8000000000000003e-52 or 1.4499999999999999e47 < y.re Initial program 50.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.4
Applied rewrites74.4%
lift-/.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6474.4
Applied rewrites74.4%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6475.1
Applied rewrites75.1%
if -3.8000000000000003e-52 < y.re < 1.4499999999999999e47Initial program 73.9%
Taylor expanded in y.im around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6480.6
Applied rewrites80.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma y.im (/ x.im y.re) x.re) y.re)))
(if (<= y.re -3.8e-52)
t_0
(if (<= y.re 1.45e+47) (/ (fma x.re (/ y.re y.im) x.im) y.im) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, (x_46_im / y_46_re), x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -3.8e-52) {
tmp = t_0;
} else if (y_46_re <= 1.45e+47) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(y_46_im, Float64(x_46_im / y_46_re), x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -3.8e-52) tmp = t_0; elseif (y_46_re <= 1.45e+47) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$im * N[(x$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -3.8e-52], t$95$0, If[LessEqual[y$46$re, 1.45e+47], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -3.8 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.45 \cdot 10^{+47}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -3.8000000000000003e-52 or 1.4499999999999999e47 < y.re Initial program 50.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.4
Applied rewrites74.4%
lift-/.f64N/A
lift-fma.f64N/A
associate-/l*N/A
lower-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6474.4
Applied rewrites74.4%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6475.1
Applied rewrites75.1%
if -3.8000000000000003e-52 < y.re < 1.4499999999999999e47Initial program 73.9%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re)))
(if (<= y.re -3.8e-52)
t_0
(if (<= y.re 1.45e+47) (/ (fma x.re (/ y.re y.im) x.im) y.im) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -3.8e-52) {
tmp = t_0;
} else if (y_46_re <= 1.45e+47) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -3.8e-52) tmp = t_0; elseif (y_46_re <= 1.45e+47) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -3.8e-52], t$95$0, If[LessEqual[y$46$re, 1.45e+47], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -3.8 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.45 \cdot 10^{+47}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -3.8000000000000003e-52 or 1.4499999999999999e47 < y.re Initial program 50.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.4
Applied rewrites74.4%
if -3.8000000000000003e-52 < y.re < 1.4499999999999999e47Initial program 73.9%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -5.5e+118)
(/ x.im y.im)
(if (<= y.im 2.7e+51)
(/ (fma x.im (/ y.im y.re) x.re) y.re)
(/ x.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_im <= -5.5e+118) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 2.7e+51) {
tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_im <= -5.5e+118) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 2.7e+51) tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -5.5e+118], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.7e+51], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -5.5 \cdot 10^{+118}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 2.7 \cdot 10^{+51}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -5.5000000000000003e118 or 2.69999999999999992e51 < y.im Initial program 41.2%
Taylor expanded in y.re around 0
lower-/.f6472.4
Applied rewrites72.4%
if -5.5000000000000003e118 < y.im < 2.69999999999999992e51Initial program 73.4%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6471.9
Applied rewrites71.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -3.6e-52) (/ x.re y.re) (if (<= y.re 7.6e-7) (/ x.im y.im) (/ x.re y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -3.6e-52) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 7.6e-7) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if (y_46re <= (-3.6d-52)) then
tmp = x_46re / y_46re
else if (y_46re <= 7.6d-7) then
tmp = x_46im / y_46im
else
tmp = x_46re / y_46re
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -3.6e-52) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 7.6e-7) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if y_46_re <= -3.6e-52: tmp = x_46_re / y_46_re elif y_46_re <= 7.6e-7: tmp = x_46_im / y_46_im else: tmp = x_46_re / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -3.6e-52) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 7.6e-7) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(x_46_re / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if (y_46_re <= -3.6e-52) tmp = x_46_re / y_46_re; elseif (y_46_re <= 7.6e-7) tmp = x_46_im / y_46_im; else tmp = x_46_re / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -3.6e-52], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.6e-7], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -3.6 \cdot 10^{-52}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 7.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -3.59999999999999988e-52 or 7.60000000000000029e-7 < y.re Initial program 52.0%
Taylor expanded in y.re around inf
lower-/.f6461.8
Applied rewrites61.8%
if -3.59999999999999988e-52 < y.re < 7.60000000000000029e-7Initial program 73.8%
Taylor expanded in y.re around 0
lower-/.f6465.8
Applied rewrites65.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = x_46im / y_46im
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_im) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.im}
\end{array}
Initial program 61.9%
Taylor expanded in y.re around 0
lower-/.f6443.1
Applied rewrites43.1%
herbie shell --seed 2025134
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, real part"
:precision binary64
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))