
(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}
(FPCore (x y z)
:precision binary64
(if (<= x -7e+78)
(fabs (* (- 1.0 z) (/ x y)))
(if (<= x 2e+20)
(fabs (/ (- (+ 4.0 x) (* x z)) y))
(fabs (/ x (/ y (- 1.0 z)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e+78) {
tmp = fabs(((1.0 - z) * (x / y)));
} else if (x <= 2e+20) {
tmp = fabs((((4.0 + x) - (x * z)) / y));
} else {
tmp = fabs((x / (y / (1.0 - z))));
}
return tmp;
}
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 <= (-7d+78)) then
tmp = abs(((1.0d0 - z) * (x / y)))
else if (x <= 2d+20) then
tmp = abs((((4.0d0 + x) - (x * z)) / y))
else
tmp = abs((x / (y / (1.0d0 - z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -7e+78) {
tmp = Math.abs(((1.0 - z) * (x / y)));
} else if (x <= 2e+20) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y));
} else {
tmp = Math.abs((x / (y / (1.0 - z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7e+78: tmp = math.fabs(((1.0 - z) * (x / y))) elif x <= 2e+20: tmp = math.fabs((((4.0 + x) - (x * z)) / y)) else: tmp = math.fabs((x / (y / (1.0 - z)))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7e+78) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); elseif (x <= 2e+20) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y)); else tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7e+78) tmp = abs(((1.0 - z) * (x / y))); elseif (x <= 2e+20) tmp = abs((((4.0 + x) - (x * z)) / y)); else tmp = abs((x / (y / (1.0 - z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7e+78], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2e+20], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+78}:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+20}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\end{array}
\end{array}
if x < -7.0000000000000003e78Initial program 77.7%
Taylor expanded in y around 0 85.4%
Taylor expanded in x around inf 85.4%
*-rgt-identity85.4%
associate-*r/85.3%
*-commutative85.3%
associate-*l*99.8%
associate-*r/100.0%
*-rgt-identity100.0%
Simplified100.0%
if -7.0000000000000003e78 < x < 2e20Initial program 94.6%
Taylor expanded in y around 0 99.9%
if 2e20 < x Initial program 84.7%
associate-*l/77.8%
sub-div86.9%
clear-num86.6%
associate--l+86.6%
Applied egg-rr86.6%
Taylor expanded in x around inf 86.9%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 5e-11) (fabs (/ (- (+ 4.0 x) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-11) {
tmp = fabs((((4.0 + x) - (x * z)) / y));
} else {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5e-11) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y)); else tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5e-11], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 5.00000000000000018e-11Initial program 85.6%
Taylor expanded in y around 0 94.3%
if 5.00000000000000018e-11 < y Initial program 98.5%
Simplified99.9%
Final simplification95.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ x y))) (t_2 (fabs (* x (/ z y)))))
(if (<= x -1.8e+60)
t_1
(if (<= x -2.3e-15)
t_2
(if (<= x 3.8e-97)
t_0
(if (<= x 3.75e-62)
t_2
(if (<= x 4.0) t_0 (if (<= x 5.8e+268) t_1 t_2))))))))
double code(double x, double y, double z) {
double t_0 = fabs((4.0 / y));
double t_1 = fabs((x / y));
double t_2 = fabs((x * (z / y)));
double tmp;
if (x <= -1.8e+60) {
tmp = t_1;
} else if (x <= -2.3e-15) {
tmp = t_2;
} else if (x <= 3.8e-97) {
tmp = t_0;
} else if (x <= 3.75e-62) {
tmp = t_2;
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 5.8e+268) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
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((4.0d0 / y))
t_1 = abs((x / y))
t_2 = abs((x * (z / y)))
if (x <= (-1.8d+60)) then
tmp = t_1
else if (x <= (-2.3d-15)) then
tmp = t_2
else if (x <= 3.8d-97) then
tmp = t_0
else if (x <= 3.75d-62) then
tmp = t_2
else if (x <= 4.0d0) then
tmp = t_0
else if (x <= 5.8d+268) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((4.0 / y));
double t_1 = Math.abs((x / y));
double t_2 = Math.abs((x * (z / y)));
double tmp;
if (x <= -1.8e+60) {
tmp = t_1;
} else if (x <= -2.3e-15) {
tmp = t_2;
} else if (x <= 3.8e-97) {
tmp = t_0;
} else if (x <= 3.75e-62) {
tmp = t_2;
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 5.8e+268) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((4.0 / y)) t_1 = math.fabs((x / y)) t_2 = math.fabs((x * (z / y))) tmp = 0 if x <= -1.8e+60: tmp = t_1 elif x <= -2.3e-15: tmp = t_2 elif x <= 3.8e-97: tmp = t_0 elif x <= 3.75e-62: tmp = t_2 elif x <= 4.0: tmp = t_0 elif x <= 5.8e+268: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = abs(Float64(4.0 / y)) t_1 = abs(Float64(x / y)) t_2 = abs(Float64(x * Float64(z / y))) tmp = 0.0 if (x <= -1.8e+60) tmp = t_1; elseif (x <= -2.3e-15) tmp = t_2; elseif (x <= 3.8e-97) tmp = t_0; elseif (x <= 3.75e-62) tmp = t_2; elseif (x <= 4.0) tmp = t_0; elseif (x <= 5.8e+268) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((4.0 / y)); t_1 = abs((x / y)); t_2 = abs((x * (z / y))); tmp = 0.0; if (x <= -1.8e+60) tmp = t_1; elseif (x <= -2.3e-15) tmp = t_2; elseif (x <= 3.8e-97) tmp = t_0; elseif (x <= 3.75e-62) tmp = t_2; elseif (x <= 4.0) tmp = t_0; elseif (x <= 5.8e+268) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.8e+60], t$95$1, If[LessEqual[x, -2.3e-15], t$95$2, If[LessEqual[x, 3.8e-97], t$95$0, If[LessEqual[x, 3.75e-62], t$95$2, If[LessEqual[x, 4.0], t$95$0, If[LessEqual[x, 5.8e+268], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
t_2 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+60}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-15}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.75 \cdot 10^{-62}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+268}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -1.79999999999999984e60 or 4 < x < 5.8000000000000002e268Initial program 83.1%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in x around inf 72.5%
if -1.79999999999999984e60 < x < -2.2999999999999999e-15 or 3.8000000000000001e-97 < x < 3.75000000000000015e-62 or 5.8000000000000002e268 < x Initial program 87.5%
Taylor expanded in z around inf 63.8%
mul-1-neg63.8%
associate-*l/78.6%
distribute-rgt-neg-out78.6%
Simplified78.6%
clear-num78.4%
associate-*l/78.5%
*-un-lft-identity78.5%
add-sqr-sqrt37.2%
sqrt-unprod57.4%
sqr-neg57.4%
sqrt-unprod41.3%
add-sqr-sqrt78.5%
Applied egg-rr78.5%
associate-/r/78.6%
Applied egg-rr78.6%
if -2.2999999999999999e-15 < x < 3.8000000000000001e-97 or 3.75000000000000015e-62 < x < 4Initial program 95.7%
Taylor expanded in x around 0 79.2%
Final simplification76.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ x y))) (t_2 (fabs (* x (/ z y)))))
(if (<= x -6.8e+59)
t_1
(if (<= x -1.66e-16)
(fabs (/ x (/ y z)))
(if (<= x 3.8e-97)
t_0
(if (<= x 3.2e-62)
t_2
(if (<= x 4.0) t_0 (if (<= x 5.6e+268) t_1 t_2))))))))
double code(double x, double y, double z) {
double t_0 = fabs((4.0 / y));
double t_1 = fabs((x / y));
double t_2 = fabs((x * (z / y)));
double tmp;
if (x <= -6.8e+59) {
tmp = t_1;
} else if (x <= -1.66e-16) {
tmp = fabs((x / (y / z)));
} else if (x <= 3.8e-97) {
tmp = t_0;
} else if (x <= 3.2e-62) {
tmp = t_2;
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 5.6e+268) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
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((4.0d0 / y))
t_1 = abs((x / y))
t_2 = abs((x * (z / y)))
if (x <= (-6.8d+59)) then
tmp = t_1
else if (x <= (-1.66d-16)) then
tmp = abs((x / (y / z)))
else if (x <= 3.8d-97) then
tmp = t_0
else if (x <= 3.2d-62) then
tmp = t_2
else if (x <= 4.0d0) then
tmp = t_0
else if (x <= 5.6d+268) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((4.0 / y));
double t_1 = Math.abs((x / y));
double t_2 = Math.abs((x * (z / y)));
double tmp;
if (x <= -6.8e+59) {
tmp = t_1;
} else if (x <= -1.66e-16) {
tmp = Math.abs((x / (y / z)));
} else if (x <= 3.8e-97) {
tmp = t_0;
} else if (x <= 3.2e-62) {
tmp = t_2;
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 5.6e+268) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((4.0 / y)) t_1 = math.fabs((x / y)) t_2 = math.fabs((x * (z / y))) tmp = 0 if x <= -6.8e+59: tmp = t_1 elif x <= -1.66e-16: tmp = math.fabs((x / (y / z))) elif x <= 3.8e-97: tmp = t_0 elif x <= 3.2e-62: tmp = t_2 elif x <= 4.0: tmp = t_0 elif x <= 5.6e+268: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = abs(Float64(4.0 / y)) t_1 = abs(Float64(x / y)) t_2 = abs(Float64(x * Float64(z / y))) tmp = 0.0 if (x <= -6.8e+59) tmp = t_1; elseif (x <= -1.66e-16) tmp = abs(Float64(x / Float64(y / z))); elseif (x <= 3.8e-97) tmp = t_0; elseif (x <= 3.2e-62) tmp = t_2; elseif (x <= 4.0) tmp = t_0; elseif (x <= 5.6e+268) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((4.0 / y)); t_1 = abs((x / y)); t_2 = abs((x * (z / y))); tmp = 0.0; if (x <= -6.8e+59) tmp = t_1; elseif (x <= -1.66e-16) tmp = abs((x / (y / z))); elseif (x <= 3.8e-97) tmp = t_0; elseif (x <= 3.2e-62) tmp = t_2; elseif (x <= 4.0) tmp = t_0; elseif (x <= 5.6e+268) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.8e+59], t$95$1, If[LessEqual[x, -1.66e-16], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.8e-97], t$95$0, If[LessEqual[x, 3.2e-62], t$95$2, If[LessEqual[x, 4.0], t$95$0, If[LessEqual[x, 5.6e+268], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
t_2 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{+59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.66 \cdot 10^{-16}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-62}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+268}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -6.80000000000000012e59 or 4 < x < 5.5999999999999999e268Initial program 83.1%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in x around inf 72.5%
if -6.80000000000000012e59 < x < -1.6600000000000001e-16Initial program 91.4%
Taylor expanded in z around inf 76.5%
mul-1-neg76.5%
associate-*l/76.4%
distribute-rgt-neg-out76.4%
Simplified76.4%
associate-*l/76.5%
associate-/l*76.5%
add-sqr-sqrt24.9%
sqrt-unprod44.5%
sqr-neg44.5%
sqrt-unprod51.1%
add-sqr-sqrt76.5%
Applied egg-rr76.5%
if -1.6600000000000001e-16 < x < 3.8000000000000001e-97 or 3.20000000000000021e-62 < x < 4Initial program 95.7%
Taylor expanded in x around 0 79.2%
if 3.8000000000000001e-97 < x < 3.20000000000000021e-62 or 5.5999999999999999e268 < x Initial program 85.2%
Taylor expanded in z around inf 56.1%
mul-1-neg56.1%
associate-*l/79.9%
distribute-rgt-neg-out79.9%
Simplified79.9%
clear-num79.8%
associate-*l/79.8%
*-un-lft-identity79.8%
add-sqr-sqrt44.6%
sqrt-unprod65.1%
sqr-neg65.1%
sqrt-unprod35.4%
add-sqr-sqrt79.8%
Applied egg-rr79.8%
associate-/r/80.0%
Applied egg-rr80.0%
Final simplification76.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ x y))))
(if (<= x -6.5e+59)
t_1
(if (<= x -1.4e-16)
(fabs (/ x (/ y z)))
(if (<= x 3.4e-97)
t_0
(if (<= x 1.22e-61)
(fabs (* x (/ z y)))
(if (<= x 4.0)
t_0
(if (<= x 3.5e+268) t_1 (fabs (/ z (/ y x)))))))))))
double code(double x, double y, double z) {
double t_0 = fabs((4.0 / y));
double t_1 = fabs((x / y));
double tmp;
if (x <= -6.5e+59) {
tmp = t_1;
} else if (x <= -1.4e-16) {
tmp = fabs((x / (y / z)));
} else if (x <= 3.4e-97) {
tmp = t_0;
} else if (x <= 1.22e-61) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 3.5e+268) {
tmp = t_1;
} else {
tmp = fabs((z / (y / x)));
}
return tmp;
}
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((4.0d0 / y))
t_1 = abs((x / y))
if (x <= (-6.5d+59)) then
tmp = t_1
else if (x <= (-1.4d-16)) then
tmp = abs((x / (y / z)))
else if (x <= 3.4d-97) then
tmp = t_0
else if (x <= 1.22d-61) then
tmp = abs((x * (z / y)))
else if (x <= 4.0d0) then
tmp = t_0
else if (x <= 3.5d+268) then
tmp = t_1
else
tmp = abs((z / (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((4.0 / y));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -6.5e+59) {
tmp = t_1;
} else if (x <= -1.4e-16) {
tmp = Math.abs((x / (y / z)));
} else if (x <= 3.4e-97) {
tmp = t_0;
} else if (x <= 1.22e-61) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.0) {
tmp = t_0;
} else if (x <= 3.5e+268) {
tmp = t_1;
} else {
tmp = Math.abs((z / (y / x)));
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((4.0 / y)) t_1 = math.fabs((x / y)) tmp = 0 if x <= -6.5e+59: tmp = t_1 elif x <= -1.4e-16: tmp = math.fabs((x / (y / z))) elif x <= 3.4e-97: tmp = t_0 elif x <= 1.22e-61: tmp = math.fabs((x * (z / y))) elif x <= 4.0: tmp = t_0 elif x <= 3.5e+268: tmp = t_1 else: tmp = math.fabs((z / (y / x))) return tmp
function code(x, y, z) t_0 = abs(Float64(4.0 / y)) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -6.5e+59) tmp = t_1; elseif (x <= -1.4e-16) tmp = abs(Float64(x / Float64(y / z))); elseif (x <= 3.4e-97) tmp = t_0; elseif (x <= 1.22e-61) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.0) tmp = t_0; elseif (x <= 3.5e+268) tmp = t_1; else tmp = abs(Float64(z / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((4.0 / y)); t_1 = abs((x / y)); tmp = 0.0; if (x <= -6.5e+59) tmp = t_1; elseif (x <= -1.4e-16) tmp = abs((x / (y / z))); elseif (x <= 3.4e-97) tmp = t_0; elseif (x <= 1.22e-61) tmp = abs((x * (z / y))); elseif (x <= 4.0) tmp = t_0; elseif (x <= 3.5e+268) tmp = t_1; else tmp = abs((z / (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e+59], t$95$1, If[LessEqual[x, -1.4e-16], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.4e-97], t$95$0, If[LessEqual[x, 1.22e-61], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], t$95$0, If[LessEqual[x, 3.5e+268], t$95$1, N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-16}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-61}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+268}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if x < -6.50000000000000021e59 or 4 < x < 3.49999999999999972e268Initial program 83.1%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in x around inf 72.5%
if -6.50000000000000021e59 < x < -1.4000000000000001e-16Initial program 91.4%
Taylor expanded in z around inf 76.5%
mul-1-neg76.5%
associate-*l/76.4%
distribute-rgt-neg-out76.4%
Simplified76.4%
associate-*l/76.5%
associate-/l*76.5%
add-sqr-sqrt24.9%
sqrt-unprod44.5%
sqr-neg44.5%
sqrt-unprod51.1%
add-sqr-sqrt76.5%
Applied egg-rr76.5%
if -1.4000000000000001e-16 < x < 3.3999999999999999e-97 or 1.22e-61 < x < 4Initial program 95.7%
Taylor expanded in x around 0 79.2%
if 3.3999999999999999e-97 < x < 1.22e-61Initial program 89.5%
Taylor expanded in z around inf 76.9%
mul-1-neg76.9%
associate-*l/66.3%
distribute-rgt-neg-out66.3%
Simplified66.3%
clear-num66.3%
associate-*l/66.3%
*-un-lft-identity66.3%
add-sqr-sqrt43.1%
sqrt-unprod66.3%
sqr-neg66.3%
sqrt-unprod23.4%
add-sqr-sqrt66.3%
Applied egg-rr66.3%
associate-/r/76.9%
Applied egg-rr76.9%
if 3.49999999999999972e268 < x Initial program 81.7%
Taylor expanded in z around inf 39.2%
mul-1-neg39.2%
associate-*l/91.1%
distribute-rgt-neg-out91.1%
Simplified91.1%
clear-num90.8%
associate-*l/90.9%
*-un-lft-identity90.9%
add-sqr-sqrt45.8%
sqrt-unprod64.1%
sqr-neg64.1%
sqrt-unprod45.2%
add-sqr-sqrt90.9%
Applied egg-rr90.9%
Final simplification76.5%
(FPCore (x y z) :precision binary64 (if (<= z -3.5e+36) (fabs (/ z (/ y x))) (if (<= z 5.5e+41) (fabs (+ (/ x y) (/ 4.0 y))) (fabs (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.5e+36) {
tmp = fabs((z / (y / x)));
} else if (z <= 5.5e+41) {
tmp = fabs(((x / y) + (4.0 / y)));
} else {
tmp = fabs((x / (y / z)));
}
return tmp;
}
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 <= (-3.5d+36)) then
tmp = abs((z / (y / x)))
else if (z <= 5.5d+41) then
tmp = abs(((x / y) + (4.0d0 / y)))
else
tmp = abs((x / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.5e+36) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 5.5e+41) {
tmp = Math.abs(((x / y) + (4.0 / y)));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.5e+36: tmp = math.fabs((z / (y / x))) elif z <= 5.5e+41: tmp = math.fabs(((x / y) + (4.0 / y))) else: tmp = math.fabs((x / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.5e+36) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 5.5e+41) tmp = abs(Float64(Float64(x / y) + Float64(4.0 / y))); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.5e+36) tmp = abs((z / (y / x))); elseif (z <= 5.5e+41) tmp = abs(((x / y) + (4.0 / y))); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.5e+36], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 5.5e+41], N[Abs[N[(N[(x / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+36}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+41}:\\
\;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -3.4999999999999998e36Initial program 97.7%
Taylor expanded in z around inf 63.7%
mul-1-neg63.7%
associate-*l/77.5%
distribute-rgt-neg-out77.5%
Simplified77.5%
clear-num77.5%
associate-*l/77.6%
*-un-lft-identity77.6%
add-sqr-sqrt77.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-unprod0.0%
add-sqr-sqrt77.6%
Applied egg-rr77.6%
if -3.4999999999999998e36 < z < 5.5000000000000003e41Initial program 90.8%
Taylor expanded in z around 0 96.4%
associate-*r/96.4%
metadata-eval96.4%
Simplified96.4%
if 5.5000000000000003e41 < z Initial program 77.2%
Taylor expanded in z around inf 68.1%
mul-1-neg68.1%
associate-*l/71.7%
distribute-rgt-neg-out71.7%
Simplified71.7%
associate-*l/68.1%
associate-/l*79.8%
add-sqr-sqrt0.0%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod79.4%
add-sqr-sqrt79.8%
Applied egg-rr79.8%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.9e+40) (fabs (- (/ x y) (/ z (/ y x)))) (if (<= z 1.1e+41) (fabs (+ (/ x y) (/ 4.0 y))) (fabs (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e+40) {
tmp = fabs(((x / y) - (z / (y / x))));
} else if (z <= 1.1e+41) {
tmp = fabs(((x / y) + (4.0 / y)));
} else {
tmp = fabs((x / (y / z)));
}
return tmp;
}
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.9d+40)) then
tmp = abs(((x / y) - (z / (y / x))))
else if (z <= 1.1d+41) then
tmp = abs(((x / y) + (4.0d0 / y)))
else
tmp = abs((x / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e+40) {
tmp = Math.abs(((x / y) - (z / (y / x))));
} else if (z <= 1.1e+41) {
tmp = Math.abs(((x / y) + (4.0 / y)));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.9e+40: tmp = math.fabs(((x / y) - (z / (y / x)))) elif z <= 1.1e+41: tmp = math.fabs(((x / y) + (4.0 / y))) else: tmp = math.fabs((x / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.9e+40) tmp = abs(Float64(Float64(x / y) - Float64(z / Float64(y / x)))); elseif (z <= 1.1e+41) tmp = abs(Float64(Float64(x / y) + Float64(4.0 / y))); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.9e+40) tmp = abs(((x / y) - (z / (y / x)))); elseif (z <= 1.1e+41) tmp = abs(((x / y) + (4.0 / y))); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.9e+40], N[Abs[N[(N[(x / y), $MachinePrecision] - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.1e+41], N[Abs[N[(N[(x / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+40}:\\
\;\;\;\;\left|\frac{x}{y} - \frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+41}:\\
\;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -1.90000000000000002e40Initial program 97.7%
*-commutative97.7%
clear-num97.6%
un-div-inv97.8%
Applied egg-rr97.8%
Taylor expanded in x around inf 77.6%
if -1.90000000000000002e40 < z < 1.09999999999999995e41Initial program 90.8%
Taylor expanded in z around 0 96.4%
associate-*r/96.4%
metadata-eval96.4%
Simplified96.4%
if 1.09999999999999995e41 < z Initial program 77.2%
Taylor expanded in z around inf 68.1%
mul-1-neg68.1%
associate-*l/71.7%
distribute-rgt-neg-out71.7%
Simplified71.7%
associate-*l/68.1%
associate-/l*79.8%
add-sqr-sqrt0.0%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod79.4%
add-sqr-sqrt79.8%
Applied egg-rr79.8%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.18e+36) (fabs (/ z (/ y x))) (if (<= z 3e+40) (fabs (/ (- -4.0 x) y)) (fabs (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.18e+36) {
tmp = fabs((z / (y / x)));
} else if (z <= 3e+40) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x / (y / z)));
}
return tmp;
}
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.18d+36)) then
tmp = abs((z / (y / x)))
else if (z <= 3d+40) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.18e+36) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 3e+40) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.18e+36: tmp = math.fabs((z / (y / x))) elif z <= 3e+40: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.18e+36) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 3e+40) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.18e+36) tmp = abs((z / (y / x))); elseif (z <= 3e+40) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.18e+36], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3e+40], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.18 \cdot 10^{+36}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+40}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -1.17999999999999997e36Initial program 97.7%
Taylor expanded in z around inf 63.7%
mul-1-neg63.7%
associate-*l/77.5%
distribute-rgt-neg-out77.5%
Simplified77.5%
clear-num77.5%
associate-*l/77.6%
*-un-lft-identity77.6%
add-sqr-sqrt77.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-unprod0.0%
add-sqr-sqrt77.6%
Applied egg-rr77.6%
if -1.17999999999999997e36 < z < 3.0000000000000002e40Initial program 90.8%
Simplified99.3%
Taylor expanded in z around 0 96.4%
associate-*r/96.4%
distribute-lft-in96.4%
metadata-eval96.4%
neg-mul-196.4%
sub-neg96.4%
Simplified96.4%
if 3.0000000000000002e40 < z Initial program 77.2%
Taylor expanded in z around inf 68.1%
mul-1-neg68.1%
associate-*l/71.7%
distribute-rgt-neg-out71.7%
Simplified71.7%
associate-*l/68.1%
associate-/l*79.8%
add-sqr-sqrt0.0%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod79.4%
add-sqr-sqrt79.8%
Applied egg-rr79.8%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 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;
}
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
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;
}
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
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
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
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}
\\
\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 83.1%
Taylor expanded in z around 0 68.7%
associate-*r/68.7%
metadata-eval68.7%
Simplified68.7%
Taylor expanded in x around inf 68.0%
if -1.55000000000000004 < x < 4Initial program 95.4%
Taylor expanded in x around 0 73.0%
Final simplification70.4%
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
double code(double x, double y, double z) {
return fabs((4.0 / y));
}
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
public static double code(double x, double y, double z) {
return Math.abs((4.0 / y));
}
def code(x, y, z): return math.fabs((4.0 / y))
function code(x, y, z) return abs(Float64(4.0 / y)) end
function tmp = code(x, y, z) tmp = abs((4.0 / y)); end
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{4}{y}\right|
\end{array}
Initial program 89.1%
Taylor expanded in x around 0 38.3%
Final simplification38.3%
herbie shell --seed 2023321
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))