
(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 2.5e-35) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (+ (* x (/ z y)) (/ (- -4.0 x) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 2.5e-35) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((x * (z / y)) + ((-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 (y <= 2.5d-35) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((x * (z / y)) + (((-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 (y <= 2.5e-35) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((x * (z / y)) + ((-4.0 - x) / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 2.5e-35: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((x * (z / y)) + ((-4.0 - x) / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 2.5e-35) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(x * Float64(z / y)) + Float64(Float64(-4.0 - x) / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.5e-35) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((x * (z / y)) + ((-4.0 - x) / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 2.5e-35], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-35}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if y < 2.49999999999999982e-35Initial program 92.2%
associate-*l/90.8%
sub-div96.8%
Applied egg-rr96.8%
if 2.49999999999999982e-35 < y Initial program 96.1%
Simplified92.1%
fma-udef92.1%
distribute-rgt-in92.1%
associate-*r*99.8%
div-inv99.8%
div-inv99.9%
Applied egg-rr99.9%
Final simplification97.7%
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 -5.7e+150)
t_0
(if (<= x -6.5e-47)
t_1
(if (<= x 6.1e-53) (fabs (/ 4.0 y)) (if (<= x 9.8e+51) 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 <= -5.7e+150) {
tmp = t_0;
} else if (x <= -6.5e-47) {
tmp = t_1;
} else if (x <= 6.1e-53) {
tmp = fabs((4.0 / y));
} else if (x <= 9.8e+51) {
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 <= (-5.7d+150)) then
tmp = t_0
else if (x <= (-6.5d-47)) then
tmp = t_1
else if (x <= 6.1d-53) then
tmp = abs((4.0d0 / y))
else if (x <= 9.8d+51) 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 <= -5.7e+150) {
tmp = t_0;
} else if (x <= -6.5e-47) {
tmp = t_1;
} else if (x <= 6.1e-53) {
tmp = Math.abs((4.0 / y));
} else if (x <= 9.8e+51) {
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 <= -5.7e+150: tmp = t_0 elif x <= -6.5e-47: tmp = t_1 elif x <= 6.1e-53: tmp = math.fabs((4.0 / y)) elif x <= 9.8e+51: 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 <= -5.7e+150) tmp = t_0; elseif (x <= -6.5e-47) tmp = t_1; elseif (x <= 6.1e-53) tmp = abs(Float64(4.0 / y)); elseif (x <= 9.8e+51) 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 <= -5.7e+150) tmp = t_0; elseif (x <= -6.5e-47) tmp = t_1; elseif (x <= 6.1e-53) tmp = abs((4.0 / y)); elseif (x <= 9.8e+51) 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, -5.7e+150], t$95$0, If[LessEqual[x, -6.5e-47], t$95$1, If[LessEqual[x, 6.1e-53], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 9.8e+51], 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 -5.7 \cdot 10^{+150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-47}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{+51}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -5.7000000000000002e150 or 9.79999999999999967e51 < x Initial program 87.3%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
sub-neg99.7%
mul-1-neg99.7%
distribute-lft-in88.3%
associate-*r/88.3%
*-rgt-identity88.3%
mul-1-neg88.3%
distribute-rgt-neg-in88.3%
unsub-neg88.3%
*-lft-identity88.3%
associate-/l*88.3%
*-commutative88.3%
associate-/r/87.2%
div-sub99.8%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in z around 0 70.2%
if -5.7000000000000002e150 < x < -6.5000000000000004e-47 or 6.0999999999999999e-53 < x < 9.79999999999999967e51Initial program 96.1%
Simplified96.1%
Taylor expanded in z around inf 62.8%
associate-*l/66.3%
*-commutative66.3%
Simplified66.3%
if -6.5000000000000004e-47 < x < 6.0999999999999999e-53Initial program 96.6%
Taylor expanded in x around 0 83.6%
Final simplification75.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -4.4e+133) (not (<= x 88000000.0))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.4e+133) || !(x <= 88000000.0)) {
tmp = fabs(((z + -1.0) / (y / x)));
} 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 <= (-4.4d+133)) .or. (.not. (x <= 88000000.0d0))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
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 <= -4.4e+133) || !(x <= 88000000.0)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -4.4e+133) or not (x <= 88000000.0): tmp = math.fabs(((z + -1.0) / (y / x))) 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 <= -4.4e+133) || !(x <= 88000000.0)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); 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 <= -4.4e+133) || ~((x <= 88000000.0))) tmp = abs(((z + -1.0) / (y / x))); 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, -4.4e+133], N[Not[LessEqual[x, 88000000.0]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $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 -4.4 \cdot 10^{+133} \lor \neg \left(x \leq 88000000\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -4.4e133 or 8.8e7 < x Initial program 88.4%
Simplified88.1%
Taylor expanded in x around inf 88.2%
associate-/l*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -4.4e133 < x < 8.8e7Initial program 96.2%
associate-*l/99.2%
sub-div99.9%
Applied egg-rr99.9%
Final simplification99.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1e-48) (not (<= x 1.15e-51))) (fabs (* x (/ (- 1.0 z) y))) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-48) || !(x <= 1.15e-51)) {
tmp = fabs((x * ((1.0 - z) / 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 <= (-1d-48)) .or. (.not. (x <= 1.15d-51))) then
tmp = abs((x * ((1.0d0 - z) / 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 <= -1e-48) || !(x <= 1.15e-51)) {
tmp = Math.abs((x * ((1.0 - z) / y)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -1e-48) or not (x <= 1.15e-51): tmp = math.fabs((x * ((1.0 - z) / y))) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -1e-48) || !(x <= 1.15e-51)) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / 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 <= -1e-48) || ~((x <= 1.15e-51))) tmp = abs((x * ((1.0 - z) / 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, -1e-48], N[Not[LessEqual[x, 1.15e-51]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-48} \lor \neg \left(x \leq 1.15 \cdot 10^{-51}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -9.9999999999999997e-49 or 1.15000000000000001e-51 < x Initial program 90.7%
Taylor expanded in x around inf 94.5%
*-commutative94.5%
sub-neg94.5%
mul-1-neg94.5%
distribute-lft-in86.7%
associate-*r/86.8%
*-rgt-identity86.8%
mul-1-neg86.8%
distribute-rgt-neg-in86.8%
unsub-neg86.8%
*-lft-identity86.8%
associate-/l*86.7%
*-commutative86.7%
associate-/r/85.4%
div-sub93.8%
associate-/r/94.6%
Simplified94.6%
if -9.9999999999999997e-49 < x < 1.15000000000000001e-51Initial program 96.6%
Taylor expanded in x around 0 83.6%
Final simplification89.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -3.9e-47) (fabs (* x (/ (- 1.0 z) y))) (if (<= x 2e-52) (fabs (/ 4.0 y)) (fabs (/ (+ z -1.0) (/ y x))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= -3.9e-47) {
tmp = fabs((x * ((1.0 - z) / y)));
} else if (x <= 2e-52) {
tmp = fabs((4.0 / y));
} else {
tmp = fabs(((z + -1.0) / (y / x)));
}
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 <= (-3.9d-47)) then
tmp = abs((x * ((1.0d0 - z) / y)))
else if (x <= 2d-52) then
tmp = abs((4.0d0 / y))
else
tmp = abs(((z + (-1.0d0)) / (y / x)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.9e-47) {
tmp = Math.abs((x * ((1.0 - z) / y)));
} else if (x <= 2e-52) {
tmp = Math.abs((4.0 / y));
} else {
tmp = Math.abs(((z + -1.0) / (y / x)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= -3.9e-47: tmp = math.fabs((x * ((1.0 - z) / y))) elif x <= 2e-52: tmp = math.fabs((4.0 / y)) else: tmp = math.fabs(((z + -1.0) / (y / x))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= -3.9e-47) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y))); elseif (x <= 2e-52) tmp = abs(Float64(4.0 / y)); else tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.9e-47) tmp = abs((x * ((1.0 - z) / y))); elseif (x <= 2e-52) tmp = abs((4.0 / y)); else tmp = abs(((z + -1.0) / (y / x))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, -3.9e-47], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2e-52], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{-47}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-52}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if x < -3.89999999999999978e-47Initial program 94.1%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
sub-neg94.0%
mul-1-neg94.0%
distribute-lft-in91.2%
associate-*r/91.2%
*-rgt-identity91.2%
mul-1-neg91.2%
distribute-rgt-neg-in91.2%
unsub-neg91.2%
*-lft-identity91.2%
associate-/l*91.2%
*-commutative91.2%
associate-/r/88.4%
div-sub92.6%
associate-/r/94.0%
Simplified94.0%
if -3.89999999999999978e-47 < x < 2e-52Initial program 96.6%
Taylor expanded in x around 0 83.6%
if 2e-52 < x Initial program 87.2%
Simplified91.8%
Taylor expanded in x around inf 87.3%
associate-/l*95.1%
sub-neg95.1%
metadata-eval95.1%
Simplified95.1%
Final simplification89.6%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -4.8e+113) (fabs (/ (* x z) y)) (if (<= z 7.2e+48) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -4.8e+113) {
tmp = fabs(((x * z) / y));
} else if (z <= 7.2e+48) {
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 <= (-4.8d+113)) then
tmp = abs(((x * z) / y))
else if (z <= 7.2d+48) 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 <= -4.8e+113) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 7.2e+48) {
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 <= -4.8e+113: tmp = math.fabs(((x * z) / y)) elif z <= 7.2e+48: 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 <= -4.8e+113) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 7.2e+48) 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 <= -4.8e+113) tmp = abs(((x * z) / y)); elseif (z <= 7.2e+48) 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, -4.8e+113], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 7.2e+48], 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 -4.8 \cdot 10^{+113}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+48}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -4.79999999999999966e113Initial program 90.8%
Simplified91.0%
Taylor expanded in z around inf 75.9%
if -4.79999999999999966e113 < z < 7.19999999999999967e48Initial program 96.9%
Simplified99.3%
Taylor expanded in z around 0 92.8%
associate-*r/92.8%
distribute-lft-in92.8%
metadata-eval92.8%
neg-mul-192.8%
sub-neg92.8%
Simplified92.8%
if 7.19999999999999967e48 < z Initial program 85.4%
Simplified87.6%
Taylor expanded in z around inf 71.0%
associate-*l/80.3%
*-commutative80.3%
Simplified80.3%
Final simplification87.6%
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 89.7%
Taylor expanded in x around inf 98.9%
*-commutative98.9%
sub-neg98.9%
mul-1-neg98.9%
distribute-lft-in89.6%
associate-*r/89.7%
*-rgt-identity89.7%
mul-1-neg89.7%
distribute-rgt-neg-in89.7%
unsub-neg89.7%
*-lft-identity89.7%
associate-/l*89.6%
*-commutative89.6%
associate-/r/88.8%
div-sub98.9%
associate-/r/98.9%
Simplified98.9%
Taylor expanded in z around 0 61.9%
if -1.5 < x < 4Initial program 96.4%
Taylor expanded in x around 0 75.0%
Final simplification68.9%
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 93.3%
Taylor expanded in x around 0 42.5%
Final simplification42.5%
herbie shell --seed 2023230
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))