
(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)));
}
real(8) function code(x, y, z)
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 8 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)));
}
real(8) function code(x, y, z)
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}
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 6.5e-53) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ x (/ y z)) (/ (+ x 4.0) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e-53) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((x / (y / z)) - ((x + 4.0) / y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 6.5d-53) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((x / (y / z)) - ((x + 4.0d0) / y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e-53) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((x / (y / z)) - ((x + 4.0) / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 6.5e-53: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((x / (y / z)) - ((x + 4.0) / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 6.5e-53) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(x / Float64(y / z)) - Float64(Float64(x + 4.0) / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.5e-53) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((x / (y / z)) - ((x + 4.0) / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 6.5e-53], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}} - \frac{x + 4}{y}\right|\\
\end{array}
\end{array}
if y < 6.4999999999999997e-53Initial program 91.6%
associate-*l/94.6%
associate-*r/92.0%
Simplified92.0%
Taylor expanded in x around 0 95.3%
sub-neg95.3%
+-commutative95.3%
distribute-lft-in92.0%
associate-+r+92.0%
distribute-rgt-in92.0%
associate-*l/92.0%
*-lft-identity92.0%
+-commutative92.0%
distribute-rgt-neg-out92.0%
sub-neg92.0%
associate-*r/94.6%
div-sub97.9%
Simplified97.9%
if 6.4999999999999997e-53 < y Initial program 94.8%
associate-*l/93.5%
associate-*r/99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 3.5e-53) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ (+ x 4.0) y) (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e-53) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((((x + 4.0) / y) - (x * (z / y))));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3.5d-53) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((((x + 4.0d0) / y) - (x * (z / y))))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e-53) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((((x + 4.0) / y) - (x * (z / y))));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 3.5e-53: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((((x + 4.0) / y) - (x * (z / y)))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 3.5e-53) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x * Float64(z / y)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e-53) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((((x + 4.0) / y) - (x * (z / y)))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 3.5e-53], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if y < 3.49999999999999993e-53Initial program 91.6%
associate-*l/94.6%
associate-*r/92.0%
Simplified92.0%
Taylor expanded in x around 0 95.3%
sub-neg95.3%
+-commutative95.3%
distribute-lft-in92.0%
associate-+r+92.0%
distribute-rgt-in92.0%
associate-*l/92.0%
*-lft-identity92.0%
+-commutative92.0%
distribute-rgt-neg-out92.0%
sub-neg92.0%
associate-*r/94.6%
div-sub97.9%
Simplified97.9%
if 3.49999999999999993e-53 < y Initial program 94.8%
associate-*l/93.5%
associate-*r/99.9%
Simplified99.9%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -18000.0) (not (<= x 450000000.0))) (fabs (/ x (/ y (- 1.0 z)))) (fabs (+ (/ 4.0 y) (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -18000.0) || !(x <= 450000000.0)) {
tmp = fabs((x / (y / (1.0 - z))));
} else {
tmp = fabs(((4.0 / y) + (x / y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-18000.0d0)) .or. (.not. (x <= 450000000.0d0))) then
tmp = abs((x / (y / (1.0d0 - z))))
else
tmp = abs(((4.0d0 / y) + (x / y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -18000.0) || !(x <= 450000000.0)) {
tmp = Math.abs((x / (y / (1.0 - z))));
} else {
tmp = Math.abs(((4.0 / y) + (x / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -18000.0) or not (x <= 450000000.0): tmp = math.fabs((x / (y / (1.0 - z)))) else: tmp = math.fabs(((4.0 / y) + (x / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -18000.0) || !(x <= 450000000.0)) tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); else tmp = abs(Float64(Float64(4.0 / y) + Float64(x / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -18000.0) || ~((x <= 450000000.0))) tmp = abs((x / (y / (1.0 - z)))); else tmp = abs(((4.0 / y) + (x / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -18000.0], N[Not[LessEqual[x, 450000000.0]], $MachinePrecision]], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -18000 \lor \neg \left(x \leq 450000000\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -18000 or 4.5e8 < x Initial program 89.3%
associate-*l/87.3%
associate-*r/94.6%
Simplified94.6%
Taylor expanded in x around 0 99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-in94.5%
associate-+r+94.5%
distribute-rgt-in94.5%
associate-*l/94.6%
*-lft-identity94.6%
+-commutative94.6%
distribute-rgt-neg-out94.6%
sub-neg94.6%
associate-*r/87.3%
div-sub92.6%
Simplified92.6%
Taylor expanded in x around inf 92.5%
associate-/l*99.7%
Simplified99.7%
if -18000 < x < 4.5e8Initial program 95.0%
associate-*l/99.9%
associate-*r/94.0%
Simplified94.0%
Taylor expanded in z around 0 81.6%
associate-*r/81.6%
metadata-eval81.6%
Simplified81.6%
Final simplification89.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x 4.2e+14) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (/ x (/ y (- 1.0 z))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= 4.2e+14) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((x / (y / (1.0 - z))));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 4.2d+14) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((x / (y / (1.0d0 - z))))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (x <= 4.2e+14) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((x / (y / (1.0 - z))));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= 4.2e+14: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((x / (y / (1.0 - z)))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= 4.2e+14) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 4.2e+14) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((x / (y / (1.0 - z)))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, 4.2e+14], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{+14}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\end{array}
\end{array}
if x < 4.2e14Initial program 93.8%
associate-*l/96.5%
associate-*r/94.0%
Simplified94.0%
Taylor expanded in x around 0 95.5%
sub-neg95.5%
+-commutative95.5%
distribute-lft-in94.0%
associate-+r+94.0%
distribute-rgt-in94.0%
associate-*l/94.0%
*-lft-identity94.0%
+-commutative94.0%
distribute-rgt-neg-out94.0%
sub-neg94.0%
associate-*r/96.5%
div-sub98.0%
Simplified98.0%
if 4.2e14 < x Initial program 88.4%
associate-*l/87.4%
associate-*r/94.9%
Simplified94.9%
Taylor expanded in x around 0 99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in94.8%
associate-+r+94.8%
distribute-rgt-in94.8%
associate-*l/94.9%
*-lft-identity94.9%
+-commutative94.9%
distribute-rgt-neg-out94.9%
sub-neg94.9%
associate-*r/87.4%
div-sub92.3%
Simplified92.3%
Taylor expanded in x around inf 92.3%
associate-/l*99.9%
Simplified99.9%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= z -1.8e+136) (not (<= z 8.2e+49))) (fabs (/ x (/ y z))) (fabs (/ (+ x 4.0) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e+136) || !(z <= 8.2e+49)) {
tmp = fabs((x / (y / z)));
} else {
tmp = fabs(((x + 4.0) / y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.8d+136)) .or. (.not. (z <= 8.2d+49))) then
tmp = abs((x / (y / z)))
else
tmp = abs(((x + 4.0d0) / y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e+136) || !(z <= 8.2e+49)) {
tmp = Math.abs((x / (y / z)));
} else {
tmp = Math.abs(((x + 4.0) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (z <= -1.8e+136) or not (z <= 8.2e+49): tmp = math.fabs((x / (y / z))) else: tmp = math.fabs(((x + 4.0) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((z <= -1.8e+136) || !(z <= 8.2e+49)) tmp = abs(Float64(x / Float64(y / z))); else tmp = abs(Float64(Float64(x + 4.0) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.8e+136) || ~((z <= 8.2e+49))) tmp = abs((x / (y / z))); else tmp = abs(((x + 4.0) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e+136], N[Not[LessEqual[z, 8.2e+49]], $MachinePrecision]], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+136} \lor \neg \left(z \leq 8.2 \cdot 10^{+49}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\end{array}
\end{array}
if z < -1.80000000000000003e136 or 8.2e49 < z Initial program 89.5%
associate-*l/88.0%
associate-*r/87.8%
Simplified87.8%
Taylor expanded in z around inf 68.6%
associate-*r/68.6%
neg-mul-168.6%
distribute-lft-neg-in68.6%
associate-*l/71.2%
*-commutative71.2%
Simplified71.2%
*-commutative71.2%
distribute-frac-neg71.2%
distribute-lft-neg-in71.2%
associate-/r/75.8%
distribute-neg-frac75.8%
add-sqr-sqrt38.2%
sqrt-unprod59.9%
sqr-neg59.9%
sqrt-unprod37.4%
add-sqr-sqrt75.8%
Applied egg-rr75.8%
if -1.80000000000000003e136 < z < 8.2e49Initial program 94.0%
associate-*l/97.6%
associate-*r/97.6%
Simplified97.6%
Taylor expanded in z around 0 95.5%
+-commutative95.5%
*-rgt-identity95.5%
associate-*r/95.4%
distribute-rgt-in95.4%
associate-*l/95.5%
*-lft-identity95.5%
Simplified95.5%
Final simplification88.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((4.0 / y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -10.5) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -10.5) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -10.5) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -10.5 or 4 < x Initial program 89.7%
associate-*l/87.8%
associate-*r/94.8%
Simplified94.8%
Taylor expanded in z around 0 67.0%
associate-*r/67.0%
metadata-eval67.0%
Simplified67.0%
Taylor expanded in x around inf 65.2%
if -10.5 < x < 4Initial program 94.9%
associate-*l/99.9%
associate-*r/93.8%
Simplified93.8%
Taylor expanded in x around 0 80.8%
Final simplification73.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -2.05e-39) (fabs (* z (/ x y))) (if (<= x 4.0) (fabs (/ 4.0 y)) (fabs (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e-39) {
tmp = fabs((z * (x / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = fabs((x / y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-2.05d-39)) then
tmp = abs((z * (x / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = abs((x / y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e-39) {
tmp = Math.abs((z * (x / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= -2.05e-39: tmp = math.fabs((z * (x / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = math.fabs((x / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= -2.05e-39) tmp = abs(Float64(z * Float64(x / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = abs(Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.05e-39) tmp = abs((z * (x / y))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = abs((x / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, -2.05e-39], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.05 \cdot 10^{-39}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -2.05e-39Initial program 91.6%
associate-*l/88.9%
associate-*r/94.9%
Simplified94.9%
Taylor expanded in z around inf 52.9%
associate-*r/52.9%
neg-mul-152.9%
distribute-lft-neg-in52.9%
associate-*l/65.1%
*-commutative65.1%
Simplified65.1%
clear-num65.0%
un-div-inv65.1%
add-sqr-sqrt65.0%
sqrt-unprod55.2%
sqr-neg55.2%
sqrt-unprod0.0%
add-sqr-sqrt65.1%
Applied egg-rr65.1%
clear-num65.0%
associate-/r/65.0%
clear-num65.1%
Applied egg-rr65.1%
if -2.05e-39 < x < 4Initial program 94.6%
associate-*l/100.0%
associate-*r/93.5%
Simplified93.5%
Taylor expanded in x around 0 82.9%
if 4 < x Initial program 88.9%
associate-*l/88.0%
associate-*r/95.2%
Simplified95.2%
Taylor expanded in z around 0 70.0%
associate-*r/70.0%
metadata-eval70.0%
Simplified70.0%
Taylor expanded in x around inf 68.2%
Final simplification75.0%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
y = abs(y);
double code(double x, double y, double z) {
return fabs((4.0 / y));
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((4.0d0 / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
return Math.abs((4.0 / y));
}
y = abs(y) def code(x, y, z): return math.fabs((4.0 / y))
y = abs(y) function code(x, y, z) return abs(Float64(4.0 / y)) end
y = abs(y) function tmp = code(x, y, z) tmp = abs((4.0 / y)); end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{4}{y}\right|
\end{array}
Initial program 92.5%
associate-*l/94.3%
associate-*r/94.2%
Simplified94.2%
Taylor expanded in x around 0 46.0%
Final simplification46.0%
herbie shell --seed 2023271
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))