
(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 7 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 5e+21) (fabs (/ (- (+ x 4.0) (* x z)) 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 <= 5e+21) {
tmp = fabs((((x + 4.0) - (x * z)) / 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 <= 5e+21) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / 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, 5e+21], N[Abs[N[(N[(N[(x + 4.0), $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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+21}:\\
\;\;\;\;\left|\frac{\left(x + 4\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 < 5e21Initial program 90.6%
associate-*l/90.7%
sub-div97.6%
Applied egg-rr97.6%
if 5e21 < y Initial program 94.5%
fabs-sub94.5%
associate-*l/91.0%
*-commutative91.0%
associate-*l/99.9%
*-commutative99.9%
fma-neg99.9%
distribute-neg-frac99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.1%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* z (/ x y)))) (t_2 (fabs (/ 4.0 y))))
(if (<= z -1e+95)
t_1
(if (<= z -4.5e-28)
t_2
(if (<= z 3.9e-259)
t_0
(if (<= z 7.5e-116)
t_2
(if (<= z 2.3e-12) t_0 (if (<= z 3.2e+60) t_2 t_1))))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((z * (x / y)));
double t_2 = fabs((4.0 / y));
double tmp;
if (z <= -1e+95) {
tmp = t_1;
} else if (z <= -4.5e-28) {
tmp = t_2;
} else if (z <= 3.9e-259) {
tmp = t_0;
} else if (z <= 7.5e-116) {
tmp = t_2;
} else if (z <= 2.3e-12) {
tmp = t_0;
} else if (z <= 3.2e+60) {
tmp = t_2;
} 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 / y))
t_1 = abs((z * (x / y)))
t_2 = abs((4.0d0 / y))
if (z <= (-1d+95)) then
tmp = t_1
else if (z <= (-4.5d-28)) then
tmp = t_2
else if (z <= 3.9d-259) then
tmp = t_0
else if (z <= 7.5d-116) then
tmp = t_2
else if (z <= 2.3d-12) then
tmp = t_0
else if (z <= 3.2d+60) then
tmp = t_2
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 / y));
double t_1 = Math.abs((z * (x / y)));
double t_2 = Math.abs((4.0 / y));
double tmp;
if (z <= -1e+95) {
tmp = t_1;
} else if (z <= -4.5e-28) {
tmp = t_2;
} else if (z <= 3.9e-259) {
tmp = t_0;
} else if (z <= 7.5e-116) {
tmp = t_2;
} else if (z <= 2.3e-12) {
tmp = t_0;
} else if (z <= 3.2e+60) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((z * (x / y))) t_2 = math.fabs((4.0 / y)) tmp = 0 if z <= -1e+95: tmp = t_1 elif z <= -4.5e-28: tmp = t_2 elif z <= 3.9e-259: tmp = t_0 elif z <= 7.5e-116: tmp = t_2 elif z <= 2.3e-12: tmp = t_0 elif z <= 3.2e+60: tmp = t_2 else: tmp = t_1 return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(z * Float64(x / y))) t_2 = abs(Float64(4.0 / y)) tmp = 0.0 if (z <= -1e+95) tmp = t_1; elseif (z <= -4.5e-28) tmp = t_2; elseif (z <= 3.9e-259) tmp = t_0; elseif (z <= 7.5e-116) tmp = t_2; elseif (z <= 2.3e-12) tmp = t_0; elseif (z <= 3.2e+60) tmp = t_2; else tmp = t_1; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((z * (x / y))); t_2 = abs((4.0 / y)); tmp = 0.0; if (z <= -1e+95) tmp = t_1; elseif (z <= -4.5e-28) tmp = t_2; elseif (z <= 3.9e-259) tmp = t_0; elseif (z <= 7.5e-116) tmp = t_2; elseif (z <= 2.3e-12) tmp = t_0; elseif (z <= 3.2e+60) tmp = t_2; 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 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -1e+95], t$95$1, If[LessEqual[z, -4.5e-28], t$95$2, If[LessEqual[z, 3.9e-259], t$95$0, If[LessEqual[z, 7.5e-116], t$95$2, If[LessEqual[z, 2.3e-12], t$95$0, If[LessEqual[z, 3.2e+60], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|z \cdot \frac{x}{y}\right|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;z \leq -1 \cdot 10^{+95}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-28}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{-259}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-116}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+60}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.00000000000000002e95 or 3.19999999999999991e60 < z Initial program 88.5%
Taylor expanded in z around inf 80.2%
*-commutative80.2%
associate-/l*84.4%
associate-/r/82.8%
associate-*r*82.8%
*-commutative82.8%
mul-1-neg82.8%
distribute-frac-neg82.8%
Simplified82.8%
expm1-log1p-u39.0%
expm1-udef31.1%
add-sqr-sqrt15.0%
sqrt-unprod28.2%
sqr-neg28.2%
sqrt-unprod18.7%
add-sqr-sqrt42.0%
Applied egg-rr42.0%
expm1-def49.9%
expm1-log1p82.8%
Simplified82.8%
if -1.00000000000000002e95 < z < -4.4999999999999998e-28 or 3.90000000000000016e-259 < z < 7.5000000000000004e-116 or 2.29999999999999989e-12 < z < 3.19999999999999991e60Initial program 91.6%
Taylor expanded in x around 0 61.6%
if -4.4999999999999998e-28 < z < 3.90000000000000016e-259 or 7.5000000000000004e-116 < z < 2.29999999999999989e-12Initial program 95.0%
Taylor expanded in z around 0 99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 69.1%
Final simplification72.4%
NOTE: y should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (/ 4.0 y))))
(if (<= z -1e+95)
(fabs (* z (/ x y)))
(if (<= z -4.5e-27)
t_1
(if (<= z 3.4e-260)
t_0
(if (<= z 5.2e-117)
t_1
(if (<= z 2.7e-12)
t_0
(if (<= z 3.2e+60) t_1 (fabs (* x (/ z y)))))))))))y = abs(y);
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((4.0 / y));
double tmp;
if (z <= -1e+95) {
tmp = fabs((z * (x / y)));
} else if (z <= -4.5e-27) {
tmp = t_1;
} else if (z <= 3.4e-260) {
tmp = t_0;
} else if (z <= 5.2e-117) {
tmp = t_1;
} else if (z <= 2.7e-12) {
tmp = t_0;
} else if (z <= 3.2e+60) {
tmp = t_1;
} else {
tmp = fabs((x * (z / y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((4.0d0 / y))
if (z <= (-1d+95)) then
tmp = abs((z * (x / y)))
else if (z <= (-4.5d-27)) then
tmp = t_1
else if (z <= 3.4d-260) then
tmp = t_0
else if (z <= 5.2d-117) then
tmp = t_1
else if (z <= 2.7d-12) then
tmp = t_0
else if (z <= 3.2d+60) then
tmp = t_1
else
tmp = abs((x * (z / y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double t_1 = Math.abs((4.0 / y));
double tmp;
if (z <= -1e+95) {
tmp = Math.abs((z * (x / y)));
} else if (z <= -4.5e-27) {
tmp = t_1;
} else if (z <= 3.4e-260) {
tmp = t_0;
} else if (z <= 5.2e-117) {
tmp = t_1;
} else if (z <= 2.7e-12) {
tmp = t_0;
} else if (z <= 3.2e+60) {
tmp = t_1;
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((4.0 / y)) tmp = 0 if z <= -1e+95: tmp = math.fabs((z * (x / y))) elif z <= -4.5e-27: tmp = t_1 elif z <= 3.4e-260: tmp = t_0 elif z <= 5.2e-117: tmp = t_1 elif z <= 2.7e-12: tmp = t_0 elif z <= 3.2e+60: tmp = t_1 else: tmp = math.fabs((x * (z / y))) return tmp
y = abs(y) function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(4.0 / y)) tmp = 0.0 if (z <= -1e+95) tmp = abs(Float64(z * Float64(x / y))); elseif (z <= -4.5e-27) tmp = t_1; elseif (z <= 3.4e-260) tmp = t_0; elseif (z <= 5.2e-117) tmp = t_1; elseif (z <= 2.7e-12) tmp = t_0; elseif (z <= 3.2e+60) tmp = t_1; else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((4.0 / y)); tmp = 0.0; if (z <= -1e+95) tmp = abs((z * (x / y))); elseif (z <= -4.5e-27) tmp = t_1; elseif (z <= 3.4e-260) tmp = t_0; elseif (z <= 5.2e-117) tmp = t_1; elseif (z <= 2.7e-12) tmp = t_0; elseif (z <= 3.2e+60) tmp = t_1; else tmp = abs((x * (z / y))); 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[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -1e+95], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -4.5e-27], t$95$1, If[LessEqual[z, 3.4e-260], t$95$0, If[LessEqual[z, 5.2e-117], t$95$1, If[LessEqual[z, 2.7e-12], t$95$0, If[LessEqual[z, 3.2e+60], t$95$1, N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;z \leq -1 \cdot 10^{+95}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-27}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-260}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-117}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+60}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -1.00000000000000002e95Initial program 96.3%
Taylor expanded in z around inf 76.7%
*-commutative76.7%
associate-/l*81.2%
associate-/r/81.6%
associate-*r*81.6%
*-commutative81.6%
mul-1-neg81.6%
distribute-frac-neg81.6%
Simplified81.6%
expm1-log1p-u35.9%
expm1-udef28.0%
add-sqr-sqrt13.6%
sqrt-unprod25.4%
sqr-neg25.4%
sqrt-unprod18.4%
add-sqr-sqrt44.0%
Applied egg-rr44.0%
expm1-def51.8%
expm1-log1p81.6%
Simplified81.6%
if -1.00000000000000002e95 < z < -4.5000000000000002e-27 or 3.3999999999999998e-260 < z < 5.19999999999999966e-117 or 2.6999999999999998e-12 < z < 3.19999999999999991e60Initial program 91.6%
Taylor expanded in x around 0 61.6%
if -4.5000000000000002e-27 < z < 3.3999999999999998e-260 or 5.19999999999999966e-117 < z < 2.6999999999999998e-12Initial program 95.0%
Taylor expanded in z around 0 99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 69.1%
if 3.19999999999999991e60 < z Initial program 79.6%
fabs-sub79.6%
associate-*l/79.6%
*-commutative79.6%
associate-*l/77.7%
*-commutative77.7%
fma-neg81.9%
distribute-neg-frac81.9%
+-commutative81.9%
distribute-neg-in81.9%
unsub-neg81.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in x around inf 88.2%
Taylor expanded in z around inf 88.2%
Final simplification73.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x -3e+48) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (x <= -3e+48) {
tmp = fabs(((x / y) * (1.0 - z)));
} 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 <= (-3d+48)) then
tmp = abs(((x / y) * (1.0d0 - z)))
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 <= -3e+48) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if x <= -3e+48: tmp = math.fabs(((x / y) * (1.0 - z))) 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 <= -3e+48) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); 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 <= -3e+48) tmp = abs(((x / y) * (1.0 - z))); 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[LessEqual[x, -3e+48], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $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 -3 \cdot 10^{+48}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -3e48Initial program 83.9%
fabs-neg83.9%
sub-neg83.9%
distribute-neg-in83.9%
sub-neg83.9%
distribute-neg-frac83.9%
associate-*l/72.8%
distribute-neg-frac72.8%
neg-mul-172.8%
associate-*l/72.7%
neg-mul-172.7%
associate-*l/72.7%
distribute-lft-out--86.7%
fabs-mul86.7%
fabs-sub86.7%
fabs-mul86.7%
associate-*l/86.8%
Simplified86.8%
Taylor expanded in x around inf 86.8%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.7%
clear-num99.8%
Applied egg-rr99.8%
if -3e48 < x Initial program 93.2%
associate-*l/95.1%
sub-div98.6%
Applied egg-rr98.6%
Final simplification98.8%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -1.4e+106) (fabs (* z (/ x y))) (if (<= z 1.3e+61) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+106) {
tmp = fabs((z * (x / y)));
} else if (z <= 1.3e+61) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x * (z / y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.4d+106)) then
tmp = abs((z * (x / y)))
else if (z <= 1.3d+61) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x * (z / y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+106) {
tmp = Math.abs((z * (x / y)));
} else if (z <= 1.3e+61) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -1.4e+106: tmp = math.fabs((z * (x / y))) elif z <= 1.3e+61: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -1.4e+106) tmp = abs(Float64(z * Float64(x / y))); elseif (z <= 1.3e+61) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.4e+106) tmp = abs((z * (x / y))); elseif (z <= 1.3e+61) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -1.4e+106], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.3e+61], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+106}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+61}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -1.39999999999999996e106Initial program 96.2%
Taylor expanded in z around inf 79.3%
*-commutative79.3%
associate-/l*82.4%
associate-/r/82.7%
associate-*r*82.7%
*-commutative82.7%
mul-1-neg82.7%
distribute-frac-neg82.7%
Simplified82.7%
expm1-log1p-u35.6%
expm1-udef27.4%
add-sqr-sqrt14.2%
sqrt-unprod26.3%
sqr-neg26.3%
sqrt-unprod19.1%
add-sqr-sqrt45.5%
Applied egg-rr45.5%
expm1-def53.7%
expm1-log1p82.7%
Simplified82.7%
if -1.39999999999999996e106 < z < 1.29999999999999986e61Initial program 93.5%
fabs-sub93.5%
associate-*l/93.6%
*-commutative93.6%
associate-*l/93.0%
*-commutative93.0%
fma-neg98.1%
distribute-neg-frac98.1%
+-commutative98.1%
distribute-neg-in98.1%
unsub-neg98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in z around 0 92.2%
associate-*r/92.2%
distribute-lft-in92.2%
metadata-eval92.2%
neg-mul-192.2%
sub-neg92.2%
Simplified92.2%
if 1.29999999999999986e61 < z Initial program 79.6%
fabs-sub79.6%
associate-*l/79.6%
*-commutative79.6%
associate-*l/77.7%
*-commutative77.7%
fma-neg81.9%
distribute-neg-frac81.9%
+-commutative81.9%
distribute-neg-in81.9%
unsub-neg81.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in x around inf 88.2%
Taylor expanded in z around inf 88.2%
Final simplification89.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -10.2) (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.2) || !(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.2d0)) .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.2) || !(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.2) 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.2) || !(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.2) || ~((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.2], 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.2 \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.199999999999999 or 4 < x Initial program 87.9%
Taylor expanded in z around 0 63.2%
associate-*r/63.2%
metadata-eval63.2%
Simplified63.2%
Taylor expanded in x around inf 62.1%
if -10.199999999999999 < x < 4Initial program 95.2%
Taylor expanded in x around 0 66.3%
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 91.4%
Taylor expanded in x around 0 34.3%
Final simplification34.3%
herbie shell --seed 2023223
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))