
(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 10 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 2e-8) (fabs (/ (+ 4.0 (* (- 1.0 z) x)) 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 <= 2e-8) {
tmp = fabs(((4.0 + ((1.0 - z) * x)) / 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 <= 2e-8) tmp = abs(Float64(Float64(4.0 + Float64(Float64(1.0 - z) * x)) / 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, 2e-8], N[Abs[N[(N[(4.0 + N[(N[(1.0 - z), $MachinePrecision] * x), $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 2 \cdot 10^{-8}:\\
\;\;\;\;\left|\frac{4 + \left(1 - z\right) \cdot x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 2e-8Initial program 90.2%
fabs-neg90.2%
sub-neg90.2%
distribute-neg-in90.2%
sub-neg90.2%
distribute-neg-frac90.2%
associate-*l/92.7%
distribute-neg-frac92.7%
neg-mul-192.7%
associate-*l/92.6%
neg-mul-192.6%
associate-*l/92.5%
distribute-lft-out--97.8%
fabs-mul97.8%
fabs-sub97.8%
fabs-mul97.8%
associate-*l/98.0%
Simplified98.0%
Taylor expanded in x around 0 98.0%
if 2e-8 < y Initial program 90.0%
fabs-sub90.0%
associate-*l/95.6%
*-commutative95.6%
associate-*l/99.7%
*-commutative99.7%
fma-neg99.7%
distribute-neg-frac99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification98.4%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -1.25e+33) (/ (fabs x) (fabs (/ y z))) (if (<= z 1.3e+14) (fabs (/ (- -4.0 x) y)) (fabs (/ (* z x) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -1.25e+33) {
tmp = fabs(x) / fabs((y / z));
} else if (z <= 1.3e+14) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs(((z * 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.25d+33)) then
tmp = abs(x) / abs((y / z))
else if (z <= 1.3d+14) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs(((z * 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.25e+33) {
tmp = Math.abs(x) / Math.abs((y / z));
} else if (z <= 1.3e+14) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs(((z * x) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -1.25e+33: tmp = math.fabs(x) / math.fabs((y / z)) elif z <= 1.3e+14: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs(((z * x) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -1.25e+33) tmp = Float64(abs(x) / abs(Float64(y / z))); elseif (z <= 1.3e+14) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(z * x) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.25e+33) tmp = abs(x) / abs((y / z)); elseif (z <= 1.3e+14) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((z * x) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -1.25e+33], N[(N[Abs[x], $MachinePrecision] / N[Abs[N[(y / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.3e+14], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+33}:\\
\;\;\;\;\frac{\left|x\right|}{\left|\frac{y}{z}\right|}\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+14}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z \cdot x}{y}\right|\\
\end{array}
\end{array}
if z < -1.24999999999999993e33Initial program 92.9%
Taylor expanded in z around inf 77.0%
*-commutative77.0%
metadata-eval77.0%
times-frac77.0%
*-lft-identity77.0%
neg-mul-177.0%
associate-/l*83.3%
distribute-frac-neg83.3%
Simplified83.3%
if -1.24999999999999993e33 < z < 1.3e14Initial program 95.5%
Simplified99.7%
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%
if 1.3e14 < z Initial program 75.7%
Simplified96.6%
Taylor expanded in z around inf 77.5%
Final simplification88.5%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* x (/ z y)))) (t_1 (fabs (/ x y))))
(if (<= x -3.3e+225)
t_0
(if (<= x -1.1e+99)
t_1
(if (<= x -1.96e+59)
t_0
(if (<= x -1.55)
t_1
(if (<= x 7e-54)
(fabs (/ 4.0 y))
(if (<= x 2.3e+182) t_0 t_1))))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x * (z / y)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -3.3e+225) {
tmp = t_0;
} else if (x <= -1.1e+99) {
tmp = t_1;
} else if (x <= -1.96e+59) {
tmp = t_0;
} else if (x <= -1.55) {
tmp = t_1;
} else if (x <= 7e-54) {
tmp = fabs((4.0 / y));
} else if (x <= 2.3e+182) {
tmp = t_0;
} else {
tmp = t_1;
}
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 * (z / y)))
t_1 = abs((x / y))
if (x <= (-3.3d+225)) then
tmp = t_0
else if (x <= (-1.1d+99)) then
tmp = t_1
else if (x <= (-1.96d+59)) then
tmp = t_0
else if (x <= (-1.55d0)) then
tmp = t_1
else if (x <= 7d-54) then
tmp = abs((4.0d0 / y))
else if (x <= 2.3d+182) then
tmp = t_0
else
tmp = t_1
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 * (z / y)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -3.3e+225) {
tmp = t_0;
} else if (x <= -1.1e+99) {
tmp = t_1;
} else if (x <= -1.96e+59) {
tmp = t_0;
} else if (x <= -1.55) {
tmp = t_1;
} else if (x <= 7e-54) {
tmp = Math.abs((4.0 / y));
} else if (x <= 2.3e+182) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x * (z / y))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -3.3e+225: tmp = t_0 elif x <= -1.1e+99: tmp = t_1 elif x <= -1.96e+59: tmp = t_0 elif x <= -1.55: tmp = t_1 elif x <= 7e-54: tmp = math.fabs((4.0 / y)) elif x <= 2.3e+182: tmp = t_0 else: tmp = t_1 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x * Float64(z / y))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -3.3e+225) tmp = t_0; elseif (x <= -1.1e+99) tmp = t_1; elseif (x <= -1.96e+59) tmp = t_0; elseif (x <= -1.55) tmp = t_1; elseif (x <= 7e-54) tmp = abs(Float64(4.0 / y)); elseif (x <= 2.3e+182) tmp = t_0; else tmp = t_1; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x * (z / y))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -3.3e+225) tmp = t_0; elseif (x <= -1.1e+99) tmp = t_1; elseif (x <= -1.96e+59) tmp = t_0; elseif (x <= -1.55) tmp = t_1; elseif (x <= 7e-54) tmp = abs((4.0 / y)); elseif (x <= 2.3e+182) tmp = t_0; else tmp = t_1; 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 * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.3e+225], t$95$0, If[LessEqual[x, -1.1e+99], t$95$1, If[LessEqual[x, -1.96e+59], t$95$0, If[LessEqual[x, -1.55], t$95$1, If[LessEqual[x, 7e-54], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.3e+182], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|x \cdot \frac{z}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -3.3 \cdot 10^{+225}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{+99}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.96 \cdot 10^{+59}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.55:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-54}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+182}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.3e225 or -1.09999999999999989e99 < x < -1.96000000000000007e59 or 6.99999999999999964e-54 < x < 2.3e182Initial program 92.2%
Simplified96.2%
Taylor expanded in z around inf 64.6%
associate-*l/68.0%
*-commutative68.0%
Simplified68.0%
if -3.3e225 < x < -1.09999999999999989e99 or -1.96000000000000007e59 < x < -1.55000000000000004 or 2.3e182 < x Initial program 87.7%
Taylor expanded in z around 0 74.7%
associate-*r/74.7%
metadata-eval74.7%
Simplified74.7%
Taylor expanded in x around inf 72.8%
if -1.55000000000000004 < x < 6.99999999999999964e-54Initial program 90.1%
Taylor expanded in x around 0 72.7%
Final simplification71.3%
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 (/ x y))))
(if (<= x -1.25e+177)
t_0
(if (<= x -2.7e+98)
t_1
(if (<= x -4.4e+57)
t_0
(if (<= x -1.5) t_1 (if (<= x 8e-54) (fabs (/ 4.0 y)) t_0)))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -1.25e+177) {
tmp = t_0;
} else if (x <= -2.7e+98) {
tmp = t_1;
} else if (x <= -4.4e+57) {
tmp = t_0;
} else if (x <= -1.5) {
tmp = t_1;
} else if (x <= 8e-54) {
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) :: t_1
real(8) :: tmp
t_0 = abs((z * (x / y)))
t_1 = abs((x / y))
if (x <= (-1.25d+177)) then
tmp = t_0
else if (x <= (-2.7d+98)) then
tmp = t_1
else if (x <= (-4.4d+57)) then
tmp = t_0
else if (x <= (-1.5d0)) then
tmp = t_1
else if (x <= 8d-54) 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((z * (x / y)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -1.25e+177) {
tmp = t_0;
} else if (x <= -2.7e+98) {
tmp = t_1;
} else if (x <= -4.4e+57) {
tmp = t_0;
} else if (x <= -1.5) {
tmp = t_1;
} else if (x <= 8e-54) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -1.25e+177: tmp = t_0 elif x <= -2.7e+98: tmp = t_1 elif x <= -4.4e+57: tmp = t_0 elif x <= -1.5: tmp = t_1 elif x <= 8e-54: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -1.25e+177) tmp = t_0; elseif (x <= -2.7e+98) tmp = t_1; elseif (x <= -4.4e+57) tmp = t_0; elseif (x <= -1.5) tmp = t_1; elseif (x <= 8e-54) 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((z * (x / y))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -1.25e+177) tmp = t_0; elseif (x <= -2.7e+98) tmp = t_1; elseif (x <= -4.4e+57) tmp = t_0; elseif (x <= -1.5) tmp = t_1; elseif (x <= 8e-54) 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.25e+177], t$95$0, If[LessEqual[x, -2.7e+98], t$95$1, If[LessEqual[x, -4.4e+57], t$95$0, If[LessEqual[x, -1.5], t$95$1, If[LessEqual[x, 8e-54], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{+177}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-54}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.2500000000000001e177 or -2.7e98 < x < -4.4000000000000001e57 or 8.0000000000000002e-54 < x Initial program 88.7%
Simplified94.9%
Taylor expanded in z around inf 58.8%
*-commutative58.8%
associate-*l/69.3%
*-commutative69.3%
Simplified69.3%
if -1.2500000000000001e177 < x < -2.7e98 or -4.4000000000000001e57 < x < -1.5Initial program 96.4%
Taylor expanded in z around 0 78.3%
associate-*r/78.3%
metadata-eval78.3%
Simplified78.3%
Taylor expanded in x around inf 74.0%
if -1.5 < x < 8.0000000000000002e-54Initial program 90.1%
Taylor expanded in x around 0 72.7%
Final simplification71.3%
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 (/ x y))))
(if (<= x -6.6e+178)
t_0
(if (<= x -1.18e+98)
t_1
(if (<= x -1.85e+57)
(fabs (/ z (/ y x)))
(if (<= x -1.55) t_1 (if (<= x 8.5e-54) (fabs (/ 4.0 y)) t_0)))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -6.6e+178) {
tmp = t_0;
} else if (x <= -1.18e+98) {
tmp = t_1;
} else if (x <= -1.85e+57) {
tmp = fabs((z / (y / x)));
} else if (x <= -1.55) {
tmp = t_1;
} else if (x <= 8.5e-54) {
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) :: t_1
real(8) :: tmp
t_0 = abs((z * (x / y)))
t_1 = abs((x / y))
if (x <= (-6.6d+178)) then
tmp = t_0
else if (x <= (-1.18d+98)) then
tmp = t_1
else if (x <= (-1.85d+57)) then
tmp = abs((z / (y / x)))
else if (x <= (-1.55d0)) then
tmp = t_1
else if (x <= 8.5d-54) 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((z * (x / y)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -6.6e+178) {
tmp = t_0;
} else if (x <= -1.18e+98) {
tmp = t_1;
} else if (x <= -1.85e+57) {
tmp = Math.abs((z / (y / x)));
} else if (x <= -1.55) {
tmp = t_1;
} else if (x <= 8.5e-54) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -6.6e+178: tmp = t_0 elif x <= -1.18e+98: tmp = t_1 elif x <= -1.85e+57: tmp = math.fabs((z / (y / x))) elif x <= -1.55: tmp = t_1 elif x <= 8.5e-54: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -6.6e+178) tmp = t_0; elseif (x <= -1.18e+98) tmp = t_1; elseif (x <= -1.85e+57) tmp = abs(Float64(z / Float64(y / x))); elseif (x <= -1.55) tmp = t_1; elseif (x <= 8.5e-54) 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((z * (x / y))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -6.6e+178) tmp = t_0; elseif (x <= -1.18e+98) tmp = t_1; elseif (x <= -1.85e+57) tmp = abs((z / (y / x))); elseif (x <= -1.55) tmp = t_1; elseif (x <= 8.5e-54) 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.6e+178], t$95$0, If[LessEqual[x, -1.18e+98], t$95$1, If[LessEqual[x, -1.85e+57], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -1.55], t$95$1, If[LessEqual[x, 8.5e-54], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{+178}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.18 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{+57}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;x \leq -1.55:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-54}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.5999999999999996e178 or 8.5e-54 < x Initial program 88.4%
Simplified94.3%
Taylor expanded in z around inf 56.8%
*-commutative56.8%
associate-*l/68.5%
*-commutative68.5%
Simplified68.5%
if -6.5999999999999996e178 < x < -1.18000000000000002e98 or -1.85000000000000003e57 < x < -1.55000000000000004Initial program 96.4%
Taylor expanded in z around 0 78.3%
associate-*r/78.3%
metadata-eval78.3%
Simplified78.3%
Taylor expanded in x around inf 74.0%
if -1.18000000000000002e98 < x < -1.85000000000000003e57Initial program 91.4%
Simplified99.5%
Taylor expanded in z around inf 76.4%
*-commutative76.4%
associate-*l/76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in z around 0 76.4%
associate-/l*76.4%
Simplified76.4%
if -1.55000000000000004 < x < 8.5e-54Initial program 90.1%
Taylor expanded in x around 0 72.7%
Final simplification71.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1.6) (not (<= x 4.2))) (fabs (/ (- 1.0 z) (/ y x))) (fabs (/ (- 4.0 (* z x)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.6) || !(x <= 4.2)) {
tmp = fabs(((1.0 - z) / (y / x)));
} else {
tmp = fabs(((4.0 - (z * 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 <= (-1.6d0)) .or. (.not. (x <= 4.2d0))) then
tmp = abs(((1.0d0 - z) / (y / x)))
else
tmp = abs(((4.0d0 - (z * 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 <= -1.6) || !(x <= 4.2)) {
tmp = Math.abs(((1.0 - z) / (y / x)));
} else {
tmp = Math.abs(((4.0 - (z * x)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -1.6) or not (x <= 4.2): tmp = math.fabs(((1.0 - z) / (y / x))) else: tmp = math.fabs(((4.0 - (z * x)) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -1.6) || !(x <= 4.2)) tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x))); else tmp = abs(Float64(Float64(4.0 - Float64(z * x)) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.6) || ~((x <= 4.2))) tmp = abs(((1.0 - z) / (y / x))); else tmp = abs(((4.0 - (z * x)) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -1.6], N[Not[LessEqual[x, 4.2]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 - N[(z * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \lor \neg \left(x \leq 4.2\right):\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 - z \cdot x}{y}\right|\\
\end{array}
\end{array}
if x < -1.6000000000000001 or 4.20000000000000018 < x Initial program 89.4%
Simplified94.8%
Taylor expanded in x around inf 93.3%
associate-/l*98.1%
sub-neg98.1%
metadata-eval98.1%
Simplified98.1%
if -1.6000000000000001 < x < 4.20000000000000018Initial program 90.9%
fabs-neg90.9%
sub-neg90.9%
distribute-neg-in90.9%
sub-neg90.9%
distribute-neg-frac90.9%
associate-*l/99.9%
distribute-neg-frac99.9%
neg-mul-199.9%
associate-*l/99.9%
neg-mul-199.9%
associate-*l/99.8%
distribute-lft-out--99.8%
fabs-mul99.8%
fabs-sub99.8%
fabs-mul99.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in z around inf 98.5%
neg-mul-198.5%
distribute-lft-neg-in98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -1.45e+31) (fabs (/ (- 1.0 z) (/ y x))) (fabs (/ (+ 4.0 (* (- 1.0 z) x)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45e+31) {
tmp = fabs(((1.0 - z) / (y / x)));
} else {
tmp = fabs(((4.0 + ((1.0 - z) * 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 <= (-1.45d+31)) then
tmp = abs(((1.0d0 - z) / (y / x)))
else
tmp = abs(((4.0d0 + ((1.0d0 - z) * 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 <= -1.45e+31) {
tmp = Math.abs(((1.0 - z) / (y / x)));
} else {
tmp = Math.abs(((4.0 + ((1.0 - z) * x)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= -1.45e+31: tmp = math.fabs(((1.0 - z) / (y / x))) else: tmp = math.fabs(((4.0 + ((1.0 - z) * x)) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= -1.45e+31) tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x))); else tmp = abs(Float64(Float64(4.0 + Float64(Float64(1.0 - z) * x)) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45e+31) tmp = abs(((1.0 - z) / (y / x))); else tmp = abs(((4.0 + ((1.0 - z) * x)) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, -1.45e+31], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 + N[(N[(1.0 - z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+31}:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + \left(1 - z\right) \cdot x}{y}\right|\\
\end{array}
\end{array}
if x < -1.45e31Initial program 87.8%
Simplified92.7%
Taylor expanded in x around inf 92.9%
associate-/l*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -1.45e31 < x Initial program 91.0%
fabs-neg91.0%
sub-neg91.0%
distribute-neg-in91.0%
sub-neg91.0%
distribute-neg-frac91.0%
associate-*l/97.3%
distribute-neg-frac97.3%
neg-mul-197.3%
associate-*l/97.2%
neg-mul-197.2%
associate-*l/97.2%
distribute-lft-out--98.8%
fabs-mul98.8%
fabs-sub98.8%
fabs-mul98.8%
associate-*l/98.9%
Simplified98.9%
Taylor expanded in x around 0 98.9%
Final simplification99.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -6.1e+32) (fabs (* x (/ z y))) (if (<= z 2.6e+14) (fabs (/ (- -4.0 x) y)) (fabs (/ (* z x) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -6.1e+32) {
tmp = fabs((x * (z / y)));
} else if (z <= 2.6e+14) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs(((z * 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 <= (-6.1d+32)) then
tmp = abs((x * (z / y)))
else if (z <= 2.6d+14) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs(((z * 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 <= -6.1e+32) {
tmp = Math.abs((x * (z / y)));
} else if (z <= 2.6e+14) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs(((z * x) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -6.1e+32: tmp = math.fabs((x * (z / y))) elif z <= 2.6e+14: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs(((z * x) / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -6.1e+32) tmp = abs(Float64(x * Float64(z / y))); elseif (z <= 2.6e+14) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(z * x) / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.1e+32) tmp = abs((x * (z / y))); elseif (z <= 2.6e+14) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((z * x) / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -6.1e+32], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.6e+14], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{+32}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+14}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z \cdot x}{y}\right|\\
\end{array}
\end{array}
if z < -6.10000000000000027e32Initial program 92.9%
Simplified92.2%
Taylor expanded in z around inf 77.0%
associate-*l/83.3%
*-commutative83.3%
Simplified83.3%
if -6.10000000000000027e32 < z < 2.6e14Initial program 95.5%
Simplified99.7%
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%
if 2.6e14 < z Initial program 75.7%
Simplified96.6%
Taylor expanded in z around inf 77.5%
Final simplification88.5%
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.4%
Taylor expanded in z around 0 60.5%
associate-*r/60.5%
metadata-eval60.5%
Simplified60.5%
Taylor expanded in x around inf 58.8%
if -1.5 < x < 4Initial program 90.9%
Taylor expanded in x around 0 70.0%
Final simplification64.1%
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 90.1%
Taylor expanded in x around 0 36.0%
Final simplification36.0%
herbie shell --seed 2023252
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))