
(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 10 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}
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 4e+52) (fabs (/ (- (+ 4.0 x) (* x z)) y_m)) (fabs (fma x (/ z y_m) (/ (- -4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 4e+52) {
tmp = fabs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = fabs(fma(x, (z / y_m), ((-4.0 - x) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 4e+52) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)); else tmp = abs(fma(x, Float64(z / y_m), Float64(Float64(-4.0 - x) / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 4e+52], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 4 \cdot 10^{+52}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y_m}, \frac{-4 - x}{y_m}\right)\right|\\
\end{array}
\end{array}
if y < 4e52Initial program 90.9%
Taylor expanded in y around 0 98.2%
if 4e52 < y Initial program 91.3%
Simplified99.8%
Final simplification98.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))))
(if (<= x -10.5)
t_0
(if (<= x 3.3e-22)
(fabs (/ 4.0 y_m))
(if (or (<= x 1.28e+180) (not (<= x 1.25e+227)))
(fabs (* x (/ z y_m)))
t_0)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((x / y_m));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 3.3e-22) {
tmp = fabs((4.0 / y_m));
} else if ((x <= 1.28e+180) || !(x <= 1.25e+227)) {
tmp = fabs((x * (z / y_m)));
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y_m))
if (x <= (-10.5d0)) then
tmp = t_0
else if (x <= 3.3d-22) then
tmp = abs((4.0d0 / y_m))
else if ((x <= 1.28d+180) .or. (.not. (x <= 1.25d+227))) then
tmp = abs((x * (z / y_m)))
else
tmp = t_0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((x / y_m));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 3.3e-22) {
tmp = Math.abs((4.0 / y_m));
} else if ((x <= 1.28e+180) || !(x <= 1.25e+227)) {
tmp = Math.abs((x * (z / y_m)));
} else {
tmp = t_0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((x / y_m)) tmp = 0 if x <= -10.5: tmp = t_0 elif x <= 3.3e-22: tmp = math.fabs((4.0 / y_m)) elif (x <= 1.28e+180) or not (x <= 1.25e+227): tmp = math.fabs((x * (z / y_m))) else: tmp = t_0 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(x / y_m)) tmp = 0.0 if (x <= -10.5) tmp = t_0; elseif (x <= 3.3e-22) tmp = abs(Float64(4.0 / y_m)); elseif ((x <= 1.28e+180) || !(x <= 1.25e+227)) tmp = abs(Float64(x * Float64(z / y_m))); else tmp = t_0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((x / y_m)); tmp = 0.0; if (x <= -10.5) tmp = t_0; elseif (x <= 3.3e-22) tmp = abs((4.0 / y_m)); elseif ((x <= 1.28e+180) || ~((x <= 1.25e+227))) tmp = abs((x * (z / y_m))); else tmp = t_0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -10.5], t$95$0, If[LessEqual[x, 3.3e-22], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.28e+180], N[Not[LessEqual[x, 1.25e+227]], $MachinePrecision]], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-22}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 1.28 \cdot 10^{+180} \lor \neg \left(x \leq 1.25 \cdot 10^{+227}\right):\\
\;\;\;\;\left|x \cdot \frac{z}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -10.5 or 1.2800000000000001e180 < x < 1.2499999999999999e227Initial program 79.9%
associate-*l/84.2%
sub-div96.2%
clear-num96.1%
associate--l+96.1%
Applied egg-rr96.1%
Taylor expanded in z around 0 75.7%
Taylor expanded in x around inf 75.8%
if -10.5 < x < 3.3000000000000001e-22Initial program 95.6%
Taylor expanded in x around 0 82.7%
if 3.3000000000000001e-22 < x < 1.2800000000000001e180 or 1.2499999999999999e227 < x Initial program 95.5%
Simplified99.8%
Taylor expanded in x around inf 97.9%
Taylor expanded in z around inf 59.0%
associate-*r/71.2%
Simplified71.2%
Final simplification78.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -0.07) (not (<= x 1.6e-23))) (fabs (* x (+ (/ z y_m) (/ -1.0 y_m)))) (fabs (/ 1.0 (/ y_m (+ 4.0 x))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -0.07) || !(x <= 1.6e-23)) {
tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = fabs((1.0 / (y_m / (4.0 + x))));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-0.07d0)) .or. (.not. (x <= 1.6d-23))) then
tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
else
tmp = abs((1.0d0 / (y_m / (4.0d0 + x))))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -0.07) || !(x <= 1.6e-23)) {
tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = Math.abs((1.0 / (y_m / (4.0 + x))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -0.07) or not (x <= 1.6e-23): tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m)))) else: tmp = math.fabs((1.0 / (y_m / (4.0 + x)))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -0.07) || !(x <= 1.6e-23)) tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m)))); else tmp = abs(Float64(1.0 / Float64(y_m / Float64(4.0 + x)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -0.07) || ~((x <= 1.6e-23))) tmp = abs((x * ((z / y_m) + (-1.0 / y_m)))); else tmp = abs((1.0 / (y_m / (4.0 + x)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -0.07], N[Not[LessEqual[x, 1.6e-23]], $MachinePrecision]], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(1.0 / N[(y$95$m / N[(4.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.07 \lor \neg \left(x \leq 1.6 \cdot 10^{-23}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{1}{\frac{y_m}{4 + x}}\right|\\
\end{array}
\end{array}
if x < -0.070000000000000007 or 1.59999999999999988e-23 < x Initial program 86.0%
Simplified95.0%
Taylor expanded in x around inf 99.0%
if -0.070000000000000007 < x < 1.59999999999999988e-23Initial program 95.6%
associate-*l/99.9%
sub-div99.9%
clear-num99.9%
associate--l+99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 84.4%
Final simplification91.3%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -0.62) (not (<= x 1.1e-22))) (fabs (/ (* x (+ z -1.0)) y_m)) (fabs (/ 1.0 (/ y_m (+ 4.0 x))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -0.62) || !(x <= 1.1e-22)) {
tmp = fabs(((x * (z + -1.0)) / y_m));
} else {
tmp = fabs((1.0 / (y_m / (4.0 + x))));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-0.62d0)) .or. (.not. (x <= 1.1d-22))) then
tmp = abs(((x * (z + (-1.0d0))) / y_m))
else
tmp = abs((1.0d0 / (y_m / (4.0d0 + x))))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -0.62) || !(x <= 1.1e-22)) {
tmp = Math.abs(((x * (z + -1.0)) / y_m));
} else {
tmp = Math.abs((1.0 / (y_m / (4.0 + x))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -0.62) or not (x <= 1.1e-22): tmp = math.fabs(((x * (z + -1.0)) / y_m)) else: tmp = math.fabs((1.0 / (y_m / (4.0 + x)))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -0.62) || !(x <= 1.1e-22)) tmp = abs(Float64(Float64(x * Float64(z + -1.0)) / y_m)); else tmp = abs(Float64(1.0 / Float64(y_m / Float64(4.0 + x)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -0.62) || ~((x <= 1.1e-22))) tmp = abs(((x * (z + -1.0)) / y_m)); else tmp = abs((1.0 / (y_m / (4.0 + x)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -0.62], N[Not[LessEqual[x, 1.1e-22]], $MachinePrecision]], N[Abs[N[(N[(x * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(1.0 / N[(y$95$m / N[(4.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.62 \lor \neg \left(x \leq 1.1 \cdot 10^{-22}\right):\\
\;\;\;\;\left|\frac{x \cdot \left(z + -1\right)}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{1}{\frac{y_m}{4 + x}}\right|\\
\end{array}
\end{array}
if x < -0.619999999999999996 or 1.1e-22 < x Initial program 86.0%
Simplified95.0%
Taylor expanded in x around inf 99.0%
*-commutative99.0%
sub-div99.0%
associate-*l/92.3%
sub-neg92.3%
metadata-eval92.3%
Applied egg-rr92.3%
if -0.619999999999999996 < x < 1.1e-22Initial program 95.6%
associate-*l/99.9%
sub-div99.9%
clear-num99.9%
associate--l+99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 84.4%
Final simplification88.2%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= x -1.3)
(fabs (/ (* x (+ z -1.0)) y_m))
(if (<= x 1.9e-22)
(fabs (/ 1.0 (/ y_m (+ 4.0 x))))
(fabs (/ (- (* x z) x) y_m)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -1.3) {
tmp = fabs(((x * (z + -1.0)) / y_m));
} else if (x <= 1.9e-22) {
tmp = fabs((1.0 / (y_m / (4.0 + x))));
} else {
tmp = fabs((((x * z) - x) / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.3d0)) then
tmp = abs(((x * (z + (-1.0d0))) / y_m))
else if (x <= 1.9d-22) then
tmp = abs((1.0d0 / (y_m / (4.0d0 + x))))
else
tmp = abs((((x * z) - x) / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (x <= -1.3) {
tmp = Math.abs(((x * (z + -1.0)) / y_m));
} else if (x <= 1.9e-22) {
tmp = Math.abs((1.0 / (y_m / (4.0 + x))));
} else {
tmp = Math.abs((((x * z) - x) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -1.3: tmp = math.fabs(((x * (z + -1.0)) / y_m)) elif x <= 1.9e-22: tmp = math.fabs((1.0 / (y_m / (4.0 + x)))) else: tmp = math.fabs((((x * z) - x) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -1.3) tmp = abs(Float64(Float64(x * Float64(z + -1.0)) / y_m)); elseif (x <= 1.9e-22) tmp = abs(Float64(1.0 / Float64(y_m / Float64(4.0 + x)))); else tmp = abs(Float64(Float64(Float64(x * z) - x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= -1.3) tmp = abs(((x * (z + -1.0)) / y_m)); elseif (x <= 1.9e-22) tmp = abs((1.0 / (y_m / (4.0 + x)))); else tmp = abs((((x * z) - x) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -1.3], N[Abs[N[(N[(x * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.9e-22], N[Abs[N[(1.0 / N[(y$95$m / N[(4.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\left|\frac{x \cdot \left(z + -1\right)}{y_m}\right|\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-22}:\\
\;\;\;\;\left|\frac{1}{\frac{y_m}{4 + x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot z - x}{y_m}\right|\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 81.2%
Simplified95.2%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
sub-div99.7%
associate-*l/95.6%
sub-neg95.6%
metadata-eval95.6%
Applied egg-rr95.6%
if -1.30000000000000004 < x < 1.90000000000000012e-22Initial program 95.6%
associate-*l/99.9%
sub-div99.9%
clear-num99.9%
associate--l+99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 84.4%
if 1.90000000000000012e-22 < x Initial program 91.2%
Simplified94.7%
Taylor expanded in x around inf 98.2%
*-commutative98.2%
sub-div98.2%
associate-*l/88.7%
sub-neg88.7%
metadata-eval88.7%
Applied egg-rr88.7%
*-commutative88.7%
distribute-rgt-in88.7%
neg-mul-188.7%
Applied egg-rr88.7%
unsub-neg88.7%
Applied egg-rr88.7%
Final simplification88.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= x -10.5) (fabs (/ x y_m)) (if (<= x 5.5e-23) (fabs (/ 4.0 y_m)) (fabs (/ z (/ y_m x))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -10.5) {
tmp = fabs((x / y_m));
} else if (x <= 5.5e-23) {
tmp = fabs((4.0 / y_m));
} else {
tmp = fabs((z / (y_m / x)));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-10.5d0)) then
tmp = abs((x / y_m))
else if (x <= 5.5d-23) then
tmp = abs((4.0d0 / y_m))
else
tmp = abs((z / (y_m / x)))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (x <= -10.5) {
tmp = Math.abs((x / y_m));
} else if (x <= 5.5e-23) {
tmp = Math.abs((4.0 / y_m));
} else {
tmp = Math.abs((z / (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -10.5: tmp = math.fabs((x / y_m)) elif x <= 5.5e-23: tmp = math.fabs((4.0 / y_m)) else: tmp = math.fabs((z / (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -10.5) tmp = abs(Float64(x / y_m)); elseif (x <= 5.5e-23) tmp = abs(Float64(4.0 / y_m)); else tmp = abs(Float64(z / Float64(y_m / x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= -10.5) tmp = abs((x / y_m)); elseif (x <= 5.5e-23) tmp = abs((4.0 / y_m)); else tmp = abs((z / (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -10.5], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.5e-23], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-23}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\
\end{array}
\end{array}
if x < -10.5Initial program 80.9%
associate-*l/85.9%
sub-div95.5%
clear-num95.4%
associate--l+95.4%
Applied egg-rr95.4%
Taylor expanded in z around 0 72.6%
Taylor expanded in x around inf 72.6%
if -10.5 < x < 5.5000000000000001e-23Initial program 95.6%
Taylor expanded in x around 0 82.7%
if 5.5000000000000001e-23 < x Initial program 91.2%
Taylor expanded in z around inf 57.7%
mul-1-neg57.7%
associate-*l/75.4%
distribute-rgt-neg-out75.4%
Simplified75.4%
add-sqr-sqrt50.8%
sqrt-unprod63.7%
sqr-neg63.7%
sqrt-unprod24.6%
add-sqr-sqrt75.4%
associate-*l/57.7%
*-commutative57.7%
associate-/l*75.5%
Applied egg-rr75.5%
Final simplification78.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -1.15e+69) (fabs (/ x (/ y_m z))) (if (<= z 6.6e+143) (fabs (/ (- -4.0 x) y_m)) (fabs (/ z (/ y_m x))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.15e+69) {
tmp = fabs((x / (y_m / z)));
} else if (z <= 6.6e+143) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs((z / (y_m / x)));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.15d+69)) then
tmp = abs((x / (y_m / z)))
else if (z <= 6.6d+143) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs((z / (y_m / x)))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.15e+69) {
tmp = Math.abs((x / (y_m / z)));
} else if (z <= 6.6e+143) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs((z / (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.15e+69: tmp = math.fabs((x / (y_m / z))) elif z <= 6.6e+143: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs((z / (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.15e+69) tmp = abs(Float64(x / Float64(y_m / z))); elseif (z <= 6.6e+143) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(z / Float64(y_m / x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.15e+69) tmp = abs((x / (y_m / z))); elseif (z <= 6.6e+143) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs((z / (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.15e+69], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 6.6e+143], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{+143}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\
\end{array}
\end{array}
if z < -1.15000000000000008e69Initial program 92.0%
Taylor expanded in z around inf 70.7%
mul-1-neg70.7%
associate-*l/71.9%
distribute-rgt-neg-out71.9%
Simplified71.9%
add-sqr-sqrt71.7%
sqrt-unprod49.5%
sqr-neg49.5%
sqrt-unprod0.0%
add-sqr-sqrt71.9%
associate-*l/70.7%
associate-/l*78.0%
Applied egg-rr78.0%
if -1.15000000000000008e69 < z < 6.6e143Initial program 92.3%
Simplified96.3%
Taylor expanded in z around 0 90.6%
associate-*r/90.6%
distribute-lft-in90.6%
metadata-eval90.6%
neg-mul-190.6%
sub-neg90.6%
Simplified90.6%
if 6.6e143 < z Initial program 79.2%
Taylor expanded in z around inf 76.6%
mul-1-neg76.6%
associate-*l/84.4%
distribute-rgt-neg-out84.4%
Simplified84.4%
add-sqr-sqrt0.0%
sqrt-unprod52.2%
sqr-neg52.2%
sqrt-unprod84.1%
add-sqr-sqrt84.4%
associate-*l/76.6%
*-commutative76.6%
associate-/l*84.6%
Applied egg-rr84.6%
Final simplification87.5%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= x 3.5e+104) (fabs (/ (- (+ 4.0 x) (* x z)) y_m)) (fabs (* x (+ (/ z y_m) (/ -1.0 y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= 3.5e+104) {
tmp = fabs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 3.5d+104) then
tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
else
tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (x <= 3.5e+104) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= 3.5e+104: tmp = math.fabs((((4.0 + x) - (x * z)) / y_m)) else: tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m)))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= 3.5e+104) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)); else tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= 3.5e+104) tmp = abs((((4.0 + x) - (x * z)) / y_m)); else tmp = abs((x * ((z / y_m) + (-1.0 / y_m)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, 3.5e+104], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+104}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\right|\\
\end{array}
\end{array}
if x < 3.5000000000000002e104Initial program 91.6%
Taylor expanded in y around 0 98.6%
if 3.5000000000000002e104 < x Initial program 87.4%
Simplified92.3%
Taylor expanded in x around inf 99.7%
Final simplification98.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y_m)) (fabs (/ 4.0 y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = fabs((x / y_m));
} else {
tmp = fabs((4.0 / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y_m))
else
tmp = abs((4.0d0 / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = Math.abs((x / y_m));
} else {
tmp = Math.abs((4.0 / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -10.5) or not (x <= 4.0): tmp = math.fabs((x / y_m)) else: tmp = math.fabs((4.0 / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -10.5) || !(x <= 4.0)) tmp = abs(Float64(x / y_m)); else tmp = abs(Float64(4.0 / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -10.5) || ~((x <= 4.0))) tmp = abs((x / y_m)); else tmp = abs((4.0 / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\end{array}
\end{array}
if x < -10.5 or 4 < x Initial program 85.4%
associate-*l/83.3%
sub-div92.8%
clear-num92.7%
associate--l+92.7%
Applied egg-rr92.7%
Taylor expanded in z around 0 65.5%
Taylor expanded in x around inf 65.6%
if -10.5 < x < 4Initial program 95.7%
Taylor expanded in x around 0 80.8%
Final simplification73.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ 4.0 y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((4.0 / y_m));
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = abs((4.0d0 / y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
return Math.abs((4.0 / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs((4.0 / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(4.0 / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs((4.0 / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{4}{y_m}\right|
\end{array}
Initial program 91.0%
Taylor expanded in x around 0 46.6%
Final simplification46.6%
herbie shell --seed 2024021
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))