
(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 9 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 100000000.0) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 100000000.0) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
}
return tmp;
}
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 100000000.0) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 100000000.0], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 100000000:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 1e8Initial program 91.9%
associate-*l/93.2%
sub-div98.0%
Applied egg-rr98.0%
if 1e8 < y Initial program 96.7%
fabs-sub96.7%
associate-*l/91.5%
*-commutative91.5%
associate-*l/99.8%
*-commutative99.8%
fma-neg99.8%
distribute-neg-frac99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -6e+38) (not (<= x 10000000000000.0))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -6e+38) || !(x <= 10000000000000.0)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs((((x + 4.0) - (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 ((x <= (-6d+38)) .or. (.not. (x <= 10000000000000.0d0))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs((((x + 4.0d0) - (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 ((x <= -6e+38) || !(x <= 10000000000000.0)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -6e+38) or not (x <= 10000000000000.0): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -6e+38) || !(x <= 10000000000000.0)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6e+38) || ~((x <= 10000000000000.0))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -6e+38], N[Not[LessEqual[x, 10000000000000.0]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+38} \lor \neg \left(x \leq 10000000000000\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -6.0000000000000002e38 or 1e13 < x Initial program 86.2%
Simplified90.7%
Taylor expanded in x around inf 91.0%
associate-/l*99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
if -6.0000000000000002e38 < x < 1e13Initial program 97.9%
associate-*l/99.9%
sub-div99.9%
Applied egg-rr99.9%
Final simplification99.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 100000000.0) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ (+ x 4.0) y) (* z (/ x y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 100000000.0) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((((x + 4.0) / y) - (z * (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 (y <= 100000000.0d0) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((((x + 4.0d0) / y) - (z * (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 (y <= 100000000.0) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((((x + 4.0) / y) - (z * (x / y))));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 100000000.0: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((((x + 4.0) / y) - (z * (x / y)))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 100000000.0) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 100000000.0) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((((x + 4.0) / y) - (z * (x / y)))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 100000000.0], 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 100000000:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if y < 1e8Initial program 91.9%
associate-*l/93.2%
sub-div98.0%
Applied egg-rr98.0%
if 1e8 < y Initial program 96.7%
Final simplification97.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -0.00082) (not (<= x 6500000000000.0))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (* (+ x 4.0) (/ 1.0 y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.00082) || !(x <= 6500000000000.0)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs(((x + 4.0) * (1.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 <= (-0.00082d0)) .or. (.not. (x <= 6500000000000.0d0))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs(((x + 4.0d0) * (1.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 <= -0.00082) || !(x <= 6500000000000.0)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs(((x + 4.0) * (1.0 / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -0.00082) or not (x <= 6500000000000.0): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs(((x + 4.0) * (1.0 / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -0.00082) || !(x <= 6500000000000.0)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(x + 4.0) * Float64(1.0 / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -0.00082) || ~((x <= 6500000000000.0))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs(((x + 4.0) * (1.0 / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -0.00082], N[Not[LessEqual[x, 6500000000000.0]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x + 4.0), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00082 \lor \neg \left(x \leq 6500000000000\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(x + 4\right) \cdot \frac{1}{y}\right|\\
\end{array}
\end{array}
if x < -8.1999999999999998e-4 or 6.5e12 < x Initial program 86.6%
Simplified90.9%
Taylor expanded in x around inf 91.2%
associate-/l*99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
if -8.1999999999999998e-4 < x < 6.5e12Initial program 97.8%
Taylor expanded in z around 0 80.9%
associate-*r/80.9%
metadata-eval80.9%
Simplified80.9%
+-commutative80.9%
div-inv80.9%
div-inv80.9%
distribute-rgt-out80.9%
Applied egg-rr80.9%
Final simplification88.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -7.2e+71) (fabs (* x (/ z y))) (if (<= z 7.1e+121) (fabs (/ (- -4.0 x) y)) (fabs (* z (/ x y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -7.2e+71) {
tmp = fabs((x * (z / y)));
} else if (z <= 7.1e+121) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((z * (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 (z <= (-7.2d+71)) then
tmp = abs((x * (z / y)))
else if (z <= 7.1d+121) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z * (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 (z <= -7.2e+71) {
tmp = Math.abs((x * (z / y)));
} else if (z <= 7.1e+121) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z * (x / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -7.2e+71: tmp = math.fabs((x * (z / y))) elif z <= 7.1e+121: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z * (x / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -7.2e+71) tmp = abs(Float64(x * Float64(z / y))); elseif (z <= 7.1e+121) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z * Float64(x / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.2e+71) tmp = abs((x * (z / y))); elseif (z <= 7.1e+121) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z * (x / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -7.2e+71], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 7.1e+121], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+71}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;z \leq 7.1 \cdot 10^{+121}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -7.1999999999999999e71Initial program 93.9%
Simplified85.8%
Taylor expanded in z around inf 62.7%
associate-*l/74.5%
*-commutative74.5%
Simplified74.5%
if -7.1999999999999999e71 < z < 7.10000000000000023e121Initial program 93.5%
Simplified99.8%
Taylor expanded in z around 0 92.5%
associate-*r/92.5%
distribute-lft-in92.5%
metadata-eval92.5%
neg-mul-192.5%
sub-neg92.5%
Simplified92.5%
if 7.10000000000000023e121 < z Initial program 91.1%
Simplified92.6%
Taylor expanded in z around inf 80.0%
add-sqr-sqrt44.1%
sqrt-unprod61.8%
sqr-neg61.8%
sqrt-unprod35.6%
add-sqr-sqrt80.0%
associate-*r/85.8%
*-commutative85.8%
add-sqr-sqrt40.1%
sqrt-unprod60.8%
sqr-neg60.8%
sqrt-unprod45.4%
add-sqr-sqrt85.8%
Applied egg-rr85.8%
Final simplification88.2%
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 87.1%
Taylor expanded in z around 0 61.0%
associate-*r/61.0%
metadata-eval61.0%
Simplified61.0%
Taylor expanded in x around inf 59.0%
if -10.5 < x < 4Initial program 97.8%
Taylor expanded in x around 0 78.0%
Final simplification69.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -1.05e-5) (fabs (* x (/ z 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 <= -1.05e-5) {
tmp = fabs((x * (z / 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 <= (-1.05d-5)) then
tmp = abs((x * (z / 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 <= -1.05e-5) {
tmp = Math.abs((x * (z / 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 <= -1.05e-5: tmp = math.fabs((x * (z / 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 <= -1.05e-5) tmp = abs(Float64(x * Float64(z / 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 <= -1.05e-5) tmp = abs((x * (z / 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, -1.05e-5], N[Abs[N[(x * N[(z / 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 -1.05 \cdot 10^{-5}:\\
\;\;\;\;\left|x \cdot \frac{z}{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 < -1.04999999999999994e-5Initial program 86.9%
Simplified92.1%
Taylor expanded in z around inf 56.5%
associate-*l/63.9%
*-commutative63.9%
Simplified63.9%
if -1.04999999999999994e-5 < x < 4Initial program 97.7%
Taylor expanded in x around 0 78.5%
if 4 < x Initial program 87.6%
Taylor expanded in z around 0 69.4%
associate-*r/69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in x around inf 65.1%
Final simplification72.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -1.05e-5) (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 <= -1.05e-5) {
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 <= (-1.05d-5)) 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 <= -1.05e-5) {
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 <= -1.05e-5: 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 <= -1.05e-5) 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 <= -1.05e-5) 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, -1.05e-5], 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 -1.05 \cdot 10^{-5}:\\
\;\;\;\;\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 < -1.04999999999999994e-5Initial program 86.9%
Simplified92.1%
Taylor expanded in z around inf 56.5%
add-sqr-sqrt35.7%
sqrt-unprod50.5%
sqr-neg50.5%
sqrt-unprod20.7%
add-sqr-sqrt56.5%
associate-*r/68.5%
*-commutative68.5%
add-sqr-sqrt23.7%
sqrt-unprod55.0%
sqr-neg55.0%
sqrt-unprod44.6%
add-sqr-sqrt68.5%
Applied egg-rr68.5%
if -1.04999999999999994e-5 < x < 4Initial program 97.7%
Taylor expanded in x around 0 78.5%
if 4 < x Initial program 87.6%
Taylor expanded in z around 0 69.4%
associate-*r/69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in x around inf 65.1%
Final simplification73.5%
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 93.2%
Taylor expanded in x around 0 46.7%
Final simplification46.7%
herbie shell --seed 2023213
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))