
(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}
Sampling outcomes in binary64 precision:
Herbie found 10 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
(if (<= y.re -6.6e-18)
(/ (+ (* (/ x.im y.re) y.im) x.re) y.re)
(if (<= y.re 1.35e-136)
(/ (fma (/ x.re y.im) y.re x.im) y.im)
(if (<= y.re 3.8e+124)
(/ (+ (* x.re y.re) (* x.im y.im)) (fma y.re y.re (* y.im y.im)))
(/ (fma (/ x.im y.re) 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 <= -6.6e-18) {
tmp = (((x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re;
} else if (y_46_re <= 1.35e-136) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 3.8e+124) {
tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
} else {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -6.6e-18) tmp = Float64(Float64(Float64(Float64(x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re); elseif (y_46_re <= 1.35e-136) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 3.8e+124) tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))); else tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -6.6e-18], N[(N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.35e-136], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 3.8e+124], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im + x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 1.35 \cdot 10^{-136}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 3.8 \cdot 10^{+124}:\\
\;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -6.6000000000000003e-18Initial program 43.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites84.9%
if -6.6000000000000003e-18 < y.re < 1.3499999999999999e-136Initial program 68.7%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if 1.3499999999999999e-136 < y.re < 3.7999999999999998e124Initial program 84.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6484.2
Applied rewrites84.2%
if 3.7999999999999998e124 < y.re Initial program 35.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.re x.re (* y.im x.im))))
(if (<= y.re -3.1e-22)
(/ x.re y.re)
(if (<= y.re 3.9e-252)
(/ x.im y.im)
(if (<= y.re 1.1e-87)
(/ t_0 (* y.im y.im))
(if (<= y.re 1.3e+122) (/ t_0 (* y.re 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(y_46_re, x_46_re, (y_46_im * x_46_im));
double tmp;
if (y_46_re <= -3.1e-22) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 3.9e-252) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 1.1e-87) {
tmp = t_0 / (y_46_im * y_46_im);
} else if (y_46_re <= 1.3e+122) {
tmp = t_0 / (y_46_re * y_46_re);
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_re, x_46_re, Float64(y_46_im * x_46_im)) tmp = 0.0 if (y_46_re <= -3.1e-22) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 3.9e-252) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 1.1e-87) tmp = Float64(t_0 / Float64(y_46_im * y_46_im)); elseif (y_46_re <= 1.3e+122) tmp = Float64(t_0 / Float64(y_46_re * y_46_re)); else tmp = 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[(y$46$re * x$46$re + N[(y$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -3.1e-22], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 3.9e-252], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.1e-87], N[(t$95$0 / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.3e+122], N[(t$95$0 / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)\\
\mathbf{if}\;y.re \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 3.9 \cdot 10^{-252}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 1.1 \cdot 10^{-87}:\\
\;\;\;\;\frac{t\_0}{y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{+122}:\\
\;\;\;\;\frac{t\_0}{y.re \cdot y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -3.10000000000000013e-22 or 1.30000000000000004e122 < y.re Initial program 40.6%
Taylor expanded in y.re around inf
lower-/.f6478.0
Applied rewrites78.0%
if -3.10000000000000013e-22 < y.re < 3.8999999999999999e-252Initial program 62.0%
Taylor expanded in y.re around 0
lower-/.f6472.7
Applied rewrites72.7%
if 3.8999999999999999e-252 < y.re < 1.09999999999999994e-87Initial program 88.6%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6477.3
Applied rewrites77.3%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.3
Applied rewrites77.3%
if 1.09999999999999994e-87 < y.re < 1.30000000000000004e122Initial program 84.0%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in y.re around inf
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -3.1e-22)
(/ x.re y.re)
(if (<= y.re 3.9e-252)
(/ x.im y.im)
(if (<= y.re 2.5e-53)
(/ (fma y.re x.re (* y.im x.im)) (* y.im y.im))
(if (<= y.re 1.35e+132)
(* x.re (/ y.re (fma y.re y.re (* y.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.1e-22) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 3.9e-252) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 2.5e-53) {
tmp = fma(y_46_re, x_46_re, (y_46_im * x_46_im)) / (y_46_im * y_46_im);
} else if (y_46_re <= 1.35e+132) {
tmp = x_46_re * (y_46_re / fma(y_46_re, y_46_re, (y_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.1e-22) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 3.9e-252) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 2.5e-53) tmp = Float64(fma(y_46_re, x_46_re, Float64(y_46_im * x_46_im)) / Float64(y_46_im * y_46_im)); elseif (y_46_re <= 1.35e+132) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)))); else tmp = 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.1e-22], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 3.9e-252], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 2.5e-53], N[(N[(y$46$re * x$46$re + N[(y$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.35e+132], N[(x$46$re * N[(y$46$re / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 3.9 \cdot 10^{-252}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 2.5 \cdot 10^{-53}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)}{y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 1.35 \cdot 10^{+132}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -3.10000000000000013e-22 or 1.35e132 < y.re Initial program 40.9%
Taylor expanded in y.re around inf
lower-/.f6478.7
Applied rewrites78.7%
if -3.10000000000000013e-22 < y.re < 3.8999999999999999e-252Initial program 62.0%
Taylor expanded in y.re around 0
lower-/.f6472.7
Applied rewrites72.7%
if 3.8999999999999999e-252 < y.re < 2.5e-53Initial program 87.6%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6470.8
Applied rewrites70.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
Applied rewrites70.8%
if 2.5e-53 < y.re < 1.35e132Initial program 82.4%
Taylor expanded in x.re around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
unpow2N/A
distribute-lft-neg-outN/A
metadata-evalN/A
associate-*r*N/A
unpow2N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6455.3
Applied rewrites55.3%
Applied rewrites57.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -6.6e-18)
(/ (+ (* (/ x.im y.re) y.im) x.re) y.re)
(if (<= y.re 1.35e-136)
(/ (fma (/ x.re y.im) y.re x.im) y.im)
(if (<= y.re 3.8e+124)
(/ (fma y.im x.im (* y.re x.re)) (fma y.im y.im (* y.re y.re)))
(/ (fma (/ x.im y.re) 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 <= -6.6e-18) {
tmp = (((x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re;
} else if (y_46_re <= 1.35e-136) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 3.8e+124) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
} else {
tmp = fma((x_46_im / y_46_re), y_46_im, 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 <= -6.6e-18) tmp = Float64(Float64(Float64(Float64(x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re); elseif (y_46_re <= 1.35e-136) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 3.8e+124) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))); else tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -6.6e-18], N[(N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.35e-136], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 3.8e+124], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im + x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 1.35 \cdot 10^{-136}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 3.8 \cdot 10^{+124}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -6.6000000000000003e-18Initial program 43.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites84.9%
if -6.6000000000000003e-18 < y.re < 1.3499999999999999e-136Initial program 68.7%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if 1.3499999999999999e-136 < y.re < 3.7999999999999998e124Initial program 84.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6484.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6484.1
Applied rewrites84.1%
if 3.7999999999999998e124 < y.re Initial program 35.6%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -3.1e-22)
(/ x.re y.re)
(if (<= y.re 2.25e-128)
(/ x.im y.im)
(if (<= y.re 1.35e+132)
(* x.re (/ y.re (fma y.re y.re (* y.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.1e-22) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 2.25e-128) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 1.35e+132) {
tmp = x_46_re * (y_46_re / fma(y_46_re, y_46_re, (y_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.1e-22) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 2.25e-128) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 1.35e+132) tmp = Float64(x_46_re * Float64(y_46_re / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)))); else tmp = 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.1e-22], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2.25e-128], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.35e+132], N[(x$46$re * N[(y$46$re / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 2.25 \cdot 10^{-128}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 1.35 \cdot 10^{+132}:\\
\;\;\;\;x.re \cdot \frac{y.re}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -3.10000000000000013e-22 or 1.35e132 < y.re Initial program 40.9%
Taylor expanded in y.re around inf
lower-/.f6478.7
Applied rewrites78.7%
if -3.10000000000000013e-22 < y.re < 2.25e-128Initial program 69.0%
Taylor expanded in y.re around 0
lower-/.f6469.9
Applied rewrites69.9%
if 2.25e-128 < y.re < 1.35e132Initial program 83.6%
Taylor expanded in x.re around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
unpow2N/A
distribute-lft-neg-outN/A
metadata-evalN/A
associate-*r*N/A
unpow2N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.1
Applied rewrites51.1%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -6.6e-18) (not (<= y.re 0.205))) (/ (fma (/ x.im y.re) y.im x.re) y.re) (/ (fma (/ x.re y.im) 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_re <= -6.6e-18) || !(y_46_re <= 0.205)) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else {
tmp = fma((x_46_re / y_46_im), y_46_re, 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_re <= -6.6e-18) || !(y_46_re <= 0.205)) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); else tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / 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, -6.6e-18], N[Not[LessEqual[y$46$re, 0.205]], $MachinePrecision]], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18} \lor \neg \left(y.re \leq 0.205\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.re < -6.6000000000000003e-18 or 0.204999999999999988 < y.re Initial program 50.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6480.7
Applied rewrites80.7%
if -6.6000000000000003e-18 < y.re < 0.204999999999999988Initial program 72.4%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6483.7
Applied rewrites83.7%
Final simplification82.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1e+135) (not (<= y.im 2.65e-6))) (/ x.im y.im) (/ (fma (/ x.im y.re) 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_im <= -1e+135) || !(y_46_im <= 2.65e-6)) {
tmp = x_46_im / y_46_im;
} else {
tmp = fma((x_46_im / y_46_re), y_46_im, 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_im <= -1e+135) || !(y_46_im <= 2.65e-6)) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -1e+135], N[Not[LessEqual[y$46$im, 2.65e-6]], $MachinePrecision]], N[(x$46$im / y$46$im), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{+135} \lor \neg \left(y.im \leq 2.65 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.im < -9.99999999999999962e134 or 2.65e-6 < y.im Initial program 45.0%
Taylor expanded in y.re around 0
lower-/.f6470.2
Applied rewrites70.2%
if -9.99999999999999962e134 < y.im < 2.65e-6Initial program 69.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
Final simplification76.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -6.6e-18)
(/ (+ (* (/ x.im y.re) y.im) x.re) y.re)
(if (<= y.re 0.205)
(/ (fma (/ x.re y.im) y.re x.im) y.im)
(/ (fma (/ x.im y.re) 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 <= -6.6e-18) {
tmp = (((x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re;
} else if (y_46_re <= 0.205) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} else {
tmp = fma((x_46_im / y_46_re), y_46_im, 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 <= -6.6e-18) tmp = Float64(Float64(Float64(Float64(x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re); elseif (y_46_re <= 0.205) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); else tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -6.6e-18], N[(N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 0.205], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im + x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 0.205:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -6.6000000000000003e-18Initial program 43.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6484.8
Applied rewrites84.8%
Applied rewrites84.9%
if -6.6000000000000003e-18 < y.re < 0.204999999999999988Initial program 72.4%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6483.7
Applied rewrites83.7%
if 0.204999999999999988 < y.re Initial program 55.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-outN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6477.4
Applied rewrites77.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -3.6e+131) (not (<= y.im 1.25e+36))) (/ 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_im <= -3.6e+131) || !(y_46_im <= 1.25e+36)) {
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_46im <= (-3.6d+131)) .or. (.not. (y_46im <= 1.25d+36))) 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_im <= -3.6e+131) || !(y_46_im <= 1.25e+36)) {
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_im <= -3.6e+131) or not (y_46_im <= 1.25e+36): 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_im <= -3.6e+131) || !(y_46_im <= 1.25e+36)) 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_im <= -3.6e+131) || ~((y_46_im <= 1.25e+36))) 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[Or[LessEqual[y$46$im, -3.6e+131], N[Not[LessEqual[y$46$im, 1.25e+36]], $MachinePrecision]], 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.im \leq -3.6 \cdot 10^{+131} \lor \neg \left(y.im \leq 1.25 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -3.60000000000000031e131 or 1.24999999999999994e36 < y.im Initial program 42.0%
Taylor expanded in y.re around 0
lower-/.f6471.7
Applied rewrites71.7%
if -3.60000000000000031e131 < y.im < 1.24999999999999994e36Initial program 70.0%
Taylor expanded in y.re around inf
lower-/.f6466.9
Applied rewrites66.9%
Final simplification68.6%
(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 60.1%
Taylor expanded in y.re around 0
lower-/.f6438.8
Applied rewrites38.8%
herbie shell --seed 2025015
(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))))