
(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}
(FPCore (x y z) :precision binary64 (fabs (/ (- 1.0 (/ x (/ (+ x 4.0) z))) (/ y (+ x 4.0)))))
double code(double x, double y, double z) {
return fabs(((1.0 - (x / ((x + 4.0) / z))) / (y / (x + 4.0))));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs(((1.0d0 - (x / ((x + 4.0d0) / z))) / (y / (x + 4.0d0))))
end function
public static double code(double x, double y, double z) {
return Math.abs(((1.0 - (x / ((x + 4.0) / z))) / (y / (x + 4.0))));
}
def code(x, y, z): return math.fabs(((1.0 - (x / ((x + 4.0) / z))) / (y / (x + 4.0))))
function code(x, y, z) return abs(Float64(Float64(1.0 - Float64(x / Float64(Float64(x + 4.0) / z))) / Float64(y / Float64(x + 4.0)))) end
function tmp = code(x, y, z) tmp = abs(((1.0 - (x / ((x + 4.0) / z))) / (y / (x + 4.0)))); end
code[x_, y_, z_] := N[Abs[N[(N[(1.0 - N[(x / N[(N[(x + 4.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y / N[(x + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1 - \frac{x}{\frac{x + 4}{z}}}{\frac{y}{x + 4}}\right|
\end{array}
Initial program 91.6%
clear-num91.6%
associate-*l/92.6%
frac-sub61.1%
*-un-lft-identity61.1%
Applied egg-rr61.1%
associate-*l/56.8%
associate-/r/59.9%
*-commutative59.9%
*-commutative59.9%
associate-*l*63.5%
Simplified63.5%
Taylor expanded in y around 0 96.9%
associate-/l*96.9%
*-commutative96.9%
+-commutative96.9%
associate-/l*99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= z -125000000.0) (* (fabs (/ x y)) (fabs z)) (if (<= z 7e+108) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -125000000.0) {
tmp = fabs((x / y)) * fabs(z);
} else if (z <= 7e+108) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x * (z / y)));
}
return tmp;
}
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 <= (-125000000.0d0)) then
tmp = abs((x / y)) * abs(z)
else if (z <= 7d+108) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -125000000.0) {
tmp = Math.abs((x / y)) * Math.abs(z);
} else if (z <= 7e+108) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -125000000.0: tmp = math.fabs((x / y)) * math.fabs(z) elif z <= 7e+108: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -125000000.0) tmp = Float64(abs(Float64(x / y)) * abs(z)); elseif (z <= 7e+108) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -125000000.0) tmp = abs((x / y)) * abs(z); elseif (z <= 7e+108) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -125000000.0], N[(N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e+108], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -125000000:\\
\;\;\;\;\left|\frac{x}{y}\right| \cdot \left|z\right|\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+108}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -1.25e8Initial program 98.3%
Taylor expanded in z around inf 68.8%
associate-*r/68.8%
mul-1-neg68.8%
distribute-rgt-neg-out68.8%
associate-*r/76.1%
distribute-frac-neg76.1%
mul-1-neg76.1%
metadata-eval76.1%
times-frac76.1%
*-lft-identity76.1%
neg-mul-176.1%
Simplified76.1%
if -1.25e8 < z < 7.0000000000000005e108Initial program 94.1%
Simplified99.9%
Taylor expanded in z around 0 95.0%
associate-*r/95.0%
distribute-lft-in95.0%
metadata-eval95.0%
neg-mul-195.0%
sub-neg95.0%
Simplified95.0%
if 7.0000000000000005e108 < z Initial program 73.7%
Simplified93.1%
Taylor expanded in z around inf 76.9%
associate-*l/78.5%
*-commutative78.5%
Simplified78.5%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -350.0) (not (<= x 1.1e-10))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -350.0) || !(x <= 1.1e-10)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs(((-4.0 - x) / y));
}
return tmp;
}
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 <= (-350.0d0)) .or. (.not. (x <= 1.1d-10))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs((((-4.0d0) - x) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -350.0) || !(x <= 1.1e-10)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -350.0) or not (x <= 1.1e-10): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -350.0) || !(x <= 1.1e-10)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(-4.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -350.0) || ~((x <= 1.1e-10))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -350.0], N[Not[LessEqual[x, 1.1e-10]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -350 \lor \neg \left(x \leq 1.1 \cdot 10^{-10}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if x < -350 or 1.09999999999999995e-10 < x Initial program 87.6%
Simplified94.0%
Taylor expanded in x around inf 93.5%
associate-/l*99.1%
sub-neg99.1%
metadata-eval99.1%
Simplified99.1%
if -350 < x < 1.09999999999999995e-10Initial program 95.9%
Simplified99.9%
Taylor expanded in z around 0 80.8%
associate-*r/80.8%
distribute-lft-in80.8%
metadata-eval80.8%
neg-mul-180.8%
sub-neg80.8%
Simplified80.8%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= x -6e+56) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6e+56) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
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+56)) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs((((x + 4.0d0) - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -6e+56) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6e+56: tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6e+56) 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
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6e+56) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6e+56], 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}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+56}:\\
\;\;\;\;\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.00000000000000012e56Initial program 87.3%
Simplified88.0%
Taylor expanded in x around inf 88.1%
associate-/l*99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -6.00000000000000012e56 < x Initial program 92.9%
associate-*l/96.4%
sub-div99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= x -7.4e+56) (fabs (* x (/ z y))) (if (or (<= x -1.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.4e+56) {
tmp = fabs((x * (z / y)));
} else if ((x <= -1.5) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((4.0 / y));
}
return tmp;
}
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 <= (-7.4d+56)) then
tmp = abs((x * (z / y)))
else if ((x <= (-1.5d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -7.4e+56) {
tmp = Math.abs((x * (z / y)));
} else if ((x <= -1.5) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.4e+56: tmp = math.fabs((x * (z / y))) elif (x <= -1.5) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7.4e+56) tmp = abs(Float64(x * Float64(z / y))); elseif ((x <= -1.5) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7.4e+56) tmp = abs((x * (z / y))); elseif ((x <= -1.5) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.4e+56], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.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}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+56}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq -1.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 < -7.39999999999999994e56Initial program 87.3%
Simplified88.0%
Taylor expanded in z around inf 56.4%
associate-*l/68.1%
*-commutative68.1%
Simplified68.1%
if -7.39999999999999994e56 < x < -1.5 or 4 < x Initial program 87.6%
associate-*l/90.4%
sub-div98.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 97.6%
associate-/l*98.7%
Simplified98.7%
Taylor expanded in z around 0 70.8%
if -1.5 < x < 4Initial program 95.9%
Taylor expanded in x around 0 78.5%
Final simplification74.0%
(FPCore (x y z) :precision binary64 (if (<= x -1.8e+43) (fabs (/ z (/ y x))) (if (or (<= x -1.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e+43) {
tmp = fabs((z / (y / x)));
} else if ((x <= -1.5) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((4.0 / y));
}
return tmp;
}
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.8d+43)) then
tmp = abs((z / (y / x)))
else if ((x <= (-1.5d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e+43) {
tmp = Math.abs((z / (y / x)));
} else if ((x <= -1.5) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.8e+43: tmp = math.fabs((z / (y / x))) elif (x <= -1.5) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.8e+43) tmp = abs(Float64(z / Float64(y / x))); elseif ((x <= -1.5) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.8e+43) tmp = abs((z / (y / x))); elseif ((x <= -1.5) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.8e+43], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.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}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+43}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;x \leq -1.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 < -1.80000000000000005e43Initial program 88.1%
Taylor expanded in z around inf 56.1%
associate-*r/56.1%
mul-1-neg56.1%
distribute-rgt-neg-out56.1%
associate-*r/73.2%
distribute-frac-neg73.2%
mul-1-neg73.2%
metadata-eval73.2%
times-frac73.2%
*-lft-identity73.2%
neg-mul-173.2%
Simplified73.2%
associate-*r/56.1%
add-sqr-sqrt32.8%
sqrt-unprod54.4%
sqr-neg54.4%
sqrt-prod23.2%
add-sqr-sqrt56.1%
associate-/l*73.3%
Applied egg-rr73.3%
if -1.80000000000000005e43 < x < -1.5 or 4 < x Initial program 86.8%
associate-*l/89.9%
sub-div98.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 97.5%
associate-/l*98.7%
Simplified98.7%
Taylor expanded in z around 0 71.8%
if -1.5 < x < 4Initial program 95.9%
Taylor expanded in x around 0 78.5%
Final simplification75.5%
(FPCore (x y z) :precision binary64 (if (<= z -300000000.0) (fabs (/ z (/ y x))) (if (<= z 1.8e+112) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -300000000.0) {
tmp = fabs((z / (y / x)));
} else if (z <= 1.8e+112) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x * (z / y)));
}
return tmp;
}
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 <= (-300000000.0d0)) then
tmp = abs((z / (y / x)))
else if (z <= 1.8d+112) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -300000000.0) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 1.8e+112) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -300000000.0: tmp = math.fabs((z / (y / x))) elif z <= 1.8e+112: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -300000000.0) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 1.8e+112) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -300000000.0) tmp = abs((z / (y / x))); elseif (z <= 1.8e+112) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -300000000.0], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.8e+112], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -300000000:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+112}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -3e8Initial program 98.3%
Taylor expanded in z around inf 68.8%
associate-*r/68.8%
mul-1-neg68.8%
distribute-rgt-neg-out68.8%
associate-*r/76.1%
distribute-frac-neg76.1%
mul-1-neg76.1%
metadata-eval76.1%
times-frac76.1%
*-lft-identity76.1%
neg-mul-176.1%
Simplified76.1%
associate-*r/68.8%
add-sqr-sqrt33.5%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-prod35.3%
add-sqr-sqrt68.8%
associate-/l*76.0%
Applied egg-rr76.0%
if -3e8 < z < 1.8e112Initial program 94.1%
Simplified99.9%
Taylor expanded in z around 0 95.0%
associate-*r/95.0%
distribute-lft-in95.0%
metadata-eval95.0%
neg-mul-195.0%
sub-neg95.0%
Simplified95.0%
if 1.8e112 < z Initial program 73.7%
Simplified93.1%
Taylor expanded in z around inf 76.9%
associate-*l/78.5%
*-commutative78.5%
Simplified78.5%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((4.0 / y));
}
return tmp;
}
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.55d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.55) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.55) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.55) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.55], 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}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \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 < -1.55000000000000004 or 4 < x Initial program 87.4%
associate-*l/85.5%
sub-div94.0%
Applied egg-rr94.0%
Taylor expanded in x around inf 93.5%
associate-/l*99.2%
Simplified99.2%
Taylor expanded in z around 0 63.1%
if -1.55000000000000004 < x < 4Initial program 95.9%
Taylor expanded in x around 0 78.5%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
double code(double x, double y, double z) {
return fabs((4.0 / y));
}
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
public static double code(double x, double y, double z) {
return Math.abs((4.0 / y));
}
def code(x, y, z): return math.fabs((4.0 / y))
function code(x, y, z) return abs(Float64(4.0 / y)) end
function tmp = code(x, y, z) tmp = abs((4.0 / y)); end
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{4}{y}\right|
\end{array}
Initial program 91.6%
Taylor expanded in x around 0 41.7%
Final simplification41.7%
herbie shell --seed 2023201
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))