
(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 1.6e-78) (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 <= 1.6e-78) {
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 <= 1.6e-78) 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, 1.6e-78], 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 1.6 \cdot 10^{-78}:\\
\;\;\;\;\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 < 1.6e-78Initial program 90.4%
associate-*l/91.3%
sub-div97.9%
Applied egg-rr97.9%
if 1.6e-78 < y Initial program 88.0%
Simplified99.9%
Final simplification98.4%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(if (or (<= z -1.26e+68)
(and (not (<= z -1.1e+36)) (or (<= z -1.7e+16) (not (<= z 1.3e+68)))))
(fabs (* x (/ z y)))
(fabs (/ (- -4.0 x) y))))y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.26e+68) || (!(z <= -1.1e+36) && ((z <= -1.7e+16) || !(z <= 1.3e+68)))) {
tmp = fabs((x * (z / y)));
} 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 ((z <= (-1.26d+68)) .or. (.not. (z <= (-1.1d+36))) .and. (z <= (-1.7d+16)) .or. (.not. (z <= 1.3d+68))) then
tmp = abs((x * (z / y)))
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 ((z <= -1.26e+68) || (!(z <= -1.1e+36) && ((z <= -1.7e+16) || !(z <= 1.3e+68)))) {
tmp = Math.abs((x * (z / y)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (z <= -1.26e+68) or (not (z <= -1.1e+36) and ((z <= -1.7e+16) or not (z <= 1.3e+68))): tmp = math.fabs((x * (z / y))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((z <= -1.26e+68) || (!(z <= -1.1e+36) && ((z <= -1.7e+16) || !(z <= 1.3e+68)))) tmp = abs(Float64(x * Float64(z / y))); 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 ((z <= -1.26e+68) || (~((z <= -1.1e+36)) && ((z <= -1.7e+16) || ~((z <= 1.3e+68))))) tmp = abs((x * (z / y))); 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[z, -1.26e+68], And[N[Not[LessEqual[z, -1.1e+36]], $MachinePrecision], Or[LessEqual[z, -1.7e+16], N[Not[LessEqual[z, 1.3e+68]], $MachinePrecision]]]], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{+68} \lor \neg \left(z \leq -1.1 \cdot 10^{+36}\right) \land \left(z \leq -1.7 \cdot 10^{+16} \lor \neg \left(z \leq 1.3 \cdot 10^{+68}\right)\right):\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -1.26e68 or -1.1e36 < z < -1.7e16 or 1.2999999999999999e68 < z Initial program 82.7%
Taylor expanded in z around inf 80.5%
mul-1-neg80.5%
associate-*r/85.7%
distribute-rgt-neg-out85.7%
distribute-neg-frac85.7%
Simplified85.7%
associate-*r/80.5%
associate-*l/80.2%
expm1-log1p-u46.5%
expm1-udef37.0%
associate-*l/32.7%
div-inv32.7%
associate-*r*35.7%
div-inv35.7%
add-sqr-sqrt20.0%
sqrt-unprod26.1%
sqr-neg26.1%
sqrt-unprod16.2%
add-sqr-sqrt32.4%
Applied egg-rr32.4%
expm1-def49.0%
expm1-log1p85.7%
Simplified85.7%
if -1.26e68 < z < -1.1e36 or -1.7e16 < z < 1.2999999999999999e68Initial program 94.2%
Simplified98.8%
Taylor expanded in z around 0 95.9%
associate-*r/95.9%
distribute-lft-in95.9%
metadata-eval95.9%
neg-mul-195.9%
sub-neg95.9%
Simplified95.9%
Final simplification91.9%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
(if (<= x -3.2e+32)
t_0
(if (<= x -1.25e-15)
t_1
(if (<= x 3e-27) (fabs (/ 4.0 y)) (if (<= x 5.8e+170) t_1 t_0))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((x * (z / y)));
double tmp;
if (x <= -3.2e+32) {
tmp = t_0;
} else if (x <= -1.25e-15) {
tmp = t_1;
} else if (x <= 3e-27) {
tmp = fabs((4.0 / y));
} else if (x <= 5.8e+170) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((x * (z / y)))
if (x <= (-3.2d+32)) then
tmp = t_0
else if (x <= (-1.25d-15)) then
tmp = t_1
else if (x <= 3d-27) then
tmp = abs((4.0d0 / y))
else if (x <= 5.8d+170) then
tmp = t_1
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 t_1 = Math.abs((x * (z / y)));
double tmp;
if (x <= -3.2e+32) {
tmp = t_0;
} else if (x <= -1.25e-15) {
tmp = t_1;
} else if (x <= 3e-27) {
tmp = Math.abs((4.0 / y));
} else if (x <= 5.8e+170) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((x * (z / y))) tmp = 0 if x <= -3.2e+32: tmp = t_0 elif x <= -1.25e-15: tmp = t_1 elif x <= 3e-27: tmp = math.fabs((4.0 / y)) elif x <= 5.8e+170: tmp = t_1 else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(x * Float64(z / y))) tmp = 0.0 if (x <= -3.2e+32) tmp = t_0; elseif (x <= -1.25e-15) tmp = t_1; elseif (x <= 3e-27) tmp = abs(Float64(4.0 / y)); elseif (x <= 5.8e+170) tmp = t_1; else tmp = t_0; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((x * (z / y))); tmp = 0.0; if (x <= -3.2e+32) tmp = t_0; elseif (x <= -1.25e-15) tmp = t_1; elseif (x <= 3e-27) tmp = abs((4.0 / y)); elseif (x <= 5.8e+170) tmp = t_1; 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]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.2e+32], t$95$0, If[LessEqual[x, -1.25e-15], t$95$1, If[LessEqual[x, 3e-27], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.8e+170], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-27}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+170}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -3.1999999999999999e32 or 5.8000000000000001e170 < x Initial program 79.5%
associate-*l/82.1%
sub-div96.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 96.5%
Taylor expanded in z around 0 82.3%
if -3.1999999999999999e32 < x < -1.25e-15 or 3.0000000000000001e-27 < x < 5.8000000000000001e170Initial program 99.8%
Taylor expanded in z around inf 71.0%
mul-1-neg71.0%
associate-*r/79.0%
distribute-rgt-neg-out79.0%
distribute-neg-frac79.0%
Simplified79.0%
associate-*r/71.0%
associate-*l/79.2%
expm1-log1p-u43.2%
expm1-udef34.9%
associate-*l/29.5%
div-inv29.5%
associate-*r*34.9%
div-inv34.9%
add-sqr-sqrt16.6%
sqrt-unprod23.6%
sqr-neg23.6%
sqrt-unprod14.6%
add-sqr-sqrt33.2%
Applied egg-rr33.2%
expm1-def41.5%
expm1-log1p79.0%
Simplified79.0%
if -1.25e-15 < x < 3.0000000000000001e-27Initial program 92.7%
Taylor expanded in x around 0 78.5%
Final simplification79.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y 1e+59) (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 <= 1e+59) {
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 <= 1d+59) 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 <= 1e+59) {
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 <= 1e+59: 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 <= 1e+59) 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 <= 1e+59) 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, 1e+59], 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 10^{+59}:\\
\;\;\;\;\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 < 9.99999999999999972e58Initial program 91.4%
associate-*l/92.2%
sub-div98.1%
Applied egg-rr98.1%
if 9.99999999999999972e58 < y Initial program 82.6%
Simplified99.8%
Final simplification98.4%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))))
(if (<= x -4.2e-16)
t_0
(if (<= x 1.15e-27)
(fabs (/ 4.0 y))
(if (<= x 3.2e+171) t_0 (fabs (/ x y)))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double tmp;
if (x <= -4.2e-16) {
tmp = t_0;
} else if (x <= 1.15e-27) {
tmp = fabs((4.0 / y));
} else if (x <= 3.2e+171) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = abs((z * (x / y)))
if (x <= (-4.2d-16)) then
tmp = t_0
else if (x <= 1.15d-27) then
tmp = abs((4.0d0 / y))
else if (x <= 3.2d+171) then
tmp = t_0
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 t_0 = Math.abs((z * (x / y)));
double tmp;
if (x <= -4.2e-16) {
tmp = t_0;
} else if (x <= 1.15e-27) {
tmp = Math.abs((4.0 / y));
} else if (x <= 3.2e+171) {
tmp = t_0;
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z * (x / y))) tmp = 0 if x <= -4.2e-16: tmp = t_0 elif x <= 1.15e-27: tmp = math.fabs((4.0 / y)) elif x <= 3.2e+171: tmp = t_0 else: tmp = math.fabs((x / y)) return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) tmp = 0.0 if (x <= -4.2e-16) tmp = t_0; elseif (x <= 1.15e-27) tmp = abs(Float64(4.0 / y)); elseif (x <= 3.2e+171) tmp = t_0; else tmp = abs(Float64(x / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); tmp = 0.0; if (x <= -4.2e-16) tmp = t_0; elseif (x <= 1.15e-27) tmp = abs((4.0 / y)); elseif (x <= 3.2e+171) tmp = t_0; else tmp = abs((x / 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]}, If[LessEqual[x, -4.2e-16], t$95$0, If[LessEqual[x, 1.15e-27], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.2e+171], t$95$0, N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-27}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+171}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -4.2000000000000002e-16 or 1.15e-27 < x < 3.20000000000000011e171Initial program 91.0%
Taylor expanded in z around inf 57.9%
mul-1-neg57.9%
associate-*r/64.4%
distribute-rgt-neg-out64.4%
distribute-neg-frac64.4%
Simplified64.4%
associate-*r/57.9%
associate-/l*64.3%
add-sqr-sqrt32.7%
sqrt-unprod52.0%
sqr-neg52.0%
sqrt-unprod31.5%
add-sqr-sqrt64.3%
associate-/l*57.9%
Applied egg-rr57.9%
associate-/l*64.3%
associate-/r/73.7%
Applied egg-rr73.7%
if -4.2000000000000002e-16 < x < 1.15e-27Initial program 92.7%
Taylor expanded in x around 0 78.5%
if 3.20000000000000011e171 < x Initial program 72.4%
associate-*l/79.3%
sub-div100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 100.0%
Taylor expanded in z around 0 100.0%
Final simplification79.0%
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 89.7%
associate-*l/92.6%
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.5) (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.5) || !(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.5d0)) .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.5) || !(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.5) 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.5) || !(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.5) || ~((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.5], 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.5 \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.5 or 4 < x Initial program 85.8%
associate-*l/84.4%
sub-div94.4%
Applied egg-rr94.4%
Taylor expanded in x around inf 93.7%
Taylor expanded in z around 0 66.6%
if -1.5 < x < 4Initial program 93.2%
Taylor expanded in x around 0 73.6%
Final simplification70.3%
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 89.7%
Taylor expanded in x around 0 41.5%
Final simplification41.5%
herbie shell --seed 2023309
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))