
(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 11 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 5e-85) (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 <= 5e-85) {
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 <= 5e-85) 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, 5e-85], 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 5 \cdot 10^{-85}:\\
\;\;\;\;\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 < 5.0000000000000002e-85Initial program 90.5%
Taylor expanded in y around 0 96.8%
if 5.0000000000000002e-85 < y Initial program 95.3%
Simplified99.9%
Final simplification97.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (- (/ (+ 4.0 x) y_m) (* z (/ x y_m))))))
(if (<= t_0 1e+69)
(fabs (/ (- (+ 4.0 x) (* x z)) y_m))
(if (<= t_0 7e+298) t_0 (fabs (/ (+ z -1.0) (/ y_m x)))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((((4.0 + x) / y_m) - (z * (x / y_m))));
double tmp;
if (t_0 <= 1e+69) {
tmp = fabs((((4.0 + x) - (x * z)) / y_m));
} else if (t_0 <= 7e+298) {
tmp = t_0;
} else {
tmp = fabs(((z + -1.0) / (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) :: t_0
real(8) :: tmp
t_0 = abs((((4.0d0 + x) / y_m) - (z * (x / y_m))))
if (t_0 <= 1d+69) then
tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
else if (t_0 <= 7d+298) then
tmp = t_0
else
tmp = abs(((z + (-1.0d0)) / (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 t_0 = Math.abs((((4.0 + x) / y_m) - (z * (x / y_m))));
double tmp;
if (t_0 <= 1e+69) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
} else if (t_0 <= 7e+298) {
tmp = t_0;
} else {
tmp = Math.abs(((z + -1.0) / (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((((4.0 + x) / y_m) - (z * (x / y_m)))) tmp = 0 if t_0 <= 1e+69: tmp = math.fabs((((4.0 + x) - (x * z)) / y_m)) elif t_0 <= 7e+298: tmp = t_0 else: tmp = math.fabs(((z + -1.0) / (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(Float64(Float64(4.0 + x) / y_m) - Float64(z * Float64(x / y_m)))) tmp = 0.0 if (t_0 <= 1e+69) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)); elseif (t_0 <= 7e+298) tmp = t_0; else tmp = abs(Float64(Float64(z + -1.0) / Float64(y_m / x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((((4.0 + x) / y_m) - (z * (x / y_m)))); tmp = 0.0; if (t_0 <= 1e+69) tmp = abs((((4.0 + x) - (x * z)) / y_m)); elseif (t_0 <= 7e+298) tmp = t_0; else tmp = abs(((z + -1.0) / (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1e+69], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 7e+298], t$95$0, N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{4 + x}{y_m} - z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;t_0 \leq 10^{+69}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\
\mathbf{elif}\;t_0 \leq 7 \cdot 10^{+298}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\
\end{array}
\end{array}
if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 1.0000000000000001e69Initial program 93.2%
Taylor expanded in y around 0 99.9%
if 1.0000000000000001e69 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 7.00000000000000018e298Initial program 99.9%
if 7.00000000000000018e298 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) Initial program 73.3%
Simplified88.9%
Taylor expanded in x around inf 100.0%
Taylor expanded in y around 0 96.2%
sub-neg96.2%
metadata-eval96.2%
*-commutative96.2%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -126000.0) (not (<= x 4.7e-16))) (fabs (* x (- (/ z y_m) (/ 1.0 y_m)))) (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -126000.0) || !(x <= 4.7e-16)) {
tmp = fabs((x * ((z / y_m) - (1.0 / y_m))));
} else {
tmp = fabs(((-4.0 - 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 <= (-126000.0d0)) .or. (.not. (x <= 4.7d-16))) then
tmp = abs((x * ((z / y_m) - (1.0d0 / y_m))))
else
tmp = abs((((-4.0d0) - 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 <= -126000.0) || !(x <= 4.7e-16)) {
tmp = Math.abs((x * ((z / y_m) - (1.0 / y_m))));
} else {
tmp = Math.abs(((-4.0 - x) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -126000.0) or not (x <= 4.7e-16): tmp = math.fabs((x * ((z / y_m) - (1.0 / y_m)))) else: tmp = math.fabs(((-4.0 - x) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -126000.0) || !(x <= 4.7e-16)) tmp = abs(Float64(x * Float64(Float64(z / y_m) - Float64(1.0 / y_m)))); else tmp = abs(Float64(Float64(-4.0 - x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -126000.0) || ~((x <= 4.7e-16))) tmp = abs((x * ((z / y_m) - (1.0 / y_m)))); else tmp = abs(((-4.0 - x) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -126000.0], N[Not[LessEqual[x, 4.7e-16]], $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[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} - \frac{1}{y_m}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\end{array}
\end{array}
if x < -126000 or 4.70000000000000044e-16 < x Initial program 90.1%
Simplified95.8%
Taylor expanded in x around inf 98.5%
if -126000 < x < 4.70000000000000044e-16Initial program 93.7%
Simplified94.4%
Taylor expanded in z around 0 76.2%
associate-*r/76.2%
distribute-lft-in76.2%
metadata-eval76.2%
neg-mul-176.2%
sub-neg76.2%
Simplified76.2%
Final simplification86.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= x -1.35e+107)
(fabs (* x (- (/ z y_m) (/ 1.0 y_m))))
(if (<= x 1.3e+86)
(fabs (/ (- (+ 4.0 x) (* x z)) y_m))
(fabs (/ (+ z -1.0) (/ y_m x))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -1.35e+107) {
tmp = fabs((x * ((z / y_m) - (1.0 / y_m))));
} else if (x <= 1.3e+86) {
tmp = fabs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = fabs(((z + -1.0) / (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 <= (-1.35d+107)) then
tmp = abs((x * ((z / y_m) - (1.0d0 / y_m))))
else if (x <= 1.3d+86) then
tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
else
tmp = abs(((z + (-1.0d0)) / (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 <= -1.35e+107) {
tmp = Math.abs((x * ((z / y_m) - (1.0 / y_m))));
} else if (x <= 1.3e+86) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = Math.abs(((z + -1.0) / (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -1.35e+107: tmp = math.fabs((x * ((z / y_m) - (1.0 / y_m)))) elif x <= 1.3e+86: tmp = math.fabs((((4.0 + x) - (x * z)) / y_m)) else: tmp = math.fabs(((z + -1.0) / (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -1.35e+107) tmp = abs(Float64(x * Float64(Float64(z / y_m) - Float64(1.0 / y_m)))); elseif (x <= 1.3e+86) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)); else tmp = abs(Float64(Float64(z + -1.0) / 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 <= -1.35e+107) tmp = abs((x * ((z / y_m) - (1.0 / y_m)))); elseif (x <= 1.3e+86) tmp = abs((((4.0 + x) - (x * z)) / y_m)); else tmp = abs(((z + -1.0) / (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -1.35e+107], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] - N[(1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.3e+86], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+107}:\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} - \frac{1}{y_m}\right)\right|\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+86}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\
\end{array}
\end{array}
if x < -1.3500000000000001e107Initial program 84.4%
Simplified95.5%
Taylor expanded in x around inf 99.7%
if -1.3500000000000001e107 < x < 1.2999999999999999e86Initial program 95.1%
Taylor expanded in y around 0 99.9%
if 1.2999999999999999e86 < x Initial program 87.1%
Simplified92.3%
Taylor expanded in x around inf 99.8%
Taylor expanded in y around 0 88.3%
sub-neg88.3%
metadata-eval88.3%
*-commutative88.3%
associate-/l*99.8%
Simplified99.8%
Final simplification99.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))))
(if (<= x -5.9e+147)
t_0
(if (<= x -4e-23)
(fabs (* x (/ z y_m)))
(if (<= x 4.0) (fabs (/ 4.0 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 <= -5.9e+147) {
tmp = t_0;
} else if (x <= -4e-23) {
tmp = fabs((x * (z / y_m)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / 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 <= (-5.9d+147)) then
tmp = t_0
else if (x <= (-4d-23)) then
tmp = abs((x * (z / y_m)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / 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 <= -5.9e+147) {
tmp = t_0;
} else if (x <= -4e-23) {
tmp = Math.abs((x * (z / y_m)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / 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 <= -5.9e+147: tmp = t_0 elif x <= -4e-23: tmp = math.fabs((x * (z / y_m))) elif x <= 4.0: tmp = math.fabs((4.0 / 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 <= -5.9e+147) tmp = t_0; elseif (x <= -4e-23) tmp = abs(Float64(x * Float64(z / y_m))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / 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 <= -5.9e+147) tmp = t_0; elseif (x <= -4e-23) tmp = abs((x * (z / y_m))); elseif (x <= 4.0) tmp = abs((4.0 / 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, -5.9e+147], t$95$0, If[LessEqual[x, -4e-23], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $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 -5.9 \cdot 10^{+147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-23}:\\
\;\;\;\;\left|x \cdot \frac{z}{y_m}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -5.9000000000000001e147 or 4 < x Initial program 87.8%
Simplified94.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in z around 0 75.2%
neg-mul-175.2%
distribute-neg-frac75.2%
Simplified75.2%
if -5.9000000000000001e147 < x < -3.99999999999999984e-23Initial program 97.1%
Simplified99.8%
Taylor expanded in x around inf 89.7%
Taylor expanded in z around inf 52.5%
associate-*r/62.7%
Simplified62.7%
if -3.99999999999999984e-23 < x < 4Initial program 94.1%
Taylor expanded in x around 0 76.2%
Final simplification74.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))))
(if (<= x -8.4e+147)
t_0
(if (<= x -3.85e-13)
(fabs (* z (/ x y_m)))
(if (<= x 4.0) (fabs (/ 4.0 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 <= -8.4e+147) {
tmp = t_0;
} else if (x <= -3.85e-13) {
tmp = fabs((z * (x / y_m)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / 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 <= (-8.4d+147)) then
tmp = t_0
else if (x <= (-3.85d-13)) then
tmp = abs((z * (x / y_m)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / 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 <= -8.4e+147) {
tmp = t_0;
} else if (x <= -3.85e-13) {
tmp = Math.abs((z * (x / y_m)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / 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 <= -8.4e+147: tmp = t_0 elif x <= -3.85e-13: tmp = math.fabs((z * (x / y_m))) elif x <= 4.0: tmp = math.fabs((4.0 / 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 <= -8.4e+147) tmp = t_0; elseif (x <= -3.85e-13) tmp = abs(Float64(z * Float64(x / y_m))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / 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 <= -8.4e+147) tmp = t_0; elseif (x <= -3.85e-13) tmp = abs((z * (x / y_m))); elseif (x <= 4.0) tmp = abs((4.0 / 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, -8.4e+147], t$95$0, If[LessEqual[x, -3.85e-13], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $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 -8.4 \cdot 10^{+147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.85 \cdot 10^{-13}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -8.40000000000000024e147 or 4 < x Initial program 87.8%
Simplified94.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in z around 0 75.2%
neg-mul-175.2%
distribute-neg-frac75.2%
Simplified75.2%
if -8.40000000000000024e147 < x < -3.8499999999999998e-13Initial program 99.8%
Simplified99.8%
Taylor expanded in x around inf 92.4%
Taylor expanded in z around inf 52.4%
associate-*l/66.9%
*-commutative66.9%
Simplified66.9%
if -3.8499999999999998e-13 < x < 4Initial program 93.6%
Taylor expanded in x around 0 75.8%
Final simplification74.7%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -270000.0) (not (<= x 2.8e-18))) (fabs (/ (+ z -1.0) (/ y_m x))) (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -270000.0) || !(x <= 2.8e-18)) {
tmp = fabs(((z + -1.0) / (y_m / x)));
} else {
tmp = fabs(((-4.0 - 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 <= (-270000.0d0)) .or. (.not. (x <= 2.8d-18))) then
tmp = abs(((z + (-1.0d0)) / (y_m / x)))
else
tmp = abs((((-4.0d0) - 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 <= -270000.0) || !(x <= 2.8e-18)) {
tmp = Math.abs(((z + -1.0) / (y_m / x)));
} else {
tmp = Math.abs(((-4.0 - x) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -270000.0) or not (x <= 2.8e-18): tmp = math.fabs(((z + -1.0) / (y_m / x))) else: tmp = math.fabs(((-4.0 - x) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -270000.0) || !(x <= 2.8e-18)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y_m / x))); else tmp = abs(Float64(Float64(-4.0 - x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -270000.0) || ~((x <= 2.8e-18))) tmp = abs(((z + -1.0) / (y_m / x))); else tmp = abs(((-4.0 - x) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -270000.0], N[Not[LessEqual[x, 2.8e-18]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -270000 \lor \neg \left(x \leq 2.8 \cdot 10^{-18}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\end{array}
\end{array}
if x < -2.7e5 or 2.80000000000000012e-18 < x Initial program 90.1%
Simplified95.8%
Taylor expanded in x around inf 98.5%
Taylor expanded in y around 0 90.4%
sub-neg90.4%
metadata-eval90.4%
*-commutative90.4%
associate-/l*98.4%
Simplified98.4%
if -2.7e5 < x < 2.80000000000000012e-18Initial program 93.7%
Simplified94.4%
Taylor expanded in z around 0 76.2%
associate-*r/76.2%
distribute-lft-in76.2%
metadata-eval76.2%
neg-mul-176.2%
sub-neg76.2%
Simplified76.2%
Final simplification86.9%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 1.6e-49) (fabs (/ (- (+ 4.0 x) (* x z)) y_m)) (fabs (- (/ (+ 4.0 x) y_m) (/ x (/ y_m z))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 1.6e-49) {
tmp = fabs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = fabs((((4.0 + x) / y_m) - (x / (y_m / z))));
}
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 (y_m <= 1.6d-49) then
tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
else
tmp = abs((((4.0d0 + x) / y_m) - (x / (y_m / z))))
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 (y_m <= 1.6e-49) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
} else {
tmp = Math.abs((((4.0 + x) / y_m) - (x / (y_m / z))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if y_m <= 1.6e-49: tmp = math.fabs((((4.0 + x) - (x * z)) / y_m)) else: tmp = math.fabs((((4.0 + x) / y_m) - (x / (y_m / z)))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 1.6e-49) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)); else tmp = abs(Float64(Float64(Float64(4.0 + x) / y_m) - Float64(x / Float64(y_m / z)))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (y_m <= 1.6e-49) tmp = abs((((4.0 + x) - (x * z)) / y_m)); else tmp = abs((((4.0 + x) / y_m) - (x / (y_m / z)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 1.6e-49], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 1.6 \cdot 10^{-49}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + x}{y_m} - \frac{x}{\frac{y_m}{z}}\right|\\
\end{array}
\end{array}
if y < 1.60000000000000001e-49Initial program 90.8%
Taylor expanded in y around 0 96.9%
if 1.60000000000000001e-49 < y Initial program 95.0%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification97.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -6e+15) (fabs (/ x (/ y_m z))) (if (<= z 1.2e+63) (fabs (/ (- -4.0 x) y_m)) (fabs (* x (/ z y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -6e+15) {
tmp = fabs((x / (y_m / z)));
} else if (z <= 1.2e+63) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs((x * (z / 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 (z <= (-6d+15)) then
tmp = abs((x / (y_m / z)))
else if (z <= 1.2d+63) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs((x * (z / 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 (z <= -6e+15) {
tmp = Math.abs((x / (y_m / z)));
} else if (z <= 1.2e+63) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs((x * (z / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -6e+15: tmp = math.fabs((x / (y_m / z))) elif z <= 1.2e+63: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs((x * (z / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -6e+15) tmp = abs(Float64(x / Float64(y_m / z))); elseif (z <= 1.2e+63) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(x * Float64(z / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -6e+15) tmp = abs((x / (y_m / z))); elseif (z <= 1.2e+63) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs((x * (z / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -6e+15], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.2e+63], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+63}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y_m}\right|\\
\end{array}
\end{array}
if z < -6e15Initial program 91.3%
Taylor expanded in z around inf 74.5%
mul-1-neg74.5%
associate-*l/72.0%
distribute-rgt-neg-out72.0%
Simplified72.0%
add-sqr-sqrt71.7%
sqrt-unprod58.3%
sqr-neg58.3%
sqrt-unprod0.0%
add-sqr-sqrt72.0%
associate-/r/74.7%
Applied egg-rr74.7%
if -6e15 < z < 1.2e63Initial program 95.9%
Simplified100.0%
Taylor expanded in z around 0 97.0%
associate-*r/97.0%
distribute-lft-in97.0%
metadata-eval97.0%
neg-mul-197.0%
sub-neg97.0%
Simplified97.0%
if 1.2e63 < z Initial program 80.3%
Simplified79.4%
Taylor expanded in x around inf 69.6%
Taylor expanded in z around inf 55.7%
associate-*r/69.6%
Simplified69.6%
Final simplification86.7%
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 90.1%
Simplified95.8%
Taylor expanded in x around inf 98.0%
Taylor expanded in z around 0 67.7%
neg-mul-167.7%
distribute-neg-frac67.7%
Simplified67.7%
if -10.5 < x < 4Initial program 93.7%
Taylor expanded in x around 0 74.9%
Final simplification71.4%
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 92.0%
Taylor expanded in x around 0 41.4%
Final simplification41.4%
herbie shell --seed 2024024
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))