
(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 5e-45) (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 <= 5e-45) {
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 <= 5d-45) 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 <= 5e-45) {
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 <= 5e-45: 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 <= 5e-45) 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 <= 5e-45) 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, 5e-45], 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 5 \cdot 10^{-45}:\\
\;\;\;\;\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 < 4.99999999999999976e-45Initial program 94.9%
associate-*l/94.4%
associate-*r/89.8%
Simplified89.8%
associate-*r/94.4%
sub-div97.3%
Applied egg-rr97.3%
if 4.99999999999999976e-45 < y Initial program 98.6%
associate-*l/94.9%
associate-*r/99.9%
Simplified99.9%
Final simplification98.0%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))))
(if (<= x -1.25e-124)
t_0
(if (<= x 4.0)
(fabs (/ 4.0 y))
(if (or (<= x 3.5e+96) (and (not (<= x 4e+157)) (<= x 1.75e+204)))
(fabs (/ x y))
t_0)))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double tmp;
if (x <= -1.25e-124) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else if ((x <= 3.5e+96) || (!(x <= 4e+157) && (x <= 1.75e+204))) {
tmp = fabs((x / y));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = abs((z * (x / y)))
if (x <= (-1.25d-124)) then
tmp = t_0
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else if ((x <= 3.5d+96) .or. (.not. (x <= 4d+157)) .and. (x <= 1.75d+204)) then
tmp = abs((x / y))
else
tmp = t_0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.abs((z * (x / y)));
double tmp;
if (x <= -1.25e-124) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 3.5e+96) || (!(x <= 4e+157) && (x <= 1.75e+204))) {
tmp = Math.abs((x / y));
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z * (x / y))) tmp = 0 if x <= -1.25e-124: tmp = t_0 elif x <= 4.0: tmp = math.fabs((4.0 / y)) elif (x <= 3.5e+96) or (not (x <= 4e+157) and (x <= 1.75e+204)): tmp = math.fabs((x / y)) else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) tmp = 0.0 if (x <= -1.25e-124) tmp = t_0; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); elseif ((x <= 3.5e+96) || (!(x <= 4e+157) && (x <= 1.75e+204))) tmp = abs(Float64(x / y)); else tmp = t_0; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); tmp = 0.0; if (x <= -1.25e-124) tmp = t_0; elseif (x <= 4.0) tmp = abs((4.0 / y)); elseif ((x <= 3.5e+96) || (~((x <= 4e+157)) && (x <= 1.75e+204))) tmp = abs((x / y)); else tmp = t_0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.25e-124], t$95$0, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 3.5e+96], And[N[Not[LessEqual[x, 4e+157]], $MachinePrecision], LessEqual[x, 1.75e+204]]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{-124}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+96} \lor \neg \left(x \leq 4 \cdot 10^{+157}\right) \land x \leq 1.75 \cdot 10^{+204}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.2500000000000001e-124 or 3.4999999999999999e96 < x < 3.99999999999999993e157 or 1.74999999999999995e204 < x Initial program 94.1%
associate-*l/91.2%
associate-*r/93.6%
Simplified93.6%
Taylor expanded in z around inf 60.0%
mul-1-neg60.0%
associate-/l*69.3%
distribute-neg-frac69.3%
Simplified69.3%
clear-num69.2%
associate-/r/69.2%
clear-num69.2%
add-sqr-sqrt36.9%
sqrt-unprod45.0%
sqr-neg45.0%
sqrt-unprod32.3%
add-sqr-sqrt69.2%
Applied egg-rr69.2%
if -1.2500000000000001e-124 < x < 4Initial program 98.9%
associate-*l/99.9%
associate-*r/90.0%
Simplified90.0%
Taylor expanded in x around 0 82.1%
if 4 < x < 3.4999999999999999e96 or 3.99999999999999993e157 < x < 1.74999999999999995e204Initial program 94.6%
associate-*l/92.5%
associate-*r/97.3%
Simplified97.3%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in x around inf 68.9%
Final simplification74.0%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (/ z (/ y x)))))
(if (<= x -1.25e-124)
t_1
(if (<= x 4.0)
(fabs (/ 4.0 y))
(if (<= x 7e+98)
t_0
(if (<= x 1.4e+160)
t_1
(if (<= x 3.4e+208) t_0 (fabs (* z (/ x y))))))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((z / (y / x)));
double tmp;
if (x <= -1.25e-124) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else if (x <= 7e+98) {
tmp = t_0;
} else if (x <= 1.4e+160) {
tmp = t_1;
} else if (x <= 3.4e+208) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((z / (y / x)))
if (x <= (-1.25d-124)) then
tmp = t_1
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else if (x <= 7d+98) then
tmp = t_0
else if (x <= 1.4d+160) then
tmp = t_1
else if (x <= 3.4d+208) then
tmp = t_0
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 t_0 = Math.abs((x / y));
double t_1 = Math.abs((z / (y / x)));
double tmp;
if (x <= -1.25e-124) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else if (x <= 7e+98) {
tmp = t_0;
} else if (x <= 1.4e+160) {
tmp = t_1;
} else if (x <= 3.4e+208) {
tmp = t_0;
} else {
tmp = Math.abs((z * (x / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((z / (y / x))) tmp = 0 if x <= -1.25e-124: tmp = t_1 elif x <= 4.0: tmp = math.fabs((4.0 / y)) elif x <= 7e+98: tmp = t_0 elif x <= 1.4e+160: tmp = t_1 elif x <= 3.4e+208: tmp = t_0 else: tmp = math.fabs((z * (x / y))) return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(z / Float64(y / x))) tmp = 0.0 if (x <= -1.25e-124) tmp = t_1; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); elseif (x <= 7e+98) tmp = t_0; elseif (x <= 1.4e+160) tmp = t_1; elseif (x <= 3.4e+208) tmp = t_0; else tmp = abs(Float64(z * Float64(x / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((z / (y / x))); tmp = 0.0; if (x <= -1.25e-124) tmp = t_1; elseif (x <= 4.0) tmp = abs((4.0 / y)); elseif (x <= 7e+98) tmp = t_0; elseif (x <= 1.4e+160) tmp = t_1; elseif (x <= 3.4e+208) tmp = t_0; else tmp = abs((z * (x / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.25e-124], t$95$1, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 7e+98], t$95$0, If[LessEqual[x, 1.4e+160], t$95$1, If[LessEqual[x, 3.4e+208], t$95$0, N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{-124}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+98}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+160}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+208}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -1.2500000000000001e-124 or 7e98 < x < 1.4e160Initial program 96.0%
associate-*l/92.4%
associate-*r/94.3%
Simplified94.3%
Taylor expanded in z around inf 59.2%
mul-1-neg59.2%
associate-/l*67.5%
distribute-neg-frac67.5%
Simplified67.5%
associate-/r/61.1%
add-sqr-sqrt33.1%
sqrt-unprod41.7%
sqr-neg41.7%
sqrt-unprod27.7%
add-sqr-sqrt61.1%
Applied egg-rr61.1%
associate-*l/59.2%
associate-/l*67.5%
Applied egg-rr67.5%
if -1.2500000000000001e-124 < x < 4Initial program 98.9%
associate-*l/99.9%
associate-*r/90.0%
Simplified90.0%
Taylor expanded in x around 0 82.1%
if 4 < x < 7e98 or 1.4e160 < x < 3.3999999999999998e208Initial program 94.6%
associate-*l/92.5%
associate-*r/97.3%
Simplified97.3%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in x around inf 68.9%
if 3.3999999999999998e208 < x Initial program 84.1%
associate-*l/84.5%
associate-*r/89.5%
Simplified89.5%
Taylor expanded in z around inf 64.2%
mul-1-neg64.2%
associate-/l*79.1%
distribute-neg-frac79.1%
Simplified79.1%
clear-num79.0%
associate-/r/79.1%
clear-num79.1%
add-sqr-sqrt32.1%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod47.0%
add-sqr-sqrt79.1%
Applied egg-rr79.1%
Final simplification74.0%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= z -1.46e-15) (not (<= z 800000.0))) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (+ x 4.0) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.46e-15) || !(z <= 800000.0)) {
tmp = fabs(((x / y) * (1.0 - 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.46d-15)) .or. (.not. (z <= 800000.0d0))) then
tmp = abs(((x / y) * (1.0d0 - 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.46e-15) || !(z <= 800000.0)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs(((x + 4.0) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (z <= -1.46e-15) or not (z <= 800000.0): tmp = math.fabs(((x / y) * (1.0 - 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.46e-15) || !(z <= 800000.0)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - 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.46e-15) || ~((z <= 800000.0))) tmp = abs(((x / y) * (1.0 - 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.46e-15], N[Not[LessEqual[z, 800000.0]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - 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.46 \cdot 10^{-15} \lor \neg \left(z \leq 800000\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\end{array}
\end{array}
if z < -1.4600000000000001e-15 or 8e5 < z Initial program 95.3%
Taylor expanded in x around inf 76.4%
*-un-lft-identity76.4%
*-commutative76.4%
distribute-rgt-out--79.4%
Applied egg-rr79.4%
if -1.4600000000000001e-15 < z < 8e5Initial program 96.7%
associate-*l/99.1%
associate-*r/99.1%
Simplified99.1%
Taylor expanded in z around 0 100.0%
+-commutative100.0%
*-rgt-identity100.0%
associate-*r/99.8%
distribute-rgt-in99.8%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification89.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= z -1.46e-15) (not (<= z 108000000000.0))) (fabs (* (/ x y) (- 1.0 z))) (fabs (+ (/ x y) (/ 4.0 y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.46e-15) || !(z <= 108000000000.0)) {
tmp = fabs(((x / y) * (1.0 - z)));
} else {
tmp = fabs(((x / y) + (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.46d-15)) .or. (.not. (z <= 108000000000.0d0))) then
tmp = abs(((x / y) * (1.0d0 - z)))
else
tmp = abs(((x / y) + (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.46e-15) || !(z <= 108000000000.0)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs(((x / y) + (4.0 / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (z <= -1.46e-15) or not (z <= 108000000000.0): tmp = math.fabs(((x / y) * (1.0 - z))) else: tmp = math.fabs(((x / y) + (4.0 / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((z <= -1.46e-15) || !(z <= 108000000000.0)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); else tmp = abs(Float64(Float64(x / y) + Float64(4.0 / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.46e-15) || ~((z <= 108000000000.0))) tmp = abs(((x / y) * (1.0 - z))); else tmp = abs(((x / y) + (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.46e-15], N[Not[LessEqual[z, 108000000000.0]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.46 \cdot 10^{-15} \lor \neg \left(z \leq 108000000000\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\
\end{array}
\end{array}
if z < -1.4600000000000001e-15 or 1.08e11 < z Initial program 95.3%
Taylor expanded in x around inf 76.4%
*-un-lft-identity76.4%
*-commutative76.4%
distribute-rgt-out--79.4%
Applied egg-rr79.4%
if -1.4600000000000001e-15 < z < 1.08e11Initial program 96.7%
associate-*l/99.1%
associate-*r/99.1%
Simplified99.1%
Taylor expanded in z around 0 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification89.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x 3.7e+147) (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 <= 3.7e+147) {
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 <= 3.7d+147) 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 <= 3.7e+147) {
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 <= 3.7e+147: 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 <= 3.7e+147) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.7e+147) 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, 3.7e+147], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.7 \cdot 10^{+147}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\end{array}
\end{array}
if x < 3.7e147Initial program 97.6%
associate-*l/97.2%
associate-*r/93.0%
Simplified93.0%
associate-*r/97.2%
sub-div98.1%
Applied egg-rr98.1%
if 3.7e147 < x Initial program 86.1%
Taylor expanded in x around inf 86.1%
*-un-lft-identity86.1%
*-commutative86.1%
distribute-rgt-out--100.0%
Applied egg-rr100.0%
Final simplification98.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= z -44000.0) (not (<= z 7200000000000.0))) (fabs (/ z (/ y x))) (fabs (/ (+ x 4.0) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -44000.0) || !(z <= 7200000000000.0)) {
tmp = fabs((z / (y / x)));
} 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 <= (-44000.0d0)) .or. (.not. (z <= 7200000000000.0d0))) then
tmp = abs((z / (y / x)))
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 <= -44000.0) || !(z <= 7200000000000.0)) {
tmp = Math.abs((z / (y / x)));
} else {
tmp = Math.abs(((x + 4.0) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (z <= -44000.0) or not (z <= 7200000000000.0): tmp = math.fabs((z / (y / x))) else: tmp = math.fabs(((x + 4.0) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((z <= -44000.0) || !(z <= 7200000000000.0)) tmp = abs(Float64(z / Float64(y / x))); 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 <= -44000.0) || ~((z <= 7200000000000.0))) tmp = abs((z / (y / x))); 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, -44000.0], N[Not[LessEqual[z, 7200000000000.0]], $MachinePrecision]], N[Abs[N[(z / N[(y / x), $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 -44000 \lor \neg \left(z \leq 7200000000000\right):\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\end{array}
\end{array}
if z < -44000 or 7.2e12 < z Initial program 95.2%
associate-*l/90.2%
associate-*r/86.7%
Simplified86.7%
Taylor expanded in z around inf 73.9%
mul-1-neg73.9%
associate-/l*78.9%
distribute-neg-frac78.9%
Simplified78.9%
associate-/r/74.5%
add-sqr-sqrt39.3%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod35.0%
add-sqr-sqrt74.5%
Applied egg-rr74.5%
associate-*l/73.9%
associate-/l*78.9%
Applied egg-rr78.9%
if -44000 < z < 7.2e12Initial program 96.8%
associate-*l/99.2%
associate-*r/99.2%
Simplified99.2%
Taylor expanded in z around 0 99.2%
+-commutative99.2%
*-rgt-identity99.2%
associate-*r/99.0%
distribute-rgt-in99.0%
associate-*l/99.2%
*-lft-identity99.2%
Simplified99.2%
Final simplification88.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1.55) (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 <= -1.55) || !(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 <= (-1.55d0)) .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 <= -1.55) || !(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 <= -1.55) 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 <= -1.55) || !(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 <= -1.55) || ~((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, -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}
y = |y|\\
\\
\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 93.8%
associate-*l/89.7%
associate-*r/96.1%
Simplified96.1%
Taylor expanded in z around 0 56.9%
associate-*r/56.9%
metadata-eval56.9%
Simplified56.9%
Taylor expanded in x around inf 55.2%
if -1.55000000000000004 < x < 4Initial program 98.3%
associate-*l/99.8%
associate-*r/89.2%
Simplified89.2%
Taylor expanded in x around 0 72.8%
Final simplification63.6%
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 96.0%
associate-*l/94.6%
associate-*r/92.8%
Simplified92.8%
Taylor expanded in x around 0 37.7%
Final simplification37.7%
herbie shell --seed 2023274
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))