
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re))))
(if (<= y.re -1.45e+90)
(/ (fma (/ y.im (- y.re)) x.re x.im) y.re)
(if (<= y.re -1.3e-140)
(- (* x.im (/ y.re t_0)) (* x.re (/ y.im t_0)))
(if (<= y.re 2.7e+88)
(/ (- (/ (* x.im y.re) y.im) x.re) y.im)
(/ (fma y.im (/ x.re y.re) (- x.im)) (- y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double tmp;
if (y_46_re <= -1.45e+90) {
tmp = fma((y_46_im / -y_46_re), x_46_re, x_46_im) / y_46_re;
} else if (y_46_re <= -1.3e-140) {
tmp = (x_46_im * (y_46_re / t_0)) - (x_46_re * (y_46_im / t_0));
} else if (y_46_re <= 2.7e+88) {
tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
} else {
tmp = fma(y_46_im, (x_46_re / y_46_re), -x_46_im) / -y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) tmp = 0.0 if (y_46_re <= -1.45e+90) tmp = Float64(fma(Float64(y_46_im / Float64(-y_46_re)), x_46_re, x_46_im) / y_46_re); elseif (y_46_re <= -1.3e-140) tmp = Float64(Float64(x_46_im * Float64(y_46_re / t_0)) - Float64(x_46_re * Float64(y_46_im / t_0))); elseif (y_46_re <= 2.7e+88) tmp = Float64(Float64(Float64(Float64(x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im); else tmp = Float64(fma(y_46_im, Float64(x_46_re / y_46_re), Float64(-x_46_im)) / Float64(-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$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.45e+90], N[(N[(N[(y$46$im / (-y$46$re)), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -1.3e-140], N[(N[(x$46$im * N[(y$46$re / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(x$46$re * N[(y$46$im / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 2.7e+88], N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
\mathbf{if}\;y.re \leq -1.45 \cdot 10^{+90}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{-y.re}, x.re, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -1.3 \cdot 10^{-140}:\\
\;\;\;\;x.im \cdot \frac{y.re}{t\_0} - x.re \cdot \frac{y.im}{t\_0}\\
\mathbf{elif}\;y.re \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.re}{y.re}, -x.im\right)}{-y.re}\\
\end{array}
\end{array}
if y.re < -1.4500000000000001e90Initial program 37.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6441.1
Applied rewrites41.1%
Taylor expanded in y.re around -inf
Applied rewrites90.6%
Taylor expanded in y.re around inf
Applied rewrites90.7%
if -1.4500000000000001e90 < y.re < -1.2999999999999999e-140Initial program 82.0%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6483.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6483.9
Applied rewrites83.9%
if -1.2999999999999999e-140 < y.re < 2.70000000000000016e88Initial program 66.1%
Taylor expanded in y.re around 0
Applied rewrites80.3%
if 2.70000000000000016e88 < y.re Initial program 35.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6443.0
Applied rewrites43.0%
Taylor expanded in y.re around -inf
Applied rewrites89.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -1.56e+90)
(/ (fma (/ y.im (- y.re)) x.re x.im) y.re)
(if (<= y.re -1.2e-129)
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
(if (<= y.re 2.7e+88)
(/ (- (/ (* x.im y.re) y.im) x.re) y.im)
(/ (fma y.im (/ x.re y.re) (- x.im)) (- y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -1.56e+90) {
tmp = fma((y_46_im / -y_46_re), x_46_re, x_46_im) / y_46_re;
} else if (y_46_re <= -1.2e-129) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
} else if (y_46_re <= 2.7e+88) {
tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
} else {
tmp = fma(y_46_im, (x_46_re / y_46_re), -x_46_im) / -y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -1.56e+90) tmp = Float64(fma(Float64(y_46_im / Float64(-y_46_re)), x_46_re, x_46_im) / y_46_re); elseif (y_46_re <= -1.2e-129) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))); elseif (y_46_re <= 2.7e+88) tmp = Float64(Float64(Float64(Float64(x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im); else tmp = Float64(fma(y_46_im, Float64(x_46_re / y_46_re), Float64(-x_46_im)) / Float64(-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.56e+90], N[(N[(N[(y$46$im / (-y$46$re)), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -1.2e-129], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 2.7e+88], N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.56 \cdot 10^{+90}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{-y.re}, x.re, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -1.2 \cdot 10^{-129}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.re}{y.re}, -x.im\right)}{-y.re}\\
\end{array}
\end{array}
if y.re < -1.56000000000000004e90Initial program 36.6%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6439.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6439.9
Applied rewrites39.9%
Taylor expanded in y.re around -inf
Applied rewrites90.4%
Taylor expanded in y.re around inf
Applied rewrites90.5%
if -1.56000000000000004e90 < y.re < -1.19999999999999994e-129Initial program 82.0%
if -1.19999999999999994e-129 < y.re < 2.70000000000000016e88Initial program 66.4%
Taylor expanded in y.re around 0
Applied rewrites80.5%
if 2.70000000000000016e88 < y.re Initial program 35.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6443.0
Applied rewrites43.0%
Taylor expanded in y.re around -inf
Applied rewrites89.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -7.2e+62)
(/ (fma (/ y.im (- y.re)) x.re x.im) y.re)
(if (<= y.re 2.7e+88)
(/ (- (/ (* x.im y.re) y.im) x.re) y.im)
(/ (fma y.im (/ x.re y.re) (- x.im)) (- y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -7.2e+62) {
tmp = fma((y_46_im / -y_46_re), x_46_re, x_46_im) / y_46_re;
} else if (y_46_re <= 2.7e+88) {
tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
} else {
tmp = fma(y_46_im, (x_46_re / y_46_re), -x_46_im) / -y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -7.2e+62) tmp = Float64(fma(Float64(y_46_im / Float64(-y_46_re)), x_46_re, x_46_im) / y_46_re); elseif (y_46_re <= 2.7e+88) tmp = Float64(Float64(Float64(Float64(x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im); else tmp = Float64(fma(y_46_im, Float64(x_46_re / y_46_re), Float64(-x_46_im)) / Float64(-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, -7.2e+62], N[(N[(N[(y$46$im / (-y$46$re)), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2.7e+88], N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision] + (-x$46$im)), $MachinePrecision] / (-y$46$re)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -7.2 \cdot 10^{+62}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{-y.re}, x.re, x.im\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.re}{y.re}, -x.im\right)}{-y.re}\\
\end{array}
\end{array}
if y.re < -7.2e62Initial program 43.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6446.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6446.0
Applied rewrites46.0%
Taylor expanded in y.re around -inf
Applied rewrites87.0%
Taylor expanded in y.re around inf
Applied rewrites87.1%
if -7.2e62 < y.re < 2.70000000000000016e88Initial program 70.8%
Taylor expanded in y.re around 0
Applied rewrites76.6%
if 2.70000000000000016e88 < y.re Initial program 35.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6443.0
Applied rewrites43.0%
Taylor expanded in y.re around -inf
Applied rewrites89.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -7.2e+62) (not (<= y.re 2.7e+88))) (/ (fma (/ y.im (- y.re)) x.re x.im) y.re) (/ (- (/ (* x.im y.re) y.im) x.re) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -7.2e+62) || !(y_46_re <= 2.7e+88)) {
tmp = fma((y_46_im / -y_46_re), x_46_re, x_46_im) / y_46_re;
} else {
tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -7.2e+62) || !(y_46_re <= 2.7e+88)) tmp = Float64(fma(Float64(y_46_im / Float64(-y_46_re)), x_46_re, x_46_im) / y_46_re); else tmp = Float64(Float64(Float64(Float64(x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -7.2e+62], N[Not[LessEqual[y$46$re, 2.7e+88]], $MachinePrecision]], N[(N[(N[(y$46$im / (-y$46$re)), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -7.2 \cdot 10^{+62} \lor \neg \left(y.re \leq 2.7 \cdot 10^{+88}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{-y.re}, x.re, x.im\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}\\
\end{array}
\end{array}
if y.re < -7.2e62 or 2.70000000000000016e88 < y.re Initial program 39.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6444.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6444.7
Applied rewrites44.7%
Taylor expanded in y.re around -inf
Applied rewrites88.1%
Taylor expanded in y.re around inf
Applied rewrites88.1%
if -7.2e62 < y.re < 2.70000000000000016e88Initial program 70.8%
Taylor expanded in y.re around 0
Applied rewrites76.6%
Final simplification81.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1.12e-29) (not (<= y.im 3.5e+44))) (/ (- (* y.re (/ x.im y.im)) x.re) y.im) (/ (- x.im (/ (* x.re y.im) y.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 <= -1.12e-29) || !(y_46_im <= 3.5e+44)) {
tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= (-1.12d-29)) .or. (.not. (y_46im <= 3.5d+44))) then
tmp = ((y_46re * (x_46im / y_46im)) - x_46re) / y_46im
else
tmp = (x_46im - ((x_46re * y_46im) / y_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 <= -1.12e-29) || !(y_46_im <= 3.5e+44)) {
tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= -1.12e-29) or not (y_46_im <= 3.5e+44): tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im else: tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= -1.12e-29) || !(y_46_im <= 3.5e+44)) tmp = Float64(Float64(Float64(y_46_re * Float64(x_46_im / y_46_im)) - x_46_re) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_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 <= -1.12e-29) || ~((y_46_im <= 3.5e+44))) tmp = ((y_46_re * (x_46_im / y_46_im)) - x_46_re) / y_46_im; else tmp = (x_46_im - ((x_46_re * y_46_im) / y_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, -1.12e-29], N[Not[LessEqual[y$46$im, 3.5e+44]], $MachinePrecision]], N[(N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.12 \cdot 10^{-29} \lor \neg \left(y.im \leq 3.5 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{y.re \cdot \frac{x.im}{y.im} - x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -1.11999999999999995e-29 or 3.4999999999999999e44 < y.im Initial program 42.0%
Taylor expanded in y.re around 0
Applied rewrites74.0%
Applied rewrites77.4%
if -1.11999999999999995e-29 < y.im < 3.4999999999999999e44Initial program 71.5%
Taylor expanded in y.re around inf
Applied rewrites83.7%
Final simplification80.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -4.8e+131) (not (<= y.im 6e+44))) (/ (- x.re) y.im) (/ (- x.im (/ (* x.re y.im) y.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 <= -4.8e+131) || !(y_46_im <= 6e+44)) {
tmp = -x_46_re / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= (-4.8d+131)) .or. (.not. (y_46im <= 6d+44))) then
tmp = -x_46re / y_46im
else
tmp = (x_46im - ((x_46re * y_46im) / y_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 <= -4.8e+131) || !(y_46_im <= 6e+44)) {
tmp = -x_46_re / y_46_im;
} else {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= -4.8e+131) or not (y_46_im <= 6e+44): tmp = -x_46_re / y_46_im else: tmp = (x_46_im - ((x_46_re * y_46_im) / y_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 <= -4.8e+131) || !(y_46_im <= 6e+44)) tmp = Float64(Float64(-x_46_re) / y_46_im); else tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_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 <= -4.8e+131) || ~((y_46_im <= 6e+44))) tmp = -x_46_re / y_46_im; else tmp = (x_46_im - ((x_46_re * y_46_im) / y_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, -4.8e+131], N[Not[LessEqual[y$46$im, 6e+44]], $MachinePrecision]], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4.8 \cdot 10^{+131} \lor \neg \left(y.im \leq 6 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if y.im < -4.7999999999999999e131 or 5.99999999999999974e44 < y.im Initial program 36.5%
Taylor expanded in y.re around 0
Applied rewrites75.6%
if -4.7999999999999999e131 < y.im < 5.99999999999999974e44Initial program 69.6%
Taylor expanded in y.re around inf
Applied rewrites77.8%
Final simplification77.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- x.re) y.im)))
(if (<= y.im -7.5e+150)
t_0
(if (<= y.im -5.5e-30)
(/ (- (* x.im y.re) (* x.re y.im)) (* y.im y.im))
(if (<= y.im 5.2e+44) (/ x.im y.re) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -7.5e+150) {
tmp = t_0;
} else if (y_46_im <= -5.5e-30) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im);
} else if (y_46_im <= 5.2e+44) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
real(8) :: tmp
t_0 = -x_46re / y_46im
if (y_46im <= (-7.5d+150)) then
tmp = t_0
else if (y_46im <= (-5.5d-30)) then
tmp = ((x_46im * y_46re) - (x_46re * y_46im)) / (y_46im * y_46im)
else if (y_46im <= 5.2d+44) then
tmp = x_46im / y_46re
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = -x_46_re / y_46_im;
double tmp;
if (y_46_im <= -7.5e+150) {
tmp = t_0;
} else if (y_46_im <= -5.5e-30) {
tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im);
} else if (y_46_im <= 5.2e+44) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = -x_46_re / y_46_im tmp = 0 if y_46_im <= -7.5e+150: tmp = t_0 elif y_46_im <= -5.5e-30: tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im) elif y_46_im <= 5.2e+44: tmp = x_46_im / y_46_re else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(-x_46_re) / y_46_im) tmp = 0.0 if (y_46_im <= -7.5e+150) tmp = t_0; elseif (y_46_im <= -5.5e-30) tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(y_46_im * y_46_im)); elseif (y_46_im <= 5.2e+44) tmp = Float64(x_46_im / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = -x_46_re / y_46_im; tmp = 0.0; if (y_46_im <= -7.5e+150) tmp = t_0; elseif (y_46_im <= -5.5e-30) tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im); elseif (y_46_im <= 5.2e+44) tmp = x_46_im / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -7.5e+150], t$95$0, If[LessEqual[y$46$im, -5.5e-30], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+44], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -7.5 \cdot 10^{+150}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -5.5 \cdot 10^{-30}:\\
\;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+44}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -7.4999999999999998e150 or 5.1999999999999998e44 < y.im Initial program 34.3%
Taylor expanded in y.re around 0
Applied rewrites77.0%
if -7.4999999999999998e150 < y.im < -5.49999999999999976e-30Initial program 63.7%
Taylor expanded in y.re around 0
Applied rewrites57.8%
if -5.49999999999999976e-30 < y.im < 5.1999999999999998e44Initial program 71.5%
Taylor expanded in y.re around inf
Applied rewrites68.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -2e+131) (not (<= y.im 5.2e+44))) (/ (- x.re) y.im) (/ x.im y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -2e+131) || !(y_46_im <= 5.2e+44)) {
tmp = -x_46_re / y_46_im;
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46im <= (-2d+131)) .or. (.not. (y_46im <= 5.2d+44))) then
tmp = -x_46re / y_46im
else
tmp = x_46im / y_46re
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -2e+131) || !(y_46_im <= 5.2e+44)) {
tmp = -x_46_re / y_46_im;
} else {
tmp = x_46_im / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -2e+131) or not (y_46_im <= 5.2e+44): tmp = -x_46_re / y_46_im else: tmp = x_46_im / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -2e+131) || !(y_46_im <= 5.2e+44)) tmp = Float64(Float64(-x_46_re) / y_46_im); else tmp = Float64(x_46_im / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_im <= -2e+131) || ~((y_46_im <= 5.2e+44))) tmp = -x_46_re / y_46_im; else tmp = x_46_im / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -2e+131], N[Not[LessEqual[y$46$im, 5.2e+44]], $MachinePrecision]], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2 \cdot 10^{+131} \lor \neg \left(y.im \leq 5.2 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{-x.re}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\
\end{array}
\end{array}
if y.im < -1.9999999999999998e131 or 5.1999999999999998e44 < y.im Initial program 36.5%
Taylor expanded in y.re around 0
Applied rewrites75.6%
if -1.9999999999999998e131 < y.im < 5.1999999999999998e44Initial program 69.6%
Taylor expanded in y.re around inf
Applied rewrites63.8%
Final simplification67.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_re;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = x_46im / y_46re
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.re}
\end{array}
Initial program 58.2%
Taylor expanded in y.re around inf
Applied rewrites46.7%
herbie shell --seed 2025019
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, imaginary part"
:precision binary64
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))