
(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 8.8e-107) (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 <= 8.8e-107) {
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 <= 8.8d-107) 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 <= 8.8e-107) {
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 <= 8.8e-107: 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 <= 8.8e-107) 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 <= 8.8e-107) 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, 8.8e-107], 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 8.8 \cdot 10^{-107}:\\
\;\;\;\;\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 < 8.8000000000000005e-107Initial program 87.4%
associate-*l/88.6%
sub-div95.5%
Applied egg-rr95.5%
if 8.8000000000000005e-107 < y Initial program 97.3%
Simplified94.2%
fma-udef94.2%
distribute-rgt-in94.2%
associate-*r*99.7%
div-inv99.8%
div-inv99.9%
Applied egg-rr99.9%
Final simplification97.0%
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.8e+232)
t_0
(if (<= x -1.4e+132)
t_1
(if (<= x -2.05e-24)
t_0
(if (<= x 4e-65)
(fabs (/ 4.0 y))
(if (or (<= x 300000000000.0) (not (<= x 2.2e+106))) t_0 t_1)))))))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.8e+232) {
tmp = t_0;
} else if (x <= -1.4e+132) {
tmp = t_1;
} else if (x <= -2.05e-24) {
tmp = t_0;
} else if (x <= 4e-65) {
tmp = fabs((4.0 / y));
} else if ((x <= 300000000000.0) || !(x <= 2.2e+106)) {
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((z * (x / y)))
t_1 = abs((x / y))
if (x <= (-6.8d+232)) then
tmp = t_0
else if (x <= (-1.4d+132)) then
tmp = t_1
else if (x <= (-2.05d-24)) then
tmp = t_0
else if (x <= 4d-65) then
tmp = abs((4.0d0 / y))
else if ((x <= 300000000000.0d0) .or. (.not. (x <= 2.2d+106))) 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((z * (x / y)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -6.8e+232) {
tmp = t_0;
} else if (x <= -1.4e+132) {
tmp = t_1;
} else if (x <= -2.05e-24) {
tmp = t_0;
} else if (x <= 4e-65) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 300000000000.0) || !(x <= 2.2e+106)) {
tmp = t_0;
} else {
tmp = t_1;
}
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.8e+232: tmp = t_0 elif x <= -1.4e+132: tmp = t_1 elif x <= -2.05e-24: tmp = t_0 elif x <= 4e-65: tmp = math.fabs((4.0 / y)) elif (x <= 300000000000.0) or not (x <= 2.2e+106): tmp = t_0 else: tmp = t_1 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.8e+232) tmp = t_0; elseif (x <= -1.4e+132) tmp = t_1; elseif (x <= -2.05e-24) tmp = t_0; elseif (x <= 4e-65) tmp = abs(Float64(4.0 / y)); elseif ((x <= 300000000000.0) || !(x <= 2.2e+106)) tmp = t_0; else tmp = t_1; 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.8e+232) tmp = t_0; elseif (x <= -1.4e+132) tmp = t_1; elseif (x <= -2.05e-24) tmp = t_0; elseif (x <= 4e-65) tmp = abs((4.0 / y)); elseif ((x <= 300000000000.0) || ~((x <= 2.2e+106))) 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.8e+232], t$95$0, If[LessEqual[x, -1.4e+132], t$95$1, If[LessEqual[x, -2.05e-24], t$95$0, If[LessEqual[x, 4e-65], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 300000000000.0], N[Not[LessEqual[x, 2.2e+106]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]
\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.8 \cdot 10^{+232}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.05 \cdot 10^{-24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-65}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 300000000000 \lor \neg \left(x \leq 2.2 \cdot 10^{+106}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -6.7999999999999996e232 or -1.4e132 < x < -2.05000000000000007e-24 or 3.99999999999999969e-65 < x < 3e11 or 2.19999999999999992e106 < x Initial program 88.8%
Simplified89.3%
Taylor expanded in z around inf 50.4%
*-commutative50.4%
associate-*l/72.0%
*-commutative72.0%
Simplified72.0%
if -6.7999999999999996e232 < x < -1.4e132 or 3e11 < x < 2.19999999999999992e106Initial program 83.7%
associate-*l/84.1%
sub-div94.9%
Applied egg-rr94.9%
Taylor expanded in x around inf 94.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 83.0%
if -2.05000000000000007e-24 < x < 3.99999999999999969e-65Initial program 94.4%
Taylor expanded in x around 0 79.6%
Final simplification77.2%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ z (/ y x)))) (t_1 (fabs (/ x y))))
(if (<= x -3.05e+230)
(fabs (* z (/ x y)))
(if (<= x -1.4e+132)
t_1
(if (<= x -3.2e-24)
t_0
(if (<= x 8.2e-63)
(fabs (/ 4.0 y))
(if (or (<= x 3.4e+15) (not (<= x 6.8e+106))) t_0 t_1)))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((z / (y / x)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -3.05e+230) {
tmp = fabs((z * (x / y)));
} else if (x <= -1.4e+132) {
tmp = t_1;
} else if (x <= -3.2e-24) {
tmp = t_0;
} else if (x <= 8.2e-63) {
tmp = fabs((4.0 / y));
} else if ((x <= 3.4e+15) || !(x <= 6.8e+106)) {
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((z / (y / x)))
t_1 = abs((x / y))
if (x <= (-3.05d+230)) then
tmp = abs((z * (x / y)))
else if (x <= (-1.4d+132)) then
tmp = t_1
else if (x <= (-3.2d-24)) then
tmp = t_0
else if (x <= 8.2d-63) then
tmp = abs((4.0d0 / y))
else if ((x <= 3.4d+15) .or. (.not. (x <= 6.8d+106))) 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((z / (y / x)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -3.05e+230) {
tmp = Math.abs((z * (x / y)));
} else if (x <= -1.4e+132) {
tmp = t_1;
} else if (x <= -3.2e-24) {
tmp = t_0;
} else if (x <= 8.2e-63) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 3.4e+15) || !(x <= 6.8e+106)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((z / (y / x))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -3.05e+230: tmp = math.fabs((z * (x / y))) elif x <= -1.4e+132: tmp = t_1 elif x <= -3.2e-24: tmp = t_0 elif x <= 8.2e-63: tmp = math.fabs((4.0 / y)) elif (x <= 3.4e+15) or not (x <= 6.8e+106): tmp = t_0 else: tmp = t_1 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(z / Float64(y / x))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -3.05e+230) tmp = abs(Float64(z * Float64(x / y))); elseif (x <= -1.4e+132) tmp = t_1; elseif (x <= -3.2e-24) tmp = t_0; elseif (x <= 8.2e-63) tmp = abs(Float64(4.0 / y)); elseif ((x <= 3.4e+15) || !(x <= 6.8e+106)) tmp = t_0; else tmp = t_1; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((z / (y / x))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -3.05e+230) tmp = abs((z * (x / y))); elseif (x <= -1.4e+132) tmp = t_1; elseif (x <= -3.2e-24) tmp = t_0; elseif (x <= 8.2e-63) tmp = abs((4.0 / y)); elseif ((x <= 3.4e+15) || ~((x <= 6.8e+106))) 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[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.05e+230], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -1.4e+132], t$95$1, If[LessEqual[x, -3.2e-24], t$95$0, If[LessEqual[x, 8.2e-63], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 3.4e+15], N[Not[LessEqual[x, 6.8e+106]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -3.05 \cdot 10^{+230}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+15} \lor \neg \left(x \leq 6.8 \cdot 10^{+106}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.04999999999999995e230Initial program 85.7%
Simplified82.1%
Taylor expanded in z around inf 46.6%
*-commutative46.6%
associate-*l/86.3%
*-commutative86.3%
Simplified86.3%
if -3.04999999999999995e230 < x < -1.4e132 or 3.4e15 < x < 6.79999999999999989e106Initial program 83.7%
associate-*l/84.1%
sub-div94.9%
Applied egg-rr94.9%
Taylor expanded in x around inf 94.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 83.0%
if -1.4e132 < x < -3.20000000000000012e-24 or 8.1999999999999995e-63 < x < 3.4e15 or 6.79999999999999989e106 < x Initial program 89.6%
Simplified91.2%
Taylor expanded in z around inf 51.5%
*-commutative51.5%
associate-*l/68.2%
*-commutative68.2%
Simplified68.2%
clear-num68.2%
un-div-inv68.3%
Applied egg-rr68.3%
if -3.20000000000000012e-24 < x < 8.1999999999999995e-63Initial program 94.4%
Taylor expanded in x around 0 79.6%
Final simplification77.2%
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 -1.4e+265)
t_0
(if (<= x -2.1e+233)
t_1
(if (<= x -1.3e+131)
t_0
(if (<= x -7.6e-25)
t_1
(if (<= x 6e-63)
(fabs (/ 4.0 y))
(if (<= x 510000000000.0) 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 <= -1.4e+265) {
tmp = t_0;
} else if (x <= -2.1e+233) {
tmp = t_1;
} else if (x <= -1.3e+131) {
tmp = t_0;
} else if (x <= -7.6e-25) {
tmp = t_1;
} else if (x <= 6e-63) {
tmp = fabs((4.0 / y));
} else if (x <= 510000000000.0) {
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 <= (-1.4d+265)) then
tmp = t_0
else if (x <= (-2.1d+233)) then
tmp = t_1
else if (x <= (-1.3d+131)) then
tmp = t_0
else if (x <= (-7.6d-25)) then
tmp = t_1
else if (x <= 6d-63) then
tmp = abs((4.0d0 / y))
else if (x <= 510000000000.0d0) 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 <= -1.4e+265) {
tmp = t_0;
} else if (x <= -2.1e+233) {
tmp = t_1;
} else if (x <= -1.3e+131) {
tmp = t_0;
} else if (x <= -7.6e-25) {
tmp = t_1;
} else if (x <= 6e-63) {
tmp = Math.abs((4.0 / y));
} else if (x <= 510000000000.0) {
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 <= -1.4e+265: tmp = t_0 elif x <= -2.1e+233: tmp = t_1 elif x <= -1.3e+131: tmp = t_0 elif x <= -7.6e-25: tmp = t_1 elif x <= 6e-63: tmp = math.fabs((4.0 / y)) elif x <= 510000000000.0: 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 <= -1.4e+265) tmp = t_0; elseif (x <= -2.1e+233) tmp = t_1; elseif (x <= -1.3e+131) tmp = t_0; elseif (x <= -7.6e-25) tmp = t_1; elseif (x <= 6e-63) tmp = abs(Float64(4.0 / y)); elseif (x <= 510000000000.0) 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 <= -1.4e+265) tmp = t_0; elseif (x <= -2.1e+233) tmp = t_1; elseif (x <= -1.3e+131) tmp = t_0; elseif (x <= -7.6e-25) tmp = t_1; elseif (x <= 6e-63) tmp = abs((4.0 / y)); elseif (x <= 510000000000.0) 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, -1.4e+265], t$95$0, If[LessEqual[x, -2.1e+233], t$95$1, If[LessEqual[x, -1.3e+131], t$95$0, If[LessEqual[x, -7.6e-25], t$95$1, If[LessEqual[x, 6e-63], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 510000000000.0], 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 -1.4 \cdot 10^{+265}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{+233}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{+131}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -7.6 \cdot 10^{-25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-63}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 510000000000:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.39999999999999995e265 or -2.09999999999999997e233 < x < -1.3e131 or 5.1e11 < x Initial program 79.2%
associate-*l/77.3%
sub-div91.9%
Applied egg-rr91.9%
Taylor expanded in x around inf 91.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 78.3%
if -1.39999999999999995e265 < x < -2.09999999999999997e233 or -1.3e131 < x < -7.5999999999999996e-25 or 5.99999999999999959e-63 < x < 5.1e11Initial program 99.8%
Simplified89.3%
Taylor expanded in z around inf 56.2%
associate-*l/64.7%
*-commutative64.7%
Simplified64.7%
if -7.5999999999999996e-25 < x < 5.99999999999999959e-63Initial program 94.4%
Taylor expanded in x around 0 79.6%
Final simplification76.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -2.05e+15) (not (<= x 4.8e+66))) (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 <= -2.05e+15) || !(x <= 4.8e+66)) {
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 <= (-2.05d+15)) .or. (.not. (x <= 4.8d+66))) 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 <= -2.05e+15) || !(x <= 4.8e+66)) {
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 <= -2.05e+15) or not (x <= 4.8e+66): 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 <= -2.05e+15) || !(x <= 4.8e+66)) 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 <= -2.05e+15) || ~((x <= 4.8e+66))) 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, -2.05e+15], N[Not[LessEqual[x, 4.8e+66]], $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 -2.05 \cdot 10^{+15} \lor \neg \left(x \leq 4.8 \cdot 10^{+66}\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 < -2.05e15 or 4.8000000000000003e66 < x Initial program 84.6%
Simplified88.0%
Taylor expanded in x around inf 88.2%
associate-/l*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -2.05e15 < x < 4.8000000000000003e66Initial program 94.9%
associate-*l/99.2%
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 (or (<= z -6e+107) (not (<= z 1e+119))) (fabs (* x (/ z y))) (fabs (/ (- -4.0 x) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+107) || !(z <= 1e+119)) {
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 <= (-6d+107)) .or. (.not. (z <= 1d+119))) 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 <= -6e+107) || !(z <= 1e+119)) {
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 <= -6e+107) or not (z <= 1e+119): 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 <= -6e+107) || !(z <= 1e+119)) 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 <= -6e+107) || ~((z <= 1e+119))) 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, -6e+107], N[Not[LessEqual[z, 1e+119]], $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 -6 \cdot 10^{+107} \lor \neg \left(z \leq 10^{+119}\right):\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -6.00000000000000046e107 or 9.99999999999999944e118 < z Initial program 83.1%
Simplified83.7%
Taylor expanded in z around inf 72.8%
associate-*l/84.1%
*-commutative84.1%
Simplified84.1%
if -6.00000000000000046e107 < z < 9.99999999999999944e118Initial program 93.9%
Simplified99.8%
Taylor expanded in z around 0 90.9%
associate-*r/90.9%
distribute-lft-in90.9%
metadata-eval90.9%
neg-mul-190.9%
sub-neg90.9%
Simplified90.9%
Final simplification88.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((4.0 / y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.55d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -1.55) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -1.55) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.55) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 4 < x Initial program 85.4%
associate-*l/79.3%
sub-div89.5%
Applied egg-rr89.5%
Taylor expanded in x around inf 88.9%
associate-/l*99.2%
Simplified99.2%
Taylor expanded in z around 0 65.8%
if -1.55000000000000004 < x < 4Initial program 95.1%
Taylor expanded in x around 0 73.8%
Final simplification70.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.7%
Taylor expanded in x around 0 42.4%
Final simplification42.4%
herbie shell --seed 2023202
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))