
(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 7 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 (if (<= x 2.8e+82) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (/ (- 1.0 z) (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+82) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((1.0 - z) / (y / x)));
}
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 <= 2.8d+82) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((1.0d0 - z) / (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+82) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((1.0 - z) / (y / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.8e+82: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((1.0 - z) / (y / x))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.8e+82) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.8e+82) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((1.0 - z) / (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.8e+82], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+82}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if x < 2.8e82Initial program 90.4%
associate-*l/95.1%
sub-div98.5%
Applied egg-rr98.5%
if 2.8e82 < x Initial program 90.1%
fabs-neg90.1%
sub-neg90.1%
distribute-neg-in90.1%
sub-neg90.1%
distribute-neg-frac90.1%
associate-*l/83.1%
distribute-neg-frac83.1%
neg-mul-183.1%
associate-*l/83.0%
neg-mul-183.0%
associate-*l/83.0%
distribute-lft-out--88.8%
fabs-mul88.8%
fabs-sub88.8%
fabs-mul88.8%
associate-*l/88.9%
Simplified88.9%
Taylor expanded in x around inf 88.9%
associate-/l*99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ 4.0 y))))
(if (<= x -5.2e-79)
t_0
(if (<= x 1.66e-108)
t_1
(if (<= x 2.55e-77)
t_0
(if (<= x 4.0)
t_1
(if (or (<= x 2.5e+86) (not (<= x 1.02e+119)))
(fabs (/ x y))
t_0)))))))
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs((4.0 / y));
double tmp;
if (x <= -5.2e-79) {
tmp = t_0;
} else if (x <= 1.66e-108) {
tmp = t_1;
} else if (x <= 2.55e-77) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = t_1;
} else if ((x <= 2.5e+86) || !(x <= 1.02e+119)) {
tmp = fabs((x / y));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((z * (x / y)))
t_1 = abs((4.0d0 / y))
if (x <= (-5.2d-79)) then
tmp = t_0
else if (x <= 1.66d-108) then
tmp = t_1
else if (x <= 2.55d-77) then
tmp = t_0
else if (x <= 4.0d0) then
tmp = t_1
else if ((x <= 2.5d+86) .or. (.not. (x <= 1.02d+119))) then
tmp = abs((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((z * (x / y)));
double t_1 = Math.abs((4.0 / y));
double tmp;
if (x <= -5.2e-79) {
tmp = t_0;
} else if (x <= 1.66e-108) {
tmp = t_1;
} else if (x <= 2.55e-77) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = t_1;
} else if ((x <= 2.5e+86) || !(x <= 1.02e+119)) {
tmp = Math.abs((x / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs((4.0 / y)) tmp = 0 if x <= -5.2e-79: tmp = t_0 elif x <= 1.66e-108: tmp = t_1 elif x <= 2.55e-77: tmp = t_0 elif x <= 4.0: tmp = t_1 elif (x <= 2.5e+86) or not (x <= 1.02e+119): tmp = math.fabs((x / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(4.0 / y)) tmp = 0.0 if (x <= -5.2e-79) tmp = t_0; elseif (x <= 1.66e-108) tmp = t_1; elseif (x <= 2.55e-77) tmp = t_0; elseif (x <= 4.0) tmp = t_1; elseif ((x <= 2.5e+86) || !(x <= 1.02e+119)) tmp = abs(Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); t_1 = abs((4.0 / y)); tmp = 0.0; if (x <= -5.2e-79) tmp = t_0; elseif (x <= 1.66e-108) tmp = t_1; elseif (x <= 2.55e-77) tmp = t_0; elseif (x <= 4.0) tmp = t_1; elseif ((x <= 2.5e+86) || ~((x <= 1.02e+119))) tmp = abs((x / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.2e-79], t$95$0, If[LessEqual[x, 1.66e-108], t$95$1, If[LessEqual[x, 2.55e-77], t$95$0, If[LessEqual[x, 4.0], t$95$1, If[Or[LessEqual[x, 2.5e+86], N[Not[LessEqual[x, 1.02e+119]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{-79}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+86} \lor \neg \left(x \leq 1.02 \cdot 10^{+119}\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -5.19999999999999987e-79 or 1.65999999999999993e-108 < x < 2.55000000000000016e-77 or 2.4999999999999999e86 < x < 1.02e119Initial program 86.0%
Taylor expanded in z around inf 60.7%
associate-*r/60.7%
mul-1-neg60.7%
distribute-rgt-neg-out60.7%
*-commutative60.7%
associate-*l/71.7%
distribute-neg-frac71.7%
*-commutative71.7%
distribute-neg-frac71.7%
Simplified71.7%
associate-*r/60.7%
add-cube-cbrt60.2%
times-frac64.6%
add-sqr-sqrt51.3%
sqrt-unprod58.6%
sqr-neg58.6%
sqrt-unprod13.3%
add-sqr-sqrt64.6%
times-frac60.2%
*-commutative60.2%
add-cube-cbrt60.7%
associate-/l*63.0%
Applied egg-rr63.0%
associate-/r/71.7%
Applied egg-rr71.7%
if -5.19999999999999987e-79 < x < 1.65999999999999993e-108 or 2.55000000000000016e-77 < x < 4Initial program 96.1%
Taylor expanded in x around 0 80.6%
if 4 < x < 2.4999999999999999e86 or 1.02e119 < x Initial program 88.7%
fabs-neg88.7%
sub-neg88.7%
distribute-neg-in88.7%
sub-neg88.7%
distribute-neg-frac88.7%
associate-*l/86.0%
distribute-neg-frac86.0%
neg-mul-186.0%
associate-*l/85.8%
neg-mul-185.8%
associate-*l/85.8%
distribute-lft-out--92.3%
fabs-mul92.3%
fabs-sub92.3%
fabs-mul92.3%
associate-*l/92.4%
Simplified92.4%
Taylor expanded in x around inf 91.7%
Taylor expanded in z around 0 72.1%
Final simplification75.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ 4.0 y))))
(if (<= x -7.2e-77)
t_0
(if (<= x 1.66e-108)
t_1
(if (<= x 2.2e-78)
(fabs (* x (/ z y)))
(if (<= x 4.0)
t_1
(if (or (<= x 3.1e+86) (not (<= x 1.3e+120)))
(fabs (/ x y))
t_0)))))))
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs((4.0 / y));
double tmp;
if (x <= -7.2e-77) {
tmp = t_0;
} else if (x <= 1.66e-108) {
tmp = t_1;
} else if (x <= 2.2e-78) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.0) {
tmp = t_1;
} else if ((x <= 3.1e+86) || !(x <= 1.3e+120)) {
tmp = fabs((x / y));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((z * (x / y)))
t_1 = abs((4.0d0 / y))
if (x <= (-7.2d-77)) then
tmp = t_0
else if (x <= 1.66d-108) then
tmp = t_1
else if (x <= 2.2d-78) then
tmp = abs((x * (z / y)))
else if (x <= 4.0d0) then
tmp = t_1
else if ((x <= 3.1d+86) .or. (.not. (x <= 1.3d+120))) then
tmp = abs((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((z * (x / y)));
double t_1 = Math.abs((4.0 / y));
double tmp;
if (x <= -7.2e-77) {
tmp = t_0;
} else if (x <= 1.66e-108) {
tmp = t_1;
} else if (x <= 2.2e-78) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.0) {
tmp = t_1;
} else if ((x <= 3.1e+86) || !(x <= 1.3e+120)) {
tmp = Math.abs((x / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs((4.0 / y)) tmp = 0 if x <= -7.2e-77: tmp = t_0 elif x <= 1.66e-108: tmp = t_1 elif x <= 2.2e-78: tmp = math.fabs((x * (z / y))) elif x <= 4.0: tmp = t_1 elif (x <= 3.1e+86) or not (x <= 1.3e+120): tmp = math.fabs((x / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(4.0 / y)) tmp = 0.0 if (x <= -7.2e-77) tmp = t_0; elseif (x <= 1.66e-108) tmp = t_1; elseif (x <= 2.2e-78) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.0) tmp = t_1; elseif ((x <= 3.1e+86) || !(x <= 1.3e+120)) tmp = abs(Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); t_1 = abs((4.0 / y)); tmp = 0.0; if (x <= -7.2e-77) tmp = t_0; elseif (x <= 1.66e-108) tmp = t_1; elseif (x <= 2.2e-78) tmp = abs((x * (z / y))); elseif (x <= 4.0) tmp = t_1; elseif ((x <= 3.1e+86) || ~((x <= 1.3e+120))) tmp = abs((x / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -7.2e-77], t$95$0, If[LessEqual[x, 1.66e-108], t$95$1, If[LessEqual[x, 2.2e-78], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], t$95$1, If[Or[LessEqual[x, 3.1e+86], N[Not[LessEqual[x, 1.3e+120]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{-77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-78}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+86} \lor \neg \left(x \leq 1.3 \cdot 10^{+120}\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.2e-77 or 3.1000000000000002e86 < x < 1.2999999999999999e120Initial program 86.0%
Taylor expanded in z around inf 58.3%
associate-*r/58.3%
mul-1-neg58.3%
distribute-rgt-neg-out58.3%
*-commutative58.3%
associate-*l/71.1%
distribute-neg-frac71.1%
*-commutative71.1%
distribute-neg-frac71.1%
Simplified71.1%
associate-*r/58.3%
add-cube-cbrt57.9%
times-frac62.6%
add-sqr-sqrt55.1%
sqrt-unprod56.1%
sqr-neg56.1%
sqrt-unprod7.5%
add-sqr-sqrt62.6%
times-frac57.9%
*-commutative57.9%
add-cube-cbrt58.3%
associate-/l*60.7%
Applied egg-rr60.7%
associate-/r/71.1%
Applied egg-rr71.1%
if -7.2e-77 < x < 1.65999999999999993e-108 or 2.1999999999999999e-78 < x < 4Initial program 96.1%
Taylor expanded in x around 0 80.6%
if 1.65999999999999993e-108 < x < 2.1999999999999999e-78Initial program 86.3%
fabs-sub86.3%
associate-*l/100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
fma-neg100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 93.0%
Taylor expanded in z around inf 93.0%
if 4 < x < 3.1000000000000002e86 or 1.2999999999999999e120 < x Initial program 88.7%
fabs-neg88.7%
sub-neg88.7%
distribute-neg-in88.7%
sub-neg88.7%
distribute-neg-frac88.7%
associate-*l/86.0%
distribute-neg-frac86.0%
neg-mul-186.0%
associate-*l/85.8%
neg-mul-185.8%
associate-*l/85.8%
distribute-lft-out--92.3%
fabs-mul92.3%
fabs-sub92.3%
fabs-mul92.3%
associate-*l/92.4%
Simplified92.4%
Taylor expanded in x around inf 91.7%
Taylor expanded in z around 0 72.1%
Final simplification75.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ (- 1.0 z) (/ y x)))))
(if (<= x -5.6e-77)
t_1
(if (<= x 9.2e-117)
t_0
(if (<= x 2.02e-78)
(fabs (/ (* x (- 1.0 z)) y))
(if (<= x 2.7e-9) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = fabs((4.0 / y));
double t_1 = fabs(((1.0 - z) / (y / x)));
double tmp;
if (x <= -5.6e-77) {
tmp = t_1;
} else if (x <= 9.2e-117) {
tmp = t_0;
} else if (x <= 2.02e-78) {
tmp = fabs(((x * (1.0 - z)) / y));
} else if (x <= 2.7e-9) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((4.0d0 / y))
t_1 = abs(((1.0d0 - z) / (y / x)))
if (x <= (-5.6d-77)) then
tmp = t_1
else if (x <= 9.2d-117) then
tmp = t_0
else if (x <= 2.02d-78) then
tmp = abs(((x * (1.0d0 - z)) / y))
else if (x <= 2.7d-9) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((4.0 / y));
double t_1 = Math.abs(((1.0 - z) / (y / x)));
double tmp;
if (x <= -5.6e-77) {
tmp = t_1;
} else if (x <= 9.2e-117) {
tmp = t_0;
} else if (x <= 2.02e-78) {
tmp = Math.abs(((x * (1.0 - z)) / y));
} else if (x <= 2.7e-9) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((4.0 / y)) t_1 = math.fabs(((1.0 - z) / (y / x))) tmp = 0 if x <= -5.6e-77: tmp = t_1 elif x <= 9.2e-117: tmp = t_0 elif x <= 2.02e-78: tmp = math.fabs(((x * (1.0 - z)) / y)) elif x <= 2.7e-9: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(4.0 / y)) t_1 = abs(Float64(Float64(1.0 - z) / Float64(y / x))) tmp = 0.0 if (x <= -5.6e-77) tmp = t_1; elseif (x <= 9.2e-117) tmp = t_0; elseif (x <= 2.02e-78) tmp = abs(Float64(Float64(x * Float64(1.0 - z)) / y)); elseif (x <= 2.7e-9) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((4.0 / y)); t_1 = abs(((1.0 - z) / (y / x))); tmp = 0.0; if (x <= -5.6e-77) tmp = t_1; elseif (x <= 9.2e-117) tmp = t_0; elseif (x <= 2.02e-78) tmp = abs(((x * (1.0 - z)) / y)); elseif (x <= 2.7e-9) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.6e-77], t$95$1, If[LessEqual[x, 9.2e-117], t$95$0, If[LessEqual[x, 2.02e-78], N[Abs[N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.7e-9], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{1 - z}{\frac{y}{x}}\right|\\
\mathbf{if}\;x \leq -5.6 \cdot 10^{-77}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-117}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.02 \cdot 10^{-78}:\\
\;\;\;\;\left|\frac{x \cdot \left(1 - z\right)}{y}\right|\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -5.5999999999999999e-77 or 2.7000000000000002e-9 < x Initial program 87.2%
fabs-neg87.2%
sub-neg87.2%
distribute-neg-in87.2%
sub-neg87.2%
distribute-neg-frac87.2%
associate-*l/88.2%
distribute-neg-frac88.2%
neg-mul-188.2%
associate-*l/88.1%
neg-mul-188.1%
associate-*l/88.1%
distribute-lft-out--94.5%
fabs-mul94.5%
fabs-sub94.5%
fabs-mul94.5%
associate-*l/94.6%
Simplified94.6%
Taylor expanded in x around inf 89.0%
associate-/l*94.2%
Simplified94.2%
if -5.5999999999999999e-77 < x < 9.19999999999999978e-117 or 2.0200000000000001e-78 < x < 2.7000000000000002e-9Initial program 95.9%
Taylor expanded in x around 0 82.6%
if 9.19999999999999978e-117 < x < 2.0200000000000001e-78Initial program 91.1%
fabs-neg91.1%
sub-neg91.1%
distribute-neg-in91.1%
sub-neg91.1%
distribute-neg-frac91.1%
associate-*l/100.0%
distribute-neg-frac100.0%
neg-mul-1100.0%
associate-*l/100.0%
neg-mul-1100.0%
associate-*l/99.9%
distribute-lft-out--99.9%
fabs-mul99.9%
fabs-sub99.9%
fabs-mul99.9%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around inf 78.5%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+38) (not (<= z 4.5e+30))) (fabs (* z (/ x y))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+38) || !(z <= 4.5e+30)) {
tmp = fabs((z * (x / y)));
} 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 ((z <= (-2d+38)) .or. (.not. (z <= 4.5d+30))) then
tmp = abs((z * (x / y)))
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 ((z <= -2e+38) || !(z <= 4.5e+30)) {
tmp = Math.abs((z * (x / y)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+38) or not (z <= 4.5e+30): tmp = math.fabs((z * (x / y))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+38) || !(z <= 4.5e+30)) tmp = abs(Float64(z * Float64(x / y))); else tmp = abs(Float64(Float64(-4.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+38) || ~((z <= 4.5e+30))) tmp = abs((z * (x / y))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+38], N[Not[LessEqual[z, 4.5e+30]], $MachinePrecision]], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+38} \lor \neg \left(z \leq 4.5 \cdot 10^{+30}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -1.99999999999999995e38 or 4.49999999999999995e30 < z Initial program 91.7%
Taylor expanded in z around inf 72.8%
associate-*r/72.8%
mul-1-neg72.8%
distribute-rgt-neg-out72.8%
*-commutative72.8%
associate-*l/76.5%
distribute-neg-frac76.5%
*-commutative76.5%
distribute-neg-frac76.5%
Simplified76.5%
associate-*r/72.8%
add-cube-cbrt72.1%
times-frac72.9%
add-sqr-sqrt39.0%
sqrt-unprod59.5%
sqr-neg59.5%
sqrt-unprod33.9%
add-sqr-sqrt72.9%
times-frac72.1%
*-commutative72.1%
add-cube-cbrt72.8%
associate-/l*74.0%
Applied egg-rr74.0%
associate-/r/76.5%
Applied egg-rr76.5%
if -1.99999999999999995e38 < z < 4.49999999999999995e30Initial program 89.2%
fabs-sub89.2%
associate-*l/96.4%
*-commutative96.4%
associate-*l/95.1%
*-commutative95.1%
fma-neg98.7%
distribute-neg-frac98.7%
+-commutative98.7%
distribute-neg-in98.7%
unsub-neg98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in z around 0 94.5%
associate-*r/94.5%
distribute-lft-in94.5%
metadata-eval94.5%
neg-mul-194.5%
sub-neg94.5%
Simplified94.5%
Final simplification86.3%
(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 85.1%
fabs-neg85.1%
sub-neg85.1%
distribute-neg-in85.1%
sub-neg85.1%
distribute-neg-frac85.1%
associate-*l/86.4%
distribute-neg-frac86.4%
neg-mul-186.4%
associate-*l/86.2%
neg-mul-186.2%
associate-*l/86.2%
distribute-lft-out--93.6%
fabs-mul93.6%
fabs-sub93.6%
fabs-mul93.6%
associate-*l/93.8%
Simplified93.8%
Taylor expanded in x around inf 92.6%
Taylor expanded in z around 0 61.8%
if -1.55000000000000004 < x < 4Initial program 96.2%
Taylor expanded in x around 0 67.6%
Final simplification64.5%
(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 90.3%
Taylor expanded in x around 0 34.8%
Final simplification34.8%
herbie shell --seed 2023176
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))