
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= x -6000.0) (not (<= x 4e+28))) (fabs (* (- 1.0 z) (/ x y))) (fabs (/ (fma (- 1.0 z) x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6000.0) || !(x <= 4e+28)) {
tmp = fabs(((1.0 - z) * (x / y)));
} else {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -6000.0) || !(x <= 4e+28)) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); else tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -6000.0], N[Not[LessEqual[x, 4e+28]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6000 \lor \neg \left(x \leq 4 \cdot 10^{+28}\right):\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\end{array}
\end{array}
if x < -6e3 or 3.99999999999999983e28 < x Initial program 85.5%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -6e3 < x < 3.99999999999999983e28Initial program 95.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x 4.0) y)) (t_1 (* (/ x y) z)))
(if (<= (- t_0 t_1) -1000.0)
(fabs (- t_1 t_0))
(fabs (/ (fma (- 1.0 z) x 4.0) y)))))
double code(double x, double y, double z) {
double t_0 = (x + 4.0) / y;
double t_1 = (x / y) * z;
double tmp;
if ((t_0 - t_1) <= -1000.0) {
tmp = fabs((t_1 - t_0));
} else {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + 4.0) / y) t_1 = Float64(Float64(x / y) * z) tmp = 0.0 if (Float64(t_0 - t_1) <= -1000.0) tmp = abs(Float64(t_1 - t_0)); else tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], -1000.0], N[Abs[N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := \frac{x}{y} \cdot z\\
\mathbf{if}\;t\_0 - t\_1 \leq -1000:\\
\;\;\;\;\left|t\_1 - t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -1e3Initial program 99.9%
if -1e3 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 87.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites97.0%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (if (<= y 6e-50) (fabs (/ (fma (- 1.0 z) x 4.0) y)) (fabs (fma (- x) (/ z y) (/ (+ 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6e-50) {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
} else {
tmp = fabs(fma(-x, (z / y), ((4.0 + x) / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6e-50) tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); else tmp = abs(fma(Float64(-x), Float64(z / y), Float64(Float64(4.0 + x) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6e-50], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-x) * N[(z / y), $MachinePrecision] + N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-50}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-x, \frac{z}{y}, \frac{4 + x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 5.99999999999999981e-50Initial program 87.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites96.8%
if 5.99999999999999981e-50 < y Initial program 97.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (if (<= z -5.9e+113) (fabs (/ (* (- x) z) y)) (if (<= z 1e-14) (fabs (/ (- x -4.0) y)) (fabs (* (- 1.0 z) (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e+113) {
tmp = fabs(((-x * z) / y));
} else if (z <= 1e-14) {
tmp = fabs(((x - -4.0) / y));
} else {
tmp = fabs(((1.0 - z) * (x / y)));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.9d+113)) then
tmp = abs(((-x * z) / y))
else if (z <= 1d-14) then
tmp = abs(((x - (-4.0d0)) / y))
else
tmp = abs(((1.0d0 - z) * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e+113) {
tmp = Math.abs(((-x * z) / y));
} else if (z <= 1e-14) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs(((1.0 - z) * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.9e+113: tmp = math.fabs(((-x * z) / y)) elif z <= 1e-14: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs(((1.0 - z) * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.9e+113) tmp = abs(Float64(Float64(Float64(-x) * z) / y)); elseif (z <= 1e-14) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.9e+113) tmp = abs(((-x * z) / y)); elseif (z <= 1e-14) tmp = abs(((x - -4.0) / y)); else tmp = abs(((1.0 - z) * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.9e+113], N[Abs[N[(N[((-x) * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1e-14], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+113}:\\
\;\;\;\;\left|\frac{\left(-x\right) \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 10^{-14}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -5.90000000000000023e113Initial program 93.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites94.0%
Taylor expanded in z around inf
Applied rewrites92.1%
if -5.90000000000000023e113 < z < 9.99999999999999999e-15Initial program 93.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.7%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6494.6
Applied rewrites94.6%
if 9.99999999999999999e-15 < z Initial program 80.7%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6481.0
Applied rewrites81.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.9e+113) (not (<= z 3100000.0))) (fabs (* (- z) (/ x y))) (fabs (/ (- x -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.9e+113) || !(z <= 3100000.0)) {
tmp = fabs((-z * (x / y)));
} else {
tmp = fabs(((x - -4.0) / y));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-5.9d+113)) .or. (.not. (z <= 3100000.0d0))) then
tmp = abs((-z * (x / y)))
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.9e+113) || !(z <= 3100000.0)) {
tmp = Math.abs((-z * (x / y)));
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.9e+113) or not (z <= 3100000.0): tmp = math.fabs((-z * (x / y))) else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.9e+113) || !(z <= 3100000.0)) tmp = abs(Float64(Float64(-z) * Float64(x / y))); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.9e+113) || ~((z <= 3100000.0))) tmp = abs((-z * (x / y))); else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.9e+113], N[Not[LessEqual[z, 3100000.0]], $MachinePrecision]], N[Abs[N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+113} \lor \neg \left(z \leq 3100000\right):\\
\;\;\;\;\left|\left(-z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if z < -5.90000000000000023e113 or 3.1e6 < z Initial program 87.1%
Taylor expanded in z around inf
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*r/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6484.6
Applied rewrites84.6%
if -5.90000000000000023e113 < z < 3.1e6Initial program 92.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.7%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6494.2
Applied rewrites94.2%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (<= z -5.9e+113) (fabs (/ (* (- x) z) y)) (if (<= z 3100000.0) (fabs (/ (- x -4.0) y)) (fabs (* (- z) (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e+113) {
tmp = fabs(((-x * z) / y));
} else if (z <= 3100000.0) {
tmp = fabs(((x - -4.0) / y));
} else {
tmp = fabs((-z * (x / y)));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.9d+113)) then
tmp = abs(((-x * z) / y))
else if (z <= 3100000.0d0) then
tmp = abs(((x - (-4.0d0)) / y))
else
tmp = abs((-z * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e+113) {
tmp = Math.abs(((-x * z) / y));
} else if (z <= 3100000.0) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs((-z * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.9e+113: tmp = math.fabs(((-x * z) / y)) elif z <= 3100000.0: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs((-z * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.9e+113) tmp = abs(Float64(Float64(Float64(-x) * z) / y)); elseif (z <= 3100000.0) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(Float64(-z) * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.9e+113) tmp = abs(((-x * z) / y)); elseif (z <= 3100000.0) tmp = abs(((x - -4.0) / y)); else tmp = abs((-z * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.9e+113], N[Abs[N[(N[((-x) * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3100000.0], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+113}:\\
\;\;\;\;\left|\frac{\left(-x\right) \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 3100000:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(-z\right) \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -5.90000000000000023e113Initial program 93.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites94.0%
Taylor expanded in z around inf
Applied rewrites92.1%
if -5.90000000000000023e113 < z < 3.1e6Initial program 92.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.7%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6494.2
Applied rewrites94.2%
if 3.1e6 < z Initial program 81.7%
Taylor expanded in z around inf
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*r/N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e+132) (not (<= z 2.65e+73))) (* (/ (- x) y) z) (fabs (/ (- x -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+132) || !(z <= 2.65e+73)) {
tmp = (-x / y) * z;
} else {
tmp = fabs(((x - -4.0) / y));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.3d+132)) .or. (.not. (z <= 2.65d+73))) then
tmp = (-x / y) * z
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+132) || !(z <= 2.65e+73)) {
tmp = (-x / y) * z;
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+132) or not (z <= 2.65e+73): tmp = (-x / y) * z else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+132) || !(z <= 2.65e+73)) tmp = Float64(Float64(Float64(-x) / y) * z); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+132) || ~((z <= 2.65e+73))) tmp = (-x / y) * z; else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+132], N[Not[LessEqual[z, 2.65e+73]], $MachinePrecision]], N[(N[((-x) / y), $MachinePrecision] * z), $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+132} \lor \neg \left(z \leq 2.65 \cdot 10^{+73}\right):\\
\;\;\;\;\frac{-x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if z < -2.3000000000000002e132 or 2.64999999999999998e73 < z Initial program 88.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites90.0%
Taylor expanded in z around inf
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.5
Applied rewrites83.5%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt52.0
Applied rewrites52.6%
if -2.3000000000000002e132 < z < 2.64999999999999998e73Initial program 91.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.8%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6488.3
Applied rewrites88.3%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e+132) (not (<= z 3.9e+173))) (* x (/ (- z) y)) (fabs (/ (- x -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+132) || !(z <= 3.9e+173)) {
tmp = x * (-z / y);
} else {
tmp = fabs(((x - -4.0) / y));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.3d+132)) .or. (.not. (z <= 3.9d+173))) then
tmp = x * (-z / y)
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+132) || !(z <= 3.9e+173)) {
tmp = x * (-z / y);
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+132) or not (z <= 3.9e+173): tmp = x * (-z / y) else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+132) || !(z <= 3.9e+173)) tmp = Float64(x * Float64(Float64(-z) / y)); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+132) || ~((z <= 3.9e+173))) tmp = x * (-z / y); else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+132], N[Not[LessEqual[z, 3.9e+173]], $MachinePrecision]], N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+132} \lor \neg \left(z \leq 3.9 \cdot 10^{+173}\right):\\
\;\;\;\;x \cdot \frac{-z}{y}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if z < -2.3000000000000002e132 or 3.8999999999999998e173 < z Initial program 88.7%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt53.7
Applied rewrites53.7%
Applied rewrites54.3%
Taylor expanded in z around inf
Applied rewrites54.3%
if -2.3000000000000002e132 < z < 3.8999999999999998e173Initial program 90.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites97.4%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6483.2
Applied rewrites83.2%
Final simplification75.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.5) (fabs (/ x y)) (if (<= x 4.0) (fabs (/ 4.0 y)) (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5) {
tmp = fabs((x / y));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = x / y;
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.5d0)) then
tmp = abs((x / y))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.5) {
tmp = Math.abs((x / y));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5: tmp = math.fabs((x / y)) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = x / y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5) tmp = abs(Float64(x / y)); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.5) tmp = abs((x / y)); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.5Initial program 81.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
Taylor expanded in z around 0
Applied rewrites68.5%
if -1.5 < x < 4Initial program 95.5%
Taylor expanded in x around 0
lower-/.f6466.1
Applied rewrites66.1%
if 4 < x Initial program 91.7%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6498.6
Applied rewrites98.6%
Taylor expanded in z around 0
Applied rewrites60.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt37.4
Applied rewrites37.4%
(FPCore (x y z) :precision binary64 (if (<= x -4.0) (fabs (/ x y)) (/ (+ 4.0 x) y)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.0) {
tmp = fabs((x / y));
} else {
tmp = (4.0 + x) / y;
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-4.0d0)) then
tmp = abs((x / y))
else
tmp = (4.0d0 + x) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.0) {
tmp = Math.abs((x / y));
} else {
tmp = (4.0 + x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.0: tmp = math.fabs((x / y)) else: tmp = (4.0 + x) / y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.0) tmp = abs(Float64(x / y)); else tmp = Float64(Float64(4.0 + x) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.0) tmp = abs((x / y)); else tmp = (4.0 + x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{4 + x}{y}\\
\end{array}
\end{array}
if x < -4Initial program 81.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
Taylor expanded in z around 0
Applied rewrites68.5%
if -4 < x Initial program 94.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites96.7%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6465.1
Applied rewrites65.1%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt35.2
Applied rewrites35.2%
(FPCore (x y z) :precision binary64 (fabs (/ (- x -4.0) y)))
double code(double x, double y, double z) {
return fabs(((x - -4.0) / y));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs(((x - (-4.0d0)) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs(((x - -4.0) / y));
}
def code(x, y, z): return math.fabs(((x - -4.0) / y))
function code(x, y, z) return abs(Float64(Float64(x - -4.0) / y)) end
function tmp = code(x, y, z) tmp = abs(((x - -4.0) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x - -4}{y}\right|
\end{array}
Initial program 90.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites95.8%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-subN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lft-mult-inverseN/A
*-inversesN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6466.4
Applied rewrites66.4%
(FPCore (x y z) :precision binary64 (fabs (/ x y)))
double code(double x, double y, double z) {
return fabs((x / y));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((x / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((x / y));
}
def code(x, y, z): return math.fabs((x / y))
function code(x, y, z) return abs(Float64(x / y)) end
function tmp = code(x, y, z) tmp = abs((x / y)); end
code[x_, y_, z_] := N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x}{y}\right|
\end{array}
Initial program 90.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
Taylor expanded in z around 0
Applied rewrites40.0%
(FPCore (x y z) :precision binary64 (/ x y))
double code(double x, double y, double z) {
return x / y;
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / y
end function
public static double code(double x, double y, double z) {
return x / y;
}
def code(x, y, z): return x / y
function code(x, y, z) return Float64(x / y) end
function tmp = code(x, y, z) tmp = x / y; end
code[x_, y_, z_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 90.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
Taylor expanded in z around 0
Applied rewrites40.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt22.6
Applied rewrites22.6%
herbie shell --seed 2024356
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))