
(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}
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 5e-36) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-36) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
}
return tmp;
}
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 5e-36) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 5e-36], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-36}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 5.00000000000000004e-36Initial program 91.9%
associate-*l/91.4%
sub-div98.4%
Applied egg-rr98.4%
if 5.00000000000000004e-36 < y Initial program 95.3%
fabs-sub95.3%
associate-*l/94.4%
*-commutative94.4%
associate-*l/99.8%
*-commutative99.8%
fma-neg99.8%
distribute-neg-frac99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification98.8%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ (- -4.0 x) y))))
(if (<= z -1.1e+167)
t_0
(if (<= z 105000000000.0)
t_1
(if (<= z 5.4e+69) t_0 (if (<= z 1e+122) t_1 (fabs (* x (/ z y)))))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs(((-4.0 - x) / y));
double tmp;
if (z <= -1.1e+167) {
tmp = t_0;
} else if (z <= 105000000000.0) {
tmp = t_1;
} else if (z <= 5.4e+69) {
tmp = t_0;
} else if (z <= 1e+122) {
tmp = t_1;
} else {
tmp = fabs((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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((z * (x / y)))
t_1 = abs((((-4.0d0) - x) / y))
if (z <= (-1.1d+167)) then
tmp = t_0
else if (z <= 105000000000.0d0) then
tmp = t_1
else if (z <= 5.4d+69) then
tmp = t_0
else if (z <= 1d+122) then
tmp = t_1
else
tmp = abs((x * (z / 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((z * (x / y)));
double t_1 = Math.abs(((-4.0 - x) / y));
double tmp;
if (z <= -1.1e+167) {
tmp = t_0;
} else if (z <= 105000000000.0) {
tmp = t_1;
} else if (z <= 5.4e+69) {
tmp = t_0;
} else if (z <= 1e+122) {
tmp = t_1;
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs(((-4.0 - x) / y)) tmp = 0 if z <= -1.1e+167: tmp = t_0 elif z <= 105000000000.0: tmp = t_1 elif z <= 5.4e+69: tmp = t_0 elif z <= 1e+122: tmp = t_1 else: tmp = math.fabs((x * (z / y))) return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(Float64(-4.0 - x) / y)) tmp = 0.0 if (z <= -1.1e+167) tmp = t_0; elseif (z <= 105000000000.0) tmp = t_1; elseif (z <= 5.4e+69) tmp = t_0; elseif (z <= 1e+122) tmp = t_1; else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); t_1 = abs(((-4.0 - x) / y)); tmp = 0.0; if (z <= -1.1e+167) tmp = t_0; elseif (z <= 105000000000.0) tmp = t_1; elseif (z <= 5.4e+69) tmp = t_0; elseif (z <= 1e+122) tmp = t_1; else tmp = abs((x * (z / 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -1.1e+167], t$95$0, If[LessEqual[z, 105000000000.0], t$95$1, If[LessEqual[z, 5.4e+69], t$95$0, If[LessEqual[z, 1e+122], t$95$1, N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{-4 - x}{y}\right|\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 105000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 10^{+122}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -1.10000000000000002e167 or 1.05e11 < z < 5.3999999999999996e69Initial program 95.9%
Simplified90.6%
Taylor expanded in z around inf 76.5%
add-sqr-sqrt46.1%
sqrt-unprod66.9%
sqr-neg66.9%
sqrt-unprod30.1%
add-sqr-sqrt76.5%
*-commutative76.5%
associate-*l/84.0%
clear-num83.0%
clear-num84.0%
add-sqr-sqrt32.3%
sqrt-unprod69.3%
sqr-neg69.3%
sqrt-unprod51.6%
add-sqr-sqrt84.0%
Applied egg-rr84.0%
if -1.10000000000000002e167 < z < 1.05e11 or 5.3999999999999996e69 < z < 1.00000000000000001e122Initial program 96.0%
Simplified98.7%
Taylor expanded in z around 0 89.0%
associate-*r/89.0%
distribute-lft-in89.0%
metadata-eval89.0%
neg-mul-189.0%
sub-neg89.0%
Simplified89.0%
if 1.00000000000000001e122 < z Initial program 74.2%
Simplified97.2%
Taylor expanded in z around inf 79.1%
associate-*l/81.5%
*-commutative81.5%
Simplified81.5%
Final simplification87.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -4.2e+67) (fabs (- (* z (/ x y)) (/ (+ x 4.0) y))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+67) {
tmp = fabs(((z * (x / y)) - ((x + 4.0) / y)));
} else {
tmp = fabs((((x + 4.0) - (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 (z <= (-4.2d+67)) then
tmp = abs(((z * (x / y)) - ((x + 4.0d0) / y)))
else
tmp = abs((((x + 4.0d0) - (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 (z <= -4.2e+67) {
tmp = Math.abs(((z * (x / y)) - ((x + 4.0) / y)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -4.2e+67: tmp = math.fabs(((z * (x / y)) - ((x + 4.0) / y))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -4.2e+67) tmp = abs(Float64(Float64(z * Float64(x / y)) - Float64(Float64(x + 4.0) / y))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.2e+67) tmp = abs(((z * (x / y)) - ((x + 4.0) / y))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -4.2e+67], N[Abs[N[(N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+67}:\\
\;\;\;\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if z < -4.2000000000000003e67Initial program 98.8%
if -4.2000000000000003e67 < z Initial program 91.2%
associate-*l/92.5%
sub-div99.0%
Applied egg-rr99.0%
Final simplification98.9%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -2.6e+15) (not (<= x 5.9e-22))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- -4.0 x) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.6e+15) || !(x <= 5.9e-22)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs(((-4.0 - 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) :: tmp
if ((x <= (-2.6d+15)) .or. (.not. (x <= 5.9d-22))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs((((-4.0d0) - x) / 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 <= -2.6e+15) || !(x <= 5.9e-22)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -2.6e+15) or not (x <= 5.9e-22): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -2.6e+15) || !(x <= 5.9e-22)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(-4.0 - x) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.6e+15) || ~((x <= 5.9e-22))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -2.6e+15], N[Not[LessEqual[x, 5.9e-22]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+15} \lor \neg \left(x \leq 5.9 \cdot 10^{-22}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if x < -2.6e15 or 5.90000000000000008e-22 < x Initial program 88.5%
Simplified94.3%
Taylor expanded in x around inf 92.3%
associate-/l*97.5%
sub-neg97.5%
metadata-eval97.5%
Simplified97.5%
if -2.6e15 < x < 5.90000000000000008e-22Initial program 96.8%
Simplified99.8%
Taylor expanded in z around 0 77.4%
associate-*r/77.4%
distribute-lft-in77.4%
metadata-eval77.4%
neg-mul-177.4%
sub-neg77.4%
Simplified77.4%
Final simplification87.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (fabs (/ (- (+ x 4.0) (* x z)) y)))
y = abs(y);
double code(double x, double y, double z) {
return fabs((((x + 4.0) - (x * z)) / 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((((x + 4.0d0) - (x * z)) / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) - (x * z)) / y));
}
y = abs(y) def code(x, y, z): return math.fabs((((x + 4.0) - (x * z)) / y))
y = abs(y) function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)) end
y = abs(y) function tmp = code(x, y, z) tmp = abs((((x + 4.0) - (x * z)) / y)); end
NOTE: y should be positive before calling this function code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|
\end{array}
Initial program 92.8%
associate-*l/92.2%
sub-div97.3%
Applied egg-rr97.3%
Final simplification97.3%
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 88.7%
Simplified94.4%
Taylor expanded in x around inf 91.5%
associate-/l*96.6%
sub-neg96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in z around 0 65.3%
associate-*r/65.3%
neg-mul-165.3%
Simplified65.3%
if -1.55000000000000004 < x < 4Initial program 96.8%
Taylor expanded in x around 0 74.0%
Final simplification69.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -2.6e+15) (fabs (* z (/ x y))) (if (<= x 4.0) (fabs (/ 4.0 y)) (fabs (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= -2.6e+15) {
tmp = fabs((z * (x / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = fabs((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) :: tmp
if (x <= (-2.6d+15)) then
tmp = abs((z * (x / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = abs((x / 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 <= -2.6e+15) {
tmp = Math.abs((z * (x / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= -2.6e+15: tmp = math.fabs((z * (x / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = math.fabs((x / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= -2.6e+15) tmp = abs(Float64(z * Float64(x / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = abs(Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.6e+15) tmp = abs((z * (x / y))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = abs((x / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, -2.6e+15], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+15}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -2.6e15Initial program 90.5%
Simplified93.8%
Taylor expanded in z around inf 55.3%
add-sqr-sqrt29.2%
sqrt-unprod54.9%
sqr-neg54.9%
sqrt-unprod25.9%
add-sqr-sqrt55.3%
*-commutative55.3%
associate-*l/70.0%
clear-num70.0%
clear-num70.0%
add-sqr-sqrt31.8%
sqrt-unprod59.4%
sqr-neg59.4%
sqrt-unprod38.0%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
if -2.6e15 < x < 4Initial program 96.9%
Taylor expanded in x around 0 70.9%
if 4 < x Initial program 85.0%
Simplified94.5%
Taylor expanded in x around inf 93.0%
associate-/l*98.0%
sub-neg98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in z around 0 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Final simplification69.8%
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 92.8%
Taylor expanded in x around 0 40.7%
Final simplification40.7%
herbie shell --seed 2023229
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))