
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 5e-85) (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-85) {
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-85) 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-85], 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^{-85}:\\
\;\;\;\;\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.0000000000000002e-85Initial program 90.5%
associate-*l/90.6%
sub-div96.8%
Applied egg-rr96.8%
if 5.0000000000000002e-85 < y Initial program 95.3%
Simplified99.9%
Final simplification97.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1.3e+107) (not (<= x 3.4e+66))) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.3e+107) || !(x <= 3.4e+66)) {
tmp = fabs(((x / y) * (1.0 - z)));
} 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 ((x <= (-1.3d+107)) .or. (.not. (x <= 3.4d+66))) then
tmp = abs(((x / y) * (1.0d0 - z)))
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 ((x <= -1.3e+107) || !(x <= 3.4e+66)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -1.3e+107) or not (x <= 3.4e+66): tmp = math.fabs(((x / y) * (1.0 - z))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -1.3e+107) || !(x <= 3.4e+66)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); 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 ((x <= -1.3e+107) || ~((x <= 3.4e+66))) tmp = abs(((x / y) * (1.0 - z))); 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[Or[LessEqual[x, -1.3e+107], N[Not[LessEqual[x, 3.4e+66]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $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}\;x \leq -1.3 \cdot 10^{+107} \lor \neg \left(x \leq 3.4 \cdot 10^{+66}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -1.3000000000000001e107 or 3.4000000000000003e66 < x Initial program 86.3%
Taylor expanded in x around inf 86.3%
*-un-lft-identity86.3%
*-commutative86.3%
distribute-rgt-out--99.9%
Applied egg-rr99.9%
if -1.3000000000000001e107 < x < 3.4000000000000003e66Initial program 95.0%
associate-*l/99.9%
sub-div99.9%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1.6e-49) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ (+ x 4.0) y) (/ x (/ y z))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e-49) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((((x + 4.0) / y) - (x / (y / z))));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.6d-49) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((((x + 4.0d0) / y) - (x / (y / z))))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e-49) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((((x + 4.0) / y) - (x / (y / z))));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 1.6e-49: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((((x + 4.0) / y) - (x / (y / z)))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 1.6e-49) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x / Float64(y / z)))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.6e-49) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((((x + 4.0) / y) - (x / (y / z)))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 1.6e-49], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-49}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if y < 1.60000000000000001e-49Initial program 90.8%
associate-*l/90.9%
sub-div96.9%
Applied egg-rr96.9%
if 1.60000000000000001e-49 < y Initial program 95.0%
Simplified99.9%
Final simplification97.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -126000.0) (not (<= x 4.7e-16))) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (- -4.0 x) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -126000.0) || !(x <= 4.7e-16)) {
tmp = fabs(((x / y) * (1.0 - z)));
} 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 <= (-126000.0d0)) .or. (.not. (x <= 4.7d-16))) then
tmp = abs(((x / y) * (1.0d0 - z)))
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 <= -126000.0) || !(x <= 4.7e-16)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -126000.0) or not (x <= 4.7e-16): tmp = math.fabs(((x / y) * (1.0 - z))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -126000.0) || !(x <= 4.7e-16)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); 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 <= -126000.0) || ~((x <= 4.7e-16))) tmp = abs(((x / y) * (1.0 - z))); 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, -126000.0], N[Not[LessEqual[x, 4.7e-16]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $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 -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if x < -126000 or 4.70000000000000044e-16 < x Initial program 90.1%
Taylor expanded in x around inf 88.8%
*-un-lft-identity88.8%
*-commutative88.8%
distribute-rgt-out--98.6%
Applied egg-rr98.6%
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%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -4.65e+148)
t_0
(if (<= x -4e-23)
(fabs (* x (/ z y)))
(if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -4.65e+148) {
tmp = t_0;
} else if (x <= -4e-23) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if (x <= (-4.65d+148)) then
tmp = t_0
else if (x <= (-4d-23)) then
tmp = abs((x * (z / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = t_0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -4.65e+148) {
tmp = t_0;
} else if (x <= -4e-23) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -4.65e+148: tmp = t_0 elif x <= -4e-23: tmp = math.fabs((x * (z / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -4.65e+148) tmp = t_0; elseif (x <= -4e-23) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = t_0; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -4.65e+148) tmp = t_0; elseif (x <= -4e-23) tmp = abs((x * (z / y))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.65e+148], t$95$0, If[LessEqual[x, -4e-23], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -4.65 \cdot 10^{+148}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-23}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -4.64999999999999992e148 or 4 < x Initial program 87.8%
Taylor expanded in x around inf 86.7%
Taylor expanded in z around 0 75.2%
if -4.64999999999999992e148 < x < -3.99999999999999984e-23Initial program 97.1%
Taylor expanded in z around inf 52.5%
mul-1-neg52.5%
associate-*r/62.7%
distribute-rgt-neg-out62.7%
distribute-neg-frac62.7%
Simplified62.7%
clear-num62.5%
associate-/r/62.7%
add-sqr-sqrt29.9%
sqrt-unprod45.9%
sqr-neg45.9%
sqrt-unprod32.6%
add-sqr-sqrt62.7%
associate-*l*63.3%
div-inv63.4%
expm1-log1p-u35.7%
expm1-udef34.9%
associate-*l/28.5%
div-inv28.5%
associate-*l*31.5%
div-inv31.5%
Applied egg-rr31.5%
expm1-def35.0%
expm1-log1p62.7%
Simplified62.7%
if -3.99999999999999984e-23 < x < 4Initial program 94.1%
Taylor expanded in x around 0 76.2%
Final simplification74.3%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -4.9e+147)
t_0
(if (<= x -2.45e-9)
(fabs (/ z (/ y x)))
(if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -4.9e+147) {
tmp = t_0;
} else if (x <= -2.45e-9) {
tmp = fabs((z / (y / x)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if (x <= (-4.9d+147)) then
tmp = t_0
else if (x <= (-2.45d-9)) then
tmp = abs((z / (y / x)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = t_0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -4.9e+147) {
tmp = t_0;
} else if (x <= -2.45e-9) {
tmp = Math.abs((z / (y / x)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -4.9e+147: tmp = t_0 elif x <= -2.45e-9: tmp = math.fabs((z / (y / x))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -4.9e+147) tmp = t_0; elseif (x <= -2.45e-9) tmp = abs(Float64(z / Float64(y / x))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = t_0; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -4.9e+147) tmp = t_0; elseif (x <= -2.45e-9) tmp = abs((z / (y / x))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.9e+147], t$95$0, If[LessEqual[x, -2.45e-9], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -4.9 \cdot 10^{+147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.45 \cdot 10^{-9}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -4.8999999999999998e147 or 4 < x Initial program 87.8%
Taylor expanded in x around inf 86.7%
Taylor expanded in z around 0 75.2%
if -4.8999999999999998e147 < x < -2.45000000000000002e-9Initial program 99.8%
Taylor expanded in z around inf 52.4%
mul-1-neg52.4%
associate-*r/63.3%
distribute-rgt-neg-out63.3%
distribute-neg-frac63.3%
Simplified63.3%
*-commutative63.3%
div-inv63.3%
associate-*l*66.9%
add-sqr-sqrt31.5%
sqrt-unprod48.6%
sqr-neg48.6%
sqrt-unprod35.1%
add-sqr-sqrt66.9%
associate-/r/66.7%
un-div-inv66.9%
Applied egg-rr66.9%
if -2.45000000000000002e-9 < x < 4Initial program 93.6%
Taylor expanded in x around 0 75.8%
Final simplification74.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -6.4e+15) (fabs (/ (* x z) y)) (if (<= z 1.52e+63) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -6.4e+15) {
tmp = fabs(((x * z) / y));
} else if (z <= 1.52e+63) {
tmp = fabs(((-4.0 - x) / y));
} 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) :: tmp
if (z <= (-6.4d+15)) then
tmp = abs(((x * z) / y))
else if (z <= 1.52d+63) then
tmp = abs((((-4.0d0) - x) / y))
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 tmp;
if (z <= -6.4e+15) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 1.52e+63) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -6.4e+15: tmp = math.fabs(((x * z) / y)) elif z <= 1.52e+63: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -6.4e+15) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 1.52e+63) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.4e+15) tmp = abs(((x * z) / y)); elseif (z <= 1.52e+63) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -6.4e+15], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.52e+63], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.4 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{+63}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -6.4e15Initial program 91.3%
Taylor expanded in z around inf 74.5%
mul-1-neg74.5%
associate-*r/74.4%
distribute-rgt-neg-out74.4%
distribute-neg-frac74.4%
Simplified74.4%
clear-num74.3%
associate-/r/74.3%
add-sqr-sqrt74.2%
sqrt-unprod59.7%
sqr-neg59.7%
sqrt-unprod0.0%
add-sqr-sqrt74.3%
associate-*l*71.9%
div-inv72.0%
associate-*l/74.5%
Applied egg-rr74.5%
if -6.4e15 < z < 1.51999999999999993e63Initial 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.51999999999999993e63 < z Initial program 80.3%
Taylor expanded in z around inf 55.7%
mul-1-neg55.7%
associate-*r/69.6%
distribute-rgt-neg-out69.6%
distribute-neg-frac69.6%
Simplified69.6%
clear-num69.5%
associate-/r/69.6%
add-sqr-sqrt0.0%
sqrt-unprod38.6%
sqr-neg38.6%
sqrt-unprod69.2%
add-sqr-sqrt69.6%
associate-*l*66.8%
div-inv66.9%
expm1-log1p-u35.4%
expm1-udef28.1%
associate-*l/26.3%
div-inv26.3%
associate-*l*26.4%
div-inv26.4%
Applied egg-rr26.4%
expm1-def40.1%
expm1-log1p69.6%
Simplified69.6%
Final simplification86.7%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -10.2) (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 <= -10.2) || !(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 <= (-10.2d0)) .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 <= -10.2) || !(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 <= -10.2) 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 <= -10.2) || !(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 <= -10.2) || ~((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, -10.2], 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 -10.2 \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 < -10.199999999999999 or 4 < x Initial program 90.1%
Taylor expanded in x around inf 88.3%
Taylor expanded in z around 0 67.7%
if -10.199999999999999 < x < 4Initial program 93.7%
Taylor expanded in x around 0 74.9%
Final simplification71.4%
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.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))))