
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4) 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), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4) 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), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
(FPCore (x y z) :precision binary64 (fabs (/ (- (- (* z x) 4) x) y)))
double code(double x, double y, double z) {
return fabs(((((z * x) - 4.0) - 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(((((z * x) - 4.0d0) - x) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs(((((z * x) - 4.0) - x) / y));
}
def code(x, y, z): return math.fabs(((((z * x) - 4.0) - x) / y))
function code(x, y, z) return abs(Float64(Float64(Float64(Float64(z * x) - 4.0) - x) / y)) end
function tmp = code(x, y, z) tmp = abs(((((z * x) - 4.0) - x) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(N[(z * x), $MachinePrecision] - 4), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\left|\frac{\left(z \cdot x - 4\right) - x}{y}\right|
Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (fabs y)))
(t_1 (fabs (* t_0 (- 1 z))))
(t_2 (- (/ (+ x 4) (fabs y)) (* t_0 z))))
(if (<=
t_2
-1162941958872971/23258839177459420497578361852416145099316523541994177929007686373780457219628733546438113622840434097944400691400517693873107252115668992)
t_1
(if (<=
t_2
500000000000000008608032298368227414415543912506619491164446008946190335622287523993960225937729797284303069430849145530155524612766474260348469402855720325061314257334714230178496312484014164775344612087642173365030358044414607127719847315059897273252756207808991071631335431459408181431059577374563631104)
(fabs (/ (- -4 x) (fabs y)))
t_1))))double code(double x, double y, double z) {
double t_0 = x / fabs(y);
double t_1 = fabs((t_0 * (1.0 - z)));
double t_2 = ((x + 4.0) / fabs(y)) - (t_0 * z);
double tmp;
if (t_2 <= -5e-122) {
tmp = t_1;
} else if (t_2 <= 5e+305) {
tmp = fabs(((-4.0 - x) / fabs(y)));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x / abs(y)
t_1 = abs((t_0 * (1.0d0 - z)))
t_2 = ((x + 4.0d0) / abs(y)) - (t_0 * z)
if (t_2 <= (-5d-122)) then
tmp = t_1
else if (t_2 <= 5d+305) then
tmp = abs((((-4.0d0) - x) / abs(y)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / Math.abs(y);
double t_1 = Math.abs((t_0 * (1.0 - z)));
double t_2 = ((x + 4.0) / Math.abs(y)) - (t_0 * z);
double tmp;
if (t_2 <= -5e-122) {
tmp = t_1;
} else if (t_2 <= 5e+305) {
tmp = Math.abs(((-4.0 - x) / Math.abs(y)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x / math.fabs(y) t_1 = math.fabs((t_0 * (1.0 - z))) t_2 = ((x + 4.0) / math.fabs(y)) - (t_0 * z) tmp = 0 if t_2 <= -5e-122: tmp = t_1 elif t_2 <= 5e+305: tmp = math.fabs(((-4.0 - x) / math.fabs(y))) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x / abs(y)) t_1 = abs(Float64(t_0 * Float64(1.0 - z))) t_2 = Float64(Float64(Float64(x + 4.0) / abs(y)) - Float64(t_0 * z)) tmp = 0.0 if (t_2 <= -5e-122) tmp = t_1; elseif (t_2 <= 5e+305) tmp = abs(Float64(Float64(-4.0 - x) / abs(y))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / abs(y); t_1 = abs((t_0 * (1.0 - z))); t_2 = ((x + 4.0) / abs(y)) - (t_0 * z); tmp = 0.0; if (t_2 <= -5e-122) tmp = t_1; elseif (t_2 <= 5e+305) tmp = abs(((-4.0 - x) / abs(y))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[Abs[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(t$95$0 * N[(1 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x + 4), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1162941958872971/23258839177459420497578361852416145099316523541994177929007686373780457219628733546438113622840434097944400691400517693873107252115668992], t$95$1, If[LessEqual[t$95$2, 500000000000000008608032298368227414415543912506619491164446008946190335622287523993960225937729797284303069430849145530155524612766474260348469402855720325061314257334714230178496312484014164775344612087642173365030358044414607127719847315059897273252756207808991071631335431459408181431059577374563631104], N[Abs[N[(N[(-4 - x), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := \frac{x}{\left|y\right|}\\
t_1 := \left|t\_0 \cdot \left(1 - z\right)\right|\\
t_2 := \frac{x + 4}{\left|y\right|} - t\_0 \cdot z\\
\mathbf{if}\;t\_2 \leq \frac{-1162941958872971}{23258839177459420497578361852416145099316523541994177929007686373780457219628733546438113622840434097944400691400517693873107252115668992}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 500000000000000008608032298368227414415543912506619491164446008946190335622287523993960225937729797284303069430849145530155524612766474260348469402855720325061314257334714230178496312484014164775344612087642173365030358044414607127719847315059897273252756207808991071631335431459408181431059577374563631104:\\
\;\;\;\;\left|\frac{-4 - x}{\left|y\right|}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -4.9999999999999999e-122 or 5.0000000000000001e305 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 91.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.2%
Applied rewrites61.2%
lift--.f64N/A
*-lft-identityN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6461.2%
Applied rewrites61.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6461.5%
Applied rewrites61.5%
if -4.9999999999999999e-122 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 5.0000000000000001e305Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
(FPCore (x y z)
:precision binary64
(if (<= z -90000000000000000866378311868088320)
(fabs (/ (* x z) y))
(if (<=
z
48999999999999998564994823264438648406954295928319952073277107194659702122217472)
(fabs (/ (- -4 x) y))
(fabs (* (/ (- x) y) z)))))double code(double x, double y, double z) {
double tmp;
if (z <= -9e+34) {
tmp = fabs(((x * z) / y));
} else if (z <= 4.9e+79) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs(((-x / y) * z));
}
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 <= (-9d+34)) then
tmp = abs(((x * z) / y))
else if (z <= 4.9d+79) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs(((-x / y) * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9e+34) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 4.9e+79) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs(((-x / y) * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e+34: tmp = math.fabs(((x * z) / y)) elif z <= 4.9e+79: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs(((-x / y) * z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e+34) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 4.9e+79) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(Float64(-x) / y) * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9e+34) tmp = abs(((x * z) / y)); elseif (z <= 4.9e+79) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((-x / y) * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -90000000000000000866378311868088320], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 48999999999999998564994823264438648406954295928319952073277107194659702122217472], N[Abs[N[(N[(-4 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[((-x) / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -90000000000000000866378311868088320:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 48999999999999998564994823264438648406954295928319952073277107194659702122217472:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-x}{y} \cdot z\right|\\
\end{array}
if z < -9.0000000000000001e34Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6437.1%
Applied rewrites37.1%
if -9.0000000000000001e34 < z < 4.8999999999999999e79Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
if 4.8999999999999999e79 < z Initial program 91.3%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6437.1%
Applied rewrites37.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6439.0%
Applied rewrites39.0%
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-/.f64N/A
associate-/l*N/A
associate-*l/N/A
distribute-lft-neg-outN/A
lower-*.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ (* x z) y))))
(if (<= z -90000000000000000866378311868088320)
t_0
(if (<=
z
48999999999999998564994823264438648406954295928319952073277107194659702122217472)
(fabs (/ (- -4 x) y))
t_0))))double code(double x, double y, double z) {
double t_0 = fabs(((x * z) / y));
double tmp;
if (z <= -9e+34) {
tmp = t_0;
} else if (z <= 4.9e+79) {
tmp = fabs(((-4.0 - x) / y));
} 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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs(((x * z) / y))
if (z <= (-9d+34)) then
tmp = t_0
else if (z <= 4.9d+79) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs(((x * z) / y));
double tmp;
if (z <= -9e+34) {
tmp = t_0;
} else if (z <= 4.9e+79) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((x * z) / y)) tmp = 0 if z <= -9e+34: tmp = t_0 elif z <= 4.9e+79: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(x * z) / y)) tmp = 0.0 if (z <= -9e+34) tmp = t_0; elseif (z <= 4.9e+79) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((x * z) / y)); tmp = 0.0; if (z <= -9e+34) tmp = t_0; elseif (z <= 4.9e+79) tmp = abs(((-4.0 - x) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -90000000000000000866378311868088320], t$95$0, If[LessEqual[z, 48999999999999998564994823264438648406954295928319952073277107194659702122217472], N[Abs[N[(N[(-4 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{x \cdot z}{y}\right|\\
\mathbf{if}\;z \leq -90000000000000000866378311868088320:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 48999999999999998564994823264438648406954295928319952073277107194659702122217472:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -9.0000000000000001e34 or 4.8999999999999999e79 < z Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6437.1%
Applied rewrites37.1%
if -9.0000000000000001e34 < z < 4.8999999999999999e79Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
(FPCore (x y z) :precision binary64 (fabs (/ (- -4 x) y)))
double code(double x, double y, double z) {
return fabs(((-4.0 - 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((((-4.0d0) - x) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs(((-4.0 - x) / y));
}
def code(x, y, z): return math.fabs(((-4.0 - x) / y))
function code(x, y, z) return abs(Float64(Float64(-4.0 - x) / y)) end
function tmp = code(x, y, z) tmp = abs(((-4.0 - x) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(-4 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\left|\frac{-4 - x}{y}\right|
Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
Applied rewrites70.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -230)
t_0
(if (<= x 2871044762448691/281474976710656) (fabs (/ -4 y)) t_0))))double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -230.0) {
tmp = t_0;
} else if (x <= 10.2) {
tmp = fabs((-4.0 / y));
} 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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if (x <= (-230.0d0)) then
tmp = t_0
else if (x <= 10.2d0) then
tmp = abs(((-4.0d0) / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -230.0) {
tmp = t_0;
} else if (x <= 10.2) {
tmp = Math.abs((-4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -230.0: tmp = t_0 elif x <= 10.2: tmp = math.fabs((-4.0 / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -230.0) tmp = t_0; elseif (x <= 10.2) tmp = abs(Float64(-4.0 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -230.0) tmp = t_0; elseif (x <= 10.2) tmp = abs((-4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -230], t$95$0, If[LessEqual[x, 2871044762448691/281474976710656], N[Abs[N[(-4 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -230:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq \frac{2871044762448691}{281474976710656}:\\
\;\;\;\;\left|\frac{-4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -230 or 10.199999999999999 < x Initial program 91.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.2%
Applied rewrites61.2%
lift--.f64N/A
*-lft-identityN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6461.2%
Applied rewrites61.2%
Taylor expanded in z around 0
lower-/.f6434.7%
Applied rewrites34.7%
if -230 < x < 10.199999999999999Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1%
Applied rewrites96.1%
Taylor expanded in x around 0
lower-/.f6440.4%
Applied rewrites40.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]
\left|\frac{x}{y}\right|
Initial program 91.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.2%
Applied rewrites61.2%
lift--.f64N/A
*-lft-identityN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6461.2%
Applied rewrites61.2%
Taylor expanded in z around 0
lower-/.f6434.7%
Applied rewrites34.7%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4) y) (* (/ x y) z))))