
(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 0.008) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ x (/ y z)) (/ (+ x 4.0) y)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (y <= 0.008) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((x / (y / z)) - ((x + 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 (y <= 0.008d0) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((x / (y / z)) - ((x + 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 (y <= 0.008) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((x / (y / z)) - ((x + 4.0) / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if y <= 0.008: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((x / (y / z)) - ((x + 4.0) / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (y <= 0.008) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(x / Float64(y / z)) - Float64(Float64(x + 4.0) / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.008) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((x / (y / z)) - ((x + 4.0) / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, 0.008], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.008:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}} - \frac{x + 4}{y}\right|\\
\end{array}
\end{array}
if y < 0.0080000000000000002Initial program 90.6%
associate-*l/92.7%
sub-div98.0%
Applied egg-rr98.0%
if 0.0080000000000000002 < y Initial program 94.2%
Simplified99.9%
Final simplification98.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))) (t_2 (fabs (/ 4.0 y))))
(if (<= x -3.4e+176)
t_1
(if (<= x -2.8e+153)
t_0
(if (<= x -10.2)
t_1
(if (<= x 1.35e-134)
t_2
(if (<= x 5e-114)
t_0
(if (<= x 2.5e-82) t_2 (if (<= x 2050.0) 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 t_2 = fabs((4.0 / y));
double tmp;
if (x <= -3.4e+176) {
tmp = t_1;
} else if (x <= -2.8e+153) {
tmp = t_0;
} else if (x <= -10.2) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5e-114) {
tmp = t_0;
} else if (x <= 2.5e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
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) :: t_2
real(8) :: tmp
t_0 = abs((x * (z / y)))
t_1 = abs((x / y))
t_2 = abs((4.0d0 / y))
if (x <= (-3.4d+176)) then
tmp = t_1
else if (x <= (-2.8d+153)) then
tmp = t_0
else if (x <= (-10.2d0)) then
tmp = t_1
else if (x <= 1.35d-134) then
tmp = t_2
else if (x <= 5d-114) then
tmp = t_0
else if (x <= 2.5d-82) then
tmp = t_2
else if (x <= 2050.0d0) 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 t_2 = Math.abs((4.0 / y));
double tmp;
if (x <= -3.4e+176) {
tmp = t_1;
} else if (x <= -2.8e+153) {
tmp = t_0;
} else if (x <= -10.2) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5e-114) {
tmp = t_0;
} else if (x <= 2.5e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
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)) t_2 = math.fabs((4.0 / y)) tmp = 0 if x <= -3.4e+176: tmp = t_1 elif x <= -2.8e+153: tmp = t_0 elif x <= -10.2: tmp = t_1 elif x <= 1.35e-134: tmp = t_2 elif x <= 5e-114: tmp = t_0 elif x <= 2.5e-82: tmp = t_2 elif x <= 2050.0: 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)) t_2 = abs(Float64(4.0 / y)) tmp = 0.0 if (x <= -3.4e+176) tmp = t_1; elseif (x <= -2.8e+153) tmp = t_0; elseif (x <= -10.2) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5e-114) tmp = t_0; elseif (x <= 2.5e-82) tmp = t_2; elseif (x <= 2050.0) 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)); t_2 = abs((4.0 / y)); tmp = 0.0; if (x <= -3.4e+176) tmp = t_1; elseif (x <= -2.8e+153) tmp = t_0; elseif (x <= -10.2) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5e-114) tmp = t_0; elseif (x <= 2.5e-82) tmp = t_2; elseif (x <= 2050.0) 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]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.4e+176], t$95$1, If[LessEqual[x, -2.8e+153], t$95$0, If[LessEqual[x, -10.2], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5e-114], t$95$0, If[LessEqual[x, 2.5e-82], t$95$2, If[LessEqual[x, 2050.0], 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|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{+176}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -10.2:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-82}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.40000000000000014e176 or -2.79999999999999985e153 < x < -10.199999999999999 or 2050 < x Initial program 86.3%
Taylor expanded in x around inf 84.4%
Taylor expanded in z around 0 75.2%
if -3.40000000000000014e176 < x < -2.79999999999999985e153 or 1.3499999999999999e-134 < x < 4.99999999999999989e-114 or 2.4999999999999999e-82 < x < 2050Initial program 99.8%
Taylor expanded in z around inf 79.5%
mul-1-neg79.5%
associate-*r/81.6%
distribute-rgt-neg-out81.6%
distribute-neg-frac81.6%
Simplified81.6%
associate-*r/79.5%
distribute-rgt-neg-in79.5%
distribute-neg-frac79.5%
associate-*l/83.1%
distribute-rgt-neg-in83.1%
add-sqr-sqrt47.9%
sqrt-unprod46.3%
sqr-neg46.3%
sqrt-unprod34.9%
add-sqr-sqrt83.1%
expm1-log1p-u52.6%
expm1-udef38.4%
Applied egg-rr38.4%
expm1-def52.6%
expm1-log1p81.6%
Simplified81.6%
if -10.199999999999999 < x < 1.3499999999999999e-134 or 4.99999999999999989e-114 < x < 2.4999999999999999e-82Initial program 95.8%
Taylor expanded in x around 0 82.5%
Final simplification78.8%
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))) (t_2 (fabs (/ 4.0 y))))
(if (<= x -4.7e+176)
t_1
(if (<= x -1.8e+156)
t_0
(if (<= x -10.5)
t_1
(if (<= x 1.35e-134)
t_2
(if (<= x 5e-114)
t_0
(if (<= x 8e-82)
t_2
(if (<= x 2050.0) (fabs (/ x (/ y z))) 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 t_2 = fabs((4.0 / y));
double tmp;
if (x <= -4.7e+176) {
tmp = t_1;
} else if (x <= -1.8e+156) {
tmp = t_0;
} else if (x <= -10.5) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5e-114) {
tmp = t_0;
} else if (x <= 8e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
tmp = fabs((x / (y / z)));
} 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) :: t_2
real(8) :: tmp
t_0 = abs((x * (z / y)))
t_1 = abs((x / y))
t_2 = abs((4.0d0 / y))
if (x <= (-4.7d+176)) then
tmp = t_1
else if (x <= (-1.8d+156)) then
tmp = t_0
else if (x <= (-10.5d0)) then
tmp = t_1
else if (x <= 1.35d-134) then
tmp = t_2
else if (x <= 5d-114) then
tmp = t_0
else if (x <= 8d-82) then
tmp = t_2
else if (x <= 2050.0d0) then
tmp = abs((x / (y / z)))
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 t_2 = Math.abs((4.0 / y));
double tmp;
if (x <= -4.7e+176) {
tmp = t_1;
} else if (x <= -1.8e+156) {
tmp = t_0;
} else if (x <= -10.5) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5e-114) {
tmp = t_0;
} else if (x <= 8e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
tmp = Math.abs((x / (y / z)));
} 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)) t_2 = math.fabs((4.0 / y)) tmp = 0 if x <= -4.7e+176: tmp = t_1 elif x <= -1.8e+156: tmp = t_0 elif x <= -10.5: tmp = t_1 elif x <= 1.35e-134: tmp = t_2 elif x <= 5e-114: tmp = t_0 elif x <= 8e-82: tmp = t_2 elif x <= 2050.0: tmp = math.fabs((x / (y / z))) 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)) t_2 = abs(Float64(4.0 / y)) tmp = 0.0 if (x <= -4.7e+176) tmp = t_1; elseif (x <= -1.8e+156) tmp = t_0; elseif (x <= -10.5) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5e-114) tmp = t_0; elseif (x <= 8e-82) tmp = t_2; elseif (x <= 2050.0) tmp = abs(Float64(x / Float64(y / z))); 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)); t_2 = abs((4.0 / y)); tmp = 0.0; if (x <= -4.7e+176) tmp = t_1; elseif (x <= -1.8e+156) tmp = t_0; elseif (x <= -10.5) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5e-114) tmp = t_0; elseif (x <= 8e-82) tmp = t_2; elseif (x <= 2050.0) tmp = abs((x / (y / z))); 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]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.7e+176], t$95$1, If[LessEqual[x, -1.8e+156], t$95$0, If[LessEqual[x, -10.5], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5e-114], t$95$0, If[LessEqual[x, 8e-82], t$95$2, If[LessEqual[x, 2050.0], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+176}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{+156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -10.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-82}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -4.69999999999999981e176 or -1.79999999999999989e156 < x < -10.5 or 2050 < x Initial program 86.3%
Taylor expanded in x around inf 84.4%
Taylor expanded in z around 0 75.2%
if -4.69999999999999981e176 < x < -1.79999999999999989e156 or 1.3499999999999999e-134 < x < 4.99999999999999989e-114Initial program 99.9%
Taylor expanded in z around inf 85.2%
mul-1-neg85.2%
associate-*r/92.7%
distribute-rgt-neg-out92.7%
distribute-neg-frac92.7%
Simplified92.7%
associate-*r/85.2%
distribute-rgt-neg-in85.2%
distribute-neg-frac85.2%
associate-*l/92.6%
distribute-rgt-neg-in92.6%
add-sqr-sqrt61.5%
sqrt-unprod48.2%
sqr-neg48.2%
sqrt-unprod30.8%
add-sqr-sqrt92.6%
expm1-log1p-u60.2%
expm1-udef46.8%
Applied egg-rr46.8%
expm1-def60.3%
expm1-log1p92.7%
Simplified92.7%
if -10.5 < x < 1.3499999999999999e-134 or 4.99999999999999989e-114 < x < 8e-82Initial program 95.8%
Taylor expanded in x around 0 82.5%
if 8e-82 < x < 2050Initial program 99.6%
Taylor expanded in z around inf 73.8%
mul-1-neg73.8%
associate-*r/70.6%
distribute-rgt-neg-out70.6%
distribute-neg-frac70.6%
Simplified70.6%
clear-num70.6%
un-div-inv73.8%
add-sqr-sqrt34.0%
sqrt-unprod44.4%
sqr-neg44.4%
sqrt-unprod39.1%
add-sqr-sqrt73.8%
Applied egg-rr73.8%
Final simplification79.0%
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))) (t_2 (fabs (/ 4.0 y))))
(if (<= x -2.15e+200)
t_1
(if (<= x -1.35e+156)
t_0
(if (<= x -10.5)
t_1
(if (<= x 1.35e-134)
t_2
(if (<= x 5.8e-114)
(fabs (* x (/ z y)))
(if (<= x 4.4e-82) t_2 (if (<= x 2050.0) 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 t_2 = fabs((4.0 / y));
double tmp;
if (x <= -2.15e+200) {
tmp = t_1;
} else if (x <= -1.35e+156) {
tmp = t_0;
} else if (x <= -10.5) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5.8e-114) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.4e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
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) :: t_2
real(8) :: tmp
t_0 = abs((z / (y / x)))
t_1 = abs((x / y))
t_2 = abs((4.0d0 / y))
if (x <= (-2.15d+200)) then
tmp = t_1
else if (x <= (-1.35d+156)) then
tmp = t_0
else if (x <= (-10.5d0)) then
tmp = t_1
else if (x <= 1.35d-134) then
tmp = t_2
else if (x <= 5.8d-114) then
tmp = abs((x * (z / y)))
else if (x <= 4.4d-82) then
tmp = t_2
else if (x <= 2050.0d0) 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 t_2 = Math.abs((4.0 / y));
double tmp;
if (x <= -2.15e+200) {
tmp = t_1;
} else if (x <= -1.35e+156) {
tmp = t_0;
} else if (x <= -10.5) {
tmp = t_1;
} else if (x <= 1.35e-134) {
tmp = t_2;
} else if (x <= 5.8e-114) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.4e-82) {
tmp = t_2;
} else if (x <= 2050.0) {
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)) t_2 = math.fabs((4.0 / y)) tmp = 0 if x <= -2.15e+200: tmp = t_1 elif x <= -1.35e+156: tmp = t_0 elif x <= -10.5: tmp = t_1 elif x <= 1.35e-134: tmp = t_2 elif x <= 5.8e-114: tmp = math.fabs((x * (z / y))) elif x <= 4.4e-82: tmp = t_2 elif x <= 2050.0: 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)) t_2 = abs(Float64(4.0 / y)) tmp = 0.0 if (x <= -2.15e+200) tmp = t_1; elseif (x <= -1.35e+156) tmp = t_0; elseif (x <= -10.5) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5.8e-114) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.4e-82) tmp = t_2; elseif (x <= 2050.0) 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)); t_2 = abs((4.0 / y)); tmp = 0.0; if (x <= -2.15e+200) tmp = t_1; elseif (x <= -1.35e+156) tmp = t_0; elseif (x <= -10.5) tmp = t_1; elseif (x <= 1.35e-134) tmp = t_2; elseif (x <= 5.8e-114) tmp = abs((x * (z / y))); elseif (x <= 4.4e-82) tmp = t_2; elseif (x <= 2050.0) 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]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.15e+200], t$95$1, If[LessEqual[x, -1.35e+156], t$95$0, If[LessEqual[x, -10.5], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5.8e-114], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.4e-82], t$95$2, If[LessEqual[x, 2050.0], 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|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{+200}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.35 \cdot 10^{+156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -10.5:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-114}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-82}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -2.15000000000000016e200 or -1.35e156 < x < -10.5 or 2050 < x Initial program 88.1%
Taylor expanded in x around inf 86.2%
Taylor expanded in z around 0 74.7%
if -2.15000000000000016e200 < x < -1.35e156 or 4.39999999999999971e-82 < x < 2050Initial program 87.8%
Taylor expanded in z around inf 63.9%
mul-1-neg63.9%
associate-*r/66.1%
distribute-rgt-neg-out66.1%
distribute-neg-frac66.1%
Simplified66.1%
associate-*r/63.9%
distribute-rgt-neg-in63.9%
distribute-neg-frac63.9%
associate-*l/86.2%
*-commutative86.2%
distribute-lft-neg-in86.2%
add-sqr-sqrt41.8%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-unprod44.2%
add-sqr-sqrt86.2%
clear-num86.2%
un-div-inv86.4%
Applied egg-rr86.4%
if -10.5 < x < 1.3499999999999999e-134 or 5.79999999999999993e-114 < x < 4.39999999999999971e-82Initial program 95.8%
Taylor expanded in x around 0 82.5%
if 1.3499999999999999e-134 < x < 5.79999999999999993e-114Initial program 99.8%
Taylor expanded in z around inf 86.5%
mul-1-neg86.5%
associate-*r/86.5%
distribute-rgt-neg-out86.5%
distribute-neg-frac86.5%
Simplified86.5%
associate-*r/86.5%
distribute-rgt-neg-in86.5%
distribute-neg-frac86.5%
associate-*l/86.3%
distribute-rgt-neg-in86.3%
add-sqr-sqrt71.6%
sqrt-unprod17.6%
sqr-neg17.6%
sqrt-unprod14.3%
add-sqr-sqrt86.3%
expm1-log1p-u70.4%
expm1-udef45.5%
Applied egg-rr45.5%
expm1-def70.5%
expm1-log1p86.5%
Simplified86.5%
Final simplification79.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x 1e+18) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (* (/ x y) (- 1.0 z)))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= 1e+18) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((x / y) * (1.0 - 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 (x <= 1d+18) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((x / y) * (1.0d0 - z)))
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+18) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((x / y) * (1.0 - z)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= 1e+18: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((x / y) * (1.0 - z))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (x <= 1e+18) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1e+18) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((x / y) * (1.0 - z))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, 1e+18], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+18}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\end{array}
\end{array}
if x < 1e18Initial program 93.5%
associate-*l/97.3%
sub-div99.4%
Applied egg-rr99.4%
if 1e18 < x Initial program 85.9%
Taylor expanded in x around inf 85.9%
*-un-lft-identity85.9%
*-commutative85.9%
distribute-rgt-out--99.9%
Applied egg-rr99.9%
Final simplification99.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -4.5e+94) (fabs (* x (/ z y))) (if (<= z 1.9e+102) (fabs (/ (- -4.0 x) y)) (fabs (/ x (/ y z))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+94) {
tmp = fabs((x * (z / y)));
} else if (z <= 1.9e+102) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((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 (z <= (-4.5d+94)) then
tmp = abs((x * (z / y)))
else if (z <= 1.9d+102) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((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 (z <= -4.5e+94) {
tmp = Math.abs((x * (z / y)));
} else if (z <= 1.9e+102) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -4.5e+94: tmp = math.fabs((x * (z / y))) elif z <= 1.9e+102: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x / (y / z))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -4.5e+94) tmp = abs(Float64(x * Float64(z / y))); elseif (z <= 1.9e+102) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.5e+94) tmp = abs((x * (z / y))); elseif (z <= 1.9e+102) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -4.5e+94], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.9e+102], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+94}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+102}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -4.49999999999999972e94Initial program 94.9%
Taylor expanded in z around inf 83.1%
mul-1-neg83.1%
associate-*r/84.9%
distribute-rgt-neg-out84.9%
distribute-neg-frac84.9%
Simplified84.9%
associate-*r/83.1%
distribute-rgt-neg-in83.1%
distribute-neg-frac83.1%
associate-*l/79.8%
distribute-rgt-neg-in79.8%
add-sqr-sqrt79.6%
sqrt-unprod55.7%
sqr-neg55.7%
sqrt-unprod0.0%
add-sqr-sqrt79.8%
expm1-log1p-u42.7%
expm1-udef34.5%
Applied egg-rr34.5%
expm1-def47.8%
expm1-log1p84.9%
Simplified84.9%
if -4.49999999999999972e94 < z < 1.89999999999999989e102Initial program 93.3%
Simplified99.4%
Taylor expanded in z around 0 94.8%
associate-*r/94.8%
distribute-lft-in94.8%
metadata-eval94.8%
neg-mul-194.8%
sub-neg94.8%
Simplified94.8%
if 1.89999999999999989e102 < z Initial program 80.0%
Taylor expanded in z around inf 76.5%
mul-1-neg76.5%
associate-*r/88.3%
distribute-rgt-neg-out88.3%
distribute-neg-frac88.3%
Simplified88.3%
clear-num88.2%
un-div-inv89.4%
add-sqr-sqrt0.0%
sqrt-unprod52.3%
sqr-neg52.3%
sqrt-unprod89.2%
add-sqr-sqrt89.4%
Applied egg-rr89.4%
Final simplification92.0%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -10.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 <= -10.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 <= (-10.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 <= -10.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 <= -10.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 <= -10.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 <= -10.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, -10.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 -10.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 < -10.5 or 4 < x Initial program 86.9%
Taylor expanded in x around inf 85.1%
Taylor expanded in z around 0 72.0%
if -10.5 < x < 4Initial program 96.4%
Taylor expanded in x around 0 73.3%
Final simplification72.6%
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 91.6%
Taylor expanded in x around 0 38.7%
Final simplification38.7%
herbie shell --seed 2023299
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))