
(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 y.re y.re (* y.im y.im))))
(if (<= y.im -88000000.0)
(fma (/ y.re y.im) (/ x.re y.im) (/ x.im y.im))
(if (<= y.im 6.8e-86)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(if (<= y.im 4.2e+101)
(fma (/ y.im t_0) x.im (* (/ y.re t_0) x.re))
(/ (fma (* (/ 1.0 y.im) y.re) x.re x.im) y.im))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_re, y_46_re, (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -88000000.0) {
tmp = fma((y_46_re / y_46_im), (x_46_re / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= 6.8e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 4.2e+101) {
tmp = fma((y_46_im / t_0), x_46_im, ((y_46_re / t_0) * x_46_re));
} else {
tmp = fma(((1.0 / y_46_im) * y_46_re), x_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)) tmp = 0.0 if (y_46_im <= -88000000.0) tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_re / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= 6.8e-86) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 4.2e+101) tmp = fma(Float64(y_46_im / t_0), x_46_im, Float64(Float64(y_46_re / t_0) * x_46_re)); else tmp = Float64(fma(Float64(Float64(1.0 / y_46_im) * y_46_re), x_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_] := Block[{t$95$0 = N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -88000000.0], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 6.8e-86], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 4.2e+101], N[(N[(y$46$im / t$95$0), $MachinePrecision] * x$46$im + N[(N[(y$46$re / t$95$0), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)\\
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq 6.8 \cdot 10^{-86}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 4.2 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.im}{t\_0}, x.im, \frac{y.re}{t\_0} \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{y.im} \cdot y.re, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.8e7Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites53.0%
if -8.8e7 < y.im < 6.8000000000000001e-86Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
if 6.8000000000000001e-86 < y.im < 4.2e101Initial program 61.6%
Applied rewrites62.1%
Applied rewrites64.5%
if 4.2e101 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.re y.re (* y.im y.im))))
(if (<= y.im -88000000.0)
(fma (/ y.re y.im) (/ x.re y.im) (/ x.im y.im))
(if (<= y.im 5.1e-86)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(if (<= y.im 2.05e+101)
(fma (/ x.im t_0) y.im (/ (* x.re y.re) t_0))
(/ (fma (* (/ 1.0 y.im) y.re) x.re x.im) y.im))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_re, y_46_re, (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -88000000.0) {
tmp = fma((y_46_re / y_46_im), (x_46_re / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= 5.1e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 2.05e+101) {
tmp = fma((x_46_im / t_0), y_46_im, ((x_46_re * y_46_re) / t_0));
} else {
tmp = fma(((1.0 / y_46_im) * y_46_re), x_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)) tmp = 0.0 if (y_46_im <= -88000000.0) tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_re / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= 5.1e-86) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 2.05e+101) tmp = fma(Float64(x_46_im / t_0), y_46_im, Float64(Float64(x_46_re * y_46_re) / t_0)); else tmp = Float64(fma(Float64(Float64(1.0 / y_46_im) * y_46_re), x_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_] := Block[{t$95$0 = N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -88000000.0], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.1e-86], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 2.05e+101], N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$im + N[(N[(x$46$re * y$46$re), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)\\
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq 5.1 \cdot 10^{-86}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 2.05 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{t\_0}, y.im, \frac{x.re \cdot y.re}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{y.im} \cdot y.re, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.8e7Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites53.0%
if -8.8e7 < y.im < 5.10000000000000006e-86Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
if 5.10000000000000006e-86 < y.im < 2.05e101Initial program 61.6%
Applied rewrites58.6%
if 2.05e101 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -88000000.0)
(fma (/ y.re y.im) (/ x.re y.im) (/ x.im y.im))
(if (<= y.im 5.1e-86)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(if (<= y.im 1.6e+96)
(/ (fma y.re x.re (* x.im y.im)) (fma y.re y.re (* y.im y.im)))
(/ (fma (* (/ 1.0 y.im) y.re) x.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 <= -88000000.0) {
tmp = fma((y_46_re / y_46_im), (x_46_re / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= 5.1e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 1.6e+96) {
tmp = fma(y_46_re, x_46_re, (x_46_im * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
} else {
tmp = fma(((1.0 / y_46_im) * y_46_re), x_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_im <= -88000000.0) tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_re / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= 5.1e-86) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 1.6e+96) tmp = Float64(fma(y_46_re, x_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(Float64(1.0 / y_46_im) * y_46_re), x_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[LessEqual[y$46$im, -88000000.0], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.1e-86], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.6e+96], N[(N[(y$46$re * x$46$re + 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[(N[(1.0 / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq 5.1 \cdot 10^{-86}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 1.6 \cdot 10^{+96}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, x.re, x.im \cdot y.im\right)}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{y.im} \cdot y.re, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.8e7Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites53.0%
if -8.8e7 < y.im < 5.10000000000000006e-86Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
if 5.10000000000000006e-86 < y.im < 1.60000000000000003e96Initial program 61.6%
Applied rewrites61.6%
if 1.60000000000000003e96 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -88000000.0)
(fma (/ y.re y.im) (/ x.re y.im) (/ x.im y.im))
(if (<= y.im 6e+42)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(/ (fma (* (/ 1.0 y.im) y.re) x.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 <= -88000000.0) {
tmp = fma((y_46_re / y_46_im), (x_46_re / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= 6e+42) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = fma(((1.0 / y_46_im) * y_46_re), x_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_im <= -88000000.0) tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_re / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= 6e+42) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); else tmp = Float64(fma(Float64(Float64(1.0 / y_46_im) * y_46_re), x_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[LessEqual[y$46$im, -88000000.0], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$re / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 6e+42], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(N[(1.0 / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.re}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq 6 \cdot 10^{+42}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{y.im} \cdot y.re, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.8e7Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites53.0%
if -8.8e7 < y.im < 6.00000000000000058e42Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
if 6.00000000000000058e42 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -88000000.0)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.im 6e+42)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(/ (fma (* (/ 1.0 y.im) y.re) x.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 <= -88000000.0) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_im <= 6e+42) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = fma(((1.0 / y_46_im) * y_46_re), x_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_im <= -88000000.0) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_im <= 6e+42) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); else tmp = Float64(fma(Float64(Float64(1.0 / y_46_im) * y_46_re), x_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[LessEqual[y$46$im, -88000000.0], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 6e+42], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(N[(1.0 / y$46$im), $MachinePrecision] * y$46$re), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.im \leq 6 \cdot 10^{+42}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{y.im} \cdot y.re, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -8.8e7Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
if -8.8e7 < y.im < 6.00000000000000058e42Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
if 6.00000000000000058e42 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ y.re y.im) x.re x.im) y.im)))
(if (<= y.im -88000000.0)
t_0
(if (<= y.im 6e+42) (/ (+ x.re (/ (* x.im y.im) y.re)) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -88000000.0) {
tmp = t_0;
} else if (y_46_im <= 6e+42) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -88000000.0) tmp = t_0; elseif (y_46_im <= 6e+42) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -88000000.0], t$95$0, If[LessEqual[y$46$im, 6e+42], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -88000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 6 \cdot 10^{+42}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -8.8e7 or 6.00000000000000058e42 < y.im Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
if -8.8e7 < y.im < 6.00000000000000058e42Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites51.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -1.95e+89) (/ x.re y.re) (if (<= y.re 0.008) (/ (fma (/ y.re y.im) x.re 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 <= -1.95e+89) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 0.008) {
tmp = fma((y_46_re / y_46_im), x_46_re, 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 <= -1.95e+89) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 0.008) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_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, -1.95e+89], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 0.008], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.95 \cdot 10^{+89}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 0.008:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -1.95000000000000005e89 or 0.0080000000000000002 < y.re Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites42.4%
if -1.95000000000000005e89 < y.re < 0.0080000000000000002Initial program 61.6%
Taylor expanded in y.im around inf
Applied rewrites52.4%
Applied rewrites54.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -1.25e+89) (/ x.re y.re) (if (<= y.re 0.0008) (/ 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 <= -1.25e+89) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 0.0008) {
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 <= (-1.25d+89)) then
tmp = x_46re / y_46re
else if (y_46re <= 0.0008d0) 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 <= -1.25e+89) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 0.0008) {
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 <= -1.25e+89: tmp = x_46_re / y_46_re elif y_46_re <= 0.0008: 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 <= -1.25e+89) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 0.0008) 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 <= -1.25e+89) tmp = x_46_re / y_46_re; elseif (y_46_re <= 0.0008) 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, -1.25e+89], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 0.0008], 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 -1.25 \cdot 10^{+89}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 0.0008:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -1.24999999999999996e89 or 8.00000000000000038e-4 < y.re Initial program 61.6%
Taylor expanded in y.re around inf
Applied rewrites42.4%
if -1.24999999999999996e89 < y.re < 8.00000000000000038e-4Initial program 61.6%
Taylor expanded in y.re around 0
Applied rewrites43.1%
(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.6%
Taylor expanded in y.re around 0
Applied rewrites43.1%
herbie shell --seed 2025153
(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))))