
(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 8 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 1e+18) (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 <= 1e+18) {
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 <= 1d+18) 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 <= 1e+18) {
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 <= 1e+18: 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 <= 1e+18) 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 <= 1e+18) 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, 1e+18], 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 10^{+18}:\\
\;\;\;\;\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 < 1e18Initial program 90.3%
Taylor expanded in y around 0 98.1%
if 1e18 < y Initial program 92.2%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification98.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))))
(if (<= x -1.5)
t_0
(if (<= x 9.5e-61)
(fabs (/ 4.0 y_m))
(if (<= x 2.1e+42) (fabs (* z (/ x 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 <= -1.5) {
tmp = t_0;
} else if (x <= 9.5e-61) {
tmp = fabs((4.0 / y_m));
} else if (x <= 2.1e+42) {
tmp = fabs((z * (x / 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 <= (-1.5d0)) then
tmp = t_0
else if (x <= 9.5d-61) then
tmp = abs((4.0d0 / y_m))
else if (x <= 2.1d+42) then
tmp = abs((z * (x / 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 <= -1.5) {
tmp = t_0;
} else if (x <= 9.5e-61) {
tmp = Math.abs((4.0 / y_m));
} else if (x <= 2.1e+42) {
tmp = Math.abs((z * (x / 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 <= -1.5: tmp = t_0 elif x <= 9.5e-61: tmp = math.fabs((4.0 / y_m)) elif x <= 2.1e+42: tmp = math.fabs((z * (x / 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 <= -1.5) tmp = t_0; elseif (x <= 9.5e-61) tmp = abs(Float64(4.0 / y_m)); elseif (x <= 2.1e+42) tmp = abs(Float64(z * Float64(x / 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 <= -1.5) tmp = t_0; elseif (x <= 9.5e-61) tmp = abs((4.0 / y_m)); elseif (x <= 2.1e+42) tmp = abs((z * (x / 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, -1.5], t$95$0, If[LessEqual[x, 9.5e-61], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.1e+42], N[Abs[N[(z * N[(x / 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 -1.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-61}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+42}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.5 or 2.09999999999999995e42 < x Initial program 86.9%
Simplified93.8%
Taylor expanded in x around inf 98.7%
Taylor expanded in z around 0 72.9%
neg-mul-172.9%
distribute-neg-frac72.9%
Simplified72.9%
if -1.5 < x < 9.49999999999999986e-61Initial program 92.7%
Taylor expanded in x around 0 75.6%
if 9.49999999999999986e-61 < x < 2.09999999999999995e42Initial program 99.9%
Simplified96.2%
Taylor expanded in x around inf 71.4%
Taylor expanded in z around inf 60.9%
associate-*l/64.8%
*-commutative64.8%
Simplified64.8%
Final simplification73.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))))
(if (<= x -1.5)
t_0
(if (<= x 2.3e-38)
(fabs (/ 4.0 y_m))
(if (<= x 6.8e+40) (fabs (/ x (/ y_m z))) 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 <= -1.5) {
tmp = t_0;
} else if (x <= 2.3e-38) {
tmp = fabs((4.0 / y_m));
} else if (x <= 6.8e+40) {
tmp = fabs((x / (y_m / z)));
} 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 <= (-1.5d0)) then
tmp = t_0
else if (x <= 2.3d-38) then
tmp = abs((4.0d0 / y_m))
else if (x <= 6.8d+40) then
tmp = abs((x / (y_m / z)))
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 <= -1.5) {
tmp = t_0;
} else if (x <= 2.3e-38) {
tmp = Math.abs((4.0 / y_m));
} else if (x <= 6.8e+40) {
tmp = Math.abs((x / (y_m / z)));
} 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 <= -1.5: tmp = t_0 elif x <= 2.3e-38: tmp = math.fabs((4.0 / y_m)) elif x <= 6.8e+40: tmp = math.fabs((x / (y_m / z))) 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 <= -1.5) tmp = t_0; elseif (x <= 2.3e-38) tmp = abs(Float64(4.0 / y_m)); elseif (x <= 6.8e+40) tmp = abs(Float64(x / Float64(y_m / z))); 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 <= -1.5) tmp = t_0; elseif (x <= 2.3e-38) tmp = abs((4.0 / y_m)); elseif (x <= 6.8e+40) tmp = abs((x / (y_m / z))); 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, -1.5], t$95$0, If[LessEqual[x, 2.3e-38], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 6.8e+40], N[Abs[N[(x / N[(y$95$m / z), $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 -1.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-38}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+40}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.5 or 6.79999999999999977e40 < x Initial program 86.9%
Simplified93.8%
Taylor expanded in x around inf 98.7%
Taylor expanded in z around 0 72.9%
neg-mul-172.9%
distribute-neg-frac72.9%
Simplified72.9%
if -1.5 < x < 2.30000000000000002e-38Initial program 93.0%
Taylor expanded in x around 0 74.5%
if 2.30000000000000002e-38 < x < 6.79999999999999977e40Initial program 99.8%
Taylor expanded in z around inf 63.5%
mul-1-neg63.5%
associate-*l/68.7%
distribute-rgt-neg-out68.7%
Simplified68.7%
add-sqr-sqrt33.9%
sqrt-unprod53.3%
sqr-neg53.3%
sqrt-unprod34.6%
add-sqr-sqrt68.7%
associate-*l/63.5%
associate-/l*68.9%
Applied egg-rr68.9%
Final simplification73.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= z -4.5e+26)
(fabs (/ x (/ y_m z)))
(if (<= z 3.3e+69)
(fabs (/ (- -4.0 x) y_m))
(fabs (/ (* x (+ z -1.0)) y_m)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -4.5e+26) {
tmp = fabs((x / (y_m / z)));
} else if (z <= 3.3e+69) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs(((x * (z + -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 (z <= (-4.5d+26)) then
tmp = abs((x / (y_m / z)))
else if (z <= 3.3d+69) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs(((x * (z + (-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 (z <= -4.5e+26) {
tmp = Math.abs((x / (y_m / z)));
} else if (z <= 3.3e+69) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs(((x * (z + -1.0)) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -4.5e+26: tmp = math.fabs((x / (y_m / z))) elif z <= 3.3e+69: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs(((x * (z + -1.0)) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -4.5e+26) tmp = abs(Float64(x / Float64(y_m / z))); elseif (z <= 3.3e+69) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(Float64(x * Float64(z + -1.0)) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -4.5e+26) tmp = abs((x / (y_m / z))); elseif (z <= 3.3e+69) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs(((x * (z + -1.0)) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -4.5e+26], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.3e+69], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+26}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot \left(z + -1\right)}{y_m}\right|\\
\end{array}
\end{array}
if z < -4.49999999999999978e26Initial program 93.5%
Taylor expanded in z around inf 68.5%
mul-1-neg68.5%
associate-*l/75.3%
distribute-rgt-neg-out75.3%
Simplified75.3%
add-sqr-sqrt75.1%
sqrt-unprod59.8%
sqr-neg59.8%
sqrt-unprod0.0%
add-sqr-sqrt75.3%
associate-*l/68.5%
associate-/l*79.3%
Applied egg-rr79.3%
if -4.49999999999999978e26 < z < 3.2999999999999999e69Initial program 94.2%
Simplified99.3%
Taylor expanded in z around 0 96.7%
associate-*r/96.7%
distribute-lft-in96.7%
metadata-eval96.7%
neg-mul-196.7%
sub-neg96.7%
Simplified96.7%
if 3.2999999999999999e69 < z Initial program 77.6%
Simplified73.7%
Taylor expanded in x around inf 71.6%
*-commutative71.6%
sub-div71.6%
associate-*l/80.5%
sub-neg80.5%
metadata-eval80.5%
Applied egg-rr80.5%
Final simplification90.0%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -9.2e+32) (fabs (/ x (/ y_m z))) (if (<= z 8.5e+69) (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 <= -9.2e+32) {
tmp = fabs((x / (y_m / z)));
} else if (z <= 8.5e+69) {
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 <= (-9.2d+32)) then
tmp = abs((x / (y_m / z)))
else if (z <= 8.5d+69) 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 <= -9.2e+32) {
tmp = Math.abs((x / (y_m / z)));
} else if (z <= 8.5e+69) {
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 <= -9.2e+32: tmp = math.fabs((x / (y_m / z))) elif z <= 8.5e+69: 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 <= -9.2e+32) tmp = abs(Float64(x / Float64(y_m / z))); elseif (z <= 8.5e+69) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(Float64(x * z) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -9.2e+32) tmp = abs((x / (y_m / z))); elseif (z <= 8.5e+69) 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, -9.2e+32], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 8.5e+69], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{+32}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\
\end{array}
\end{array}
if z < -9.1999999999999998e32Initial program 93.5%
Taylor expanded in z around inf 68.5%
mul-1-neg68.5%
associate-*l/75.3%
distribute-rgt-neg-out75.3%
Simplified75.3%
add-sqr-sqrt75.1%
sqrt-unprod59.8%
sqr-neg59.8%
sqrt-unprod0.0%
add-sqr-sqrt75.3%
associate-*l/68.5%
associate-/l*79.3%
Applied egg-rr79.3%
if -9.1999999999999998e32 < z < 8.5000000000000002e69Initial program 94.2%
Simplified99.3%
Taylor expanded in z around 0 96.7%
associate-*r/96.7%
distribute-lft-in96.7%
metadata-eval96.7%
neg-mul-196.7%
sub-neg96.7%
Simplified96.7%
if 8.5000000000000002e69 < z Initial program 77.6%
Simplified73.7%
Taylor expanded in x around inf 71.6%
Taylor expanded in z around inf 80.5%
Final simplification90.0%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -1.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 <= -1.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 <= (-1.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 <= -1.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 <= -1.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 <= -1.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 <= -1.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, -1.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 -1.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 < -1.5 or 4 < x Initial program 88.0%
Simplified94.3%
Taylor expanded in x around inf 98.4%
Taylor expanded in z around 0 69.3%
neg-mul-169.3%
distribute-neg-frac69.3%
Simplified69.3%
if -1.5 < x < 4Initial program 93.4%
Taylor expanded in x around 0 71.7%
Final simplification70.5%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ (- (+ 4.0 x) (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((((4.0 + x) - (x * z)) / 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 + x) - (x * z)) / 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 + x) - (x * z)) / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs((((4.0 + x) - (x * z)) / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs((((4.0 + x) - (x * z)) / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|
\end{array}
Initial program 90.7%
Taylor expanded in y around 0 97.4%
Final simplification97.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 90.7%
Taylor expanded in x around 0 39.0%
Final simplification39.0%
herbie shell --seed 2024018
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))