
(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 9 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 8e-39) (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 <= 8e-39) {
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 <= 8e-39) 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, 8e-39], 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 8 \cdot 10^{-39}:\\
\;\;\;\;\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 < 7.99999999999999943e-39Initial program 89.5%
associate-*l/90.3%
sub-div97.4%
Applied egg-rr97.4%
if 7.99999999999999943e-39 < y Initial program 95.0%
fabs-sub95.0%
associate-*l/90.7%
*-commutative90.7%
associate-*l/99.7%
*-commutative99.7%
fma-neg99.7%
distribute-neg-frac99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification98.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 (* x (/ z y)))))
(if (<= x -2.15e+79)
t_0
(if (<= x -2.6e-73)
t_1
(if (<= x 1.06e-41) (fabs (/ 4.0 y)) (if (<= x 3.1e+93) 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 <= -2.15e+79) {
tmp = t_0;
} else if (x <= -2.6e-73) {
tmp = t_1;
} else if (x <= 1.06e-41) {
tmp = fabs((4.0 / y));
} else if (x <= 3.1e+93) {
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 <= (-2.15d+79)) then
tmp = t_0
else if (x <= (-2.6d-73)) then
tmp = t_1
else if (x <= 1.06d-41) then
tmp = abs((4.0d0 / y))
else if (x <= 3.1d+93) 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 <= -2.15e+79) {
tmp = t_0;
} else if (x <= -2.6e-73) {
tmp = t_1;
} else if (x <= 1.06e-41) {
tmp = Math.abs((4.0 / y));
} else if (x <= 3.1e+93) {
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 <= -2.15e+79: tmp = t_0 elif x <= -2.6e-73: tmp = t_1 elif x <= 1.06e-41: tmp = math.fabs((4.0 / y)) elif x <= 3.1e+93: 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 <= -2.15e+79) tmp = t_0; elseif (x <= -2.6e-73) tmp = t_1; elseif (x <= 1.06e-41) tmp = abs(Float64(4.0 / y)); elseif (x <= 3.1e+93) 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 <= -2.15e+79) tmp = t_0; elseif (x <= -2.6e-73) tmp = t_1; elseif (x <= 1.06e-41) tmp = abs((4.0 / y)); elseif (x <= 3.1e+93) 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, -2.15e+79], t$95$0, If[LessEqual[x, -2.6e-73], t$95$1, If[LessEqual[x, 1.06e-41], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.1e+93], 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 -2.15 \cdot 10^{+79}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{-73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-41}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+93}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.1500000000000002e79 or 3.10000000000000019e93 < x Initial program 81.5%
Taylor expanded in z around 0 68.5%
associate-*r/68.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in x around inf 68.5%
if -2.1500000000000002e79 < x < -2.6000000000000001e-73 or 1.06e-41 < x < 3.10000000000000019e93Initial program 94.2%
Simplified94.6%
Taylor expanded in z around inf 65.9%
associate-*l/71.0%
*-commutative71.0%
Simplified71.0%
if -2.6000000000000001e-73 < x < 1.06e-41Initial program 96.9%
Taylor expanded in x around 0 78.5%
Final simplification73.5%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -1e+26) (not (<= x 1e+47))) (fabs (* (/ x y) (+ z -1.0))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+26) || !(x <= 1e+47)) {
tmp = fabs(((x / y) * (z + -1.0)));
} 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 <= (-1d+26)) .or. (.not. (x <= 1d+47))) then
tmp = abs(((x / y) * (z + (-1.0d0))))
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 <= -1e+26) || !(x <= 1e+47)) {
tmp = Math.abs(((x / y) * (z + -1.0)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -1e+26) or not (x <= 1e+47): tmp = math.fabs(((x / y) * (z + -1.0))) 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 <= -1e+26) || !(x <= 1e+47)) tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0))); 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 <= -1e+26) || ~((x <= 1e+47))) tmp = abs(((x / y) * (z + -1.0))); 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, -1e+26], N[Not[LessEqual[x, 1e+47]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $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 -1 \cdot 10^{+26} \lor \neg \left(x \leq 10^{+47}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -1.00000000000000005e26 or 1e47 < x Initial program 83.5%
Simplified89.0%
Taylor expanded in x around inf 89.2%
Taylor expanded in z around 0 76.6%
associate-*r/83.5%
distribute-rgt-in99.9%
Simplified99.9%
if -1.00000000000000005e26 < x < 1e47Initial program 96.3%
associate-*l/99.9%
sub-div99.8%
Applied egg-rr99.8%
Final simplification99.9%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -9.2e-71) (not (<= x 2.55e-40))) (fabs (* (/ x y) (+ z -1.0))) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e-71) || !(x <= 2.55e-40)) {
tmp = fabs(((x / y) * (z + -1.0)));
} 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 <= (-9.2d-71)) .or. (.not. (x <= 2.55d-40))) then
tmp = abs(((x / y) * (z + (-1.0d0))))
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 <= -9.2e-71) || !(x <= 2.55e-40)) {
tmp = Math.abs(((x / y) * (z + -1.0)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -9.2e-71) or not (x <= 2.55e-40): tmp = math.fabs(((x / y) * (z + -1.0))) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -9.2e-71) || !(x <= 2.55e-40)) tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0))); 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 <= -9.2e-71) || ~((x <= 2.55e-40))) tmp = abs(((x / y) * (z + -1.0))); 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, -9.2e-71], N[Not[LessEqual[x, 2.55e-40]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-71} \lor \neg \left(x \leq 2.55 \cdot 10^{-40}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -9.1999999999999994e-71 or 2.55000000000000019e-40 < x Initial program 86.9%
Simplified91.7%
Taylor expanded in x around inf 86.0%
Taylor expanded in z around 0 76.7%
associate-*r/81.1%
distribute-rgt-in93.3%
Simplified93.3%
if -9.1999999999999994e-71 < x < 2.55000000000000019e-40Initial program 96.1%
Taylor expanded in x around 0 77.8%
Final simplification86.3%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -3.35e-71) (not (<= x 3.45e-43))) (fabs (* z (/ x y))) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.35e-71) || !(x <= 3.45e-43)) {
tmp = fabs((z * (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 <= (-3.35d-71)) .or. (.not. (x <= 3.45d-43))) then
tmp = abs((z * (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 <= -3.35e-71) || !(x <= 3.45e-43)) {
tmp = Math.abs((z * (x / y)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -3.35e-71) or not (x <= 3.45e-43): tmp = math.fabs((z * (x / y))) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -3.35e-71) || !(x <= 3.45e-43)) tmp = abs(Float64(z * 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 <= -3.35e-71) || ~((x <= 3.45e-43))) tmp = abs((z * (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, -3.35e-71], N[Not[LessEqual[x, 3.45e-43]], $MachinePrecision]], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.35 \cdot 10^{-71} \lor \neg \left(x \leq 3.45 \cdot 10^{-43}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -3.3499999999999999e-71 or 3.44999999999999982e-43 < x Initial program 86.9%
Simplified91.7%
Taylor expanded in z around inf 53.5%
add-sqr-sqrt32.7%
sqrt-unprod49.7%
sqr-neg49.7%
sqrt-unprod20.8%
add-sqr-sqrt53.5%
associate-*r/67.5%
*-commutative67.5%
add-sqr-sqrt26.8%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod40.6%
add-sqr-sqrt67.5%
Applied egg-rr67.5%
if -3.3499999999999999e-71 < x < 3.44999999999999982e-43Initial program 96.1%
Taylor expanded in x around 0 77.8%
Final simplification72.1%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (or (<= x -5.6e-71) (not (<= x 2.9e-40))) (fabs (/ z (/ y x))) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.6e-71) || !(x <= 2.9e-40)) {
tmp = fabs((z / (y / x)));
} 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 <= (-5.6d-71)) .or. (.not. (x <= 2.9d-40))) then
tmp = abs((z / (y / x)))
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 <= -5.6e-71) || !(x <= 2.9e-40)) {
tmp = Math.abs((z / (y / x)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if (x <= -5.6e-71) or not (x <= 2.9e-40): tmp = math.fabs((z / (y / x))) else: tmp = math.fabs((4.0 / y)) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if ((x <= -5.6e-71) || !(x <= 2.9e-40)) tmp = abs(Float64(z / Float64(y / x))); 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 <= -5.6e-71) || ~((x <= 2.9e-40))) tmp = abs((z / (y / x))); 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, -5.6e-71], N[Not[LessEqual[x, 2.9e-40]], $MachinePrecision]], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{-71} \lor \neg \left(x \leq 2.9 \cdot 10^{-40}\right):\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -5.60000000000000001e-71 or 2.8999999999999999e-40 < x Initial program 86.9%
Taylor expanded in z around inf 53.5%
associate-*r/53.5%
mul-1-neg53.5%
distribute-rgt-neg-out53.5%
associate-*r/67.5%
distribute-frac-neg67.5%
mul-1-neg67.5%
metadata-eval67.5%
times-frac67.5%
*-lft-identity67.5%
neg-mul-167.5%
Simplified67.5%
associate-*r/53.5%
add-sqr-sqrt20.8%
sqrt-unprod49.7%
sqr-neg49.7%
sqrt-unprod32.7%
add-sqr-sqrt53.5%
associate-/l*67.5%
Applied egg-rr67.5%
if -5.60000000000000001e-71 < x < 2.8999999999999999e-40Initial program 96.1%
Taylor expanded in x around 0 77.8%
Final simplification72.2%
NOTE: y should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z -4.4e+91) (fabs (/ z (/ y x))) (if (<= z 2.5e+102) (fabs (/ (- -4.0 x) y)) (fabs (* z (/ x y))))))
y = abs(y);
double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+91) {
tmp = fabs((z / (y / x)));
} else if (z <= 2.5e+102) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((z * (x / y)));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-4.4d+91)) then
tmp = abs((z / (y / x)))
else if (z <= 2.5d+102) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z * (x / y)))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+91) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 2.5e+102) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z * (x / y)));
}
return tmp;
}
y = abs(y) def code(x, y, z): tmp = 0 if z <= -4.4e+91: tmp = math.fabs((z / (y / x))) elif z <= 2.5e+102: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z * (x / y))) return tmp
y = abs(y) function code(x, y, z) tmp = 0.0 if (z <= -4.4e+91) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 2.5e+102) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z * Float64(x / y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.4e+91) tmp = abs((z / (y / x))); elseif (z <= 2.5e+102) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z * (x / y))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, -4.4e+91], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.5e+102], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+91}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+102}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -4.39999999999999999e91Initial program 94.2%
Taylor expanded in z around inf 65.2%
associate-*r/65.2%
mul-1-neg65.2%
distribute-rgt-neg-out65.2%
associate-*r/73.3%
distribute-frac-neg73.3%
mul-1-neg73.3%
metadata-eval73.3%
times-frac73.3%
*-lft-identity73.3%
neg-mul-173.3%
Simplified73.3%
associate-*r/65.2%
add-sqr-sqrt29.2%
sqrt-unprod48.9%
sqr-neg48.9%
sqrt-unprod35.9%
add-sqr-sqrt65.2%
associate-/l*73.5%
Applied egg-rr73.5%
if -4.39999999999999999e91 < z < 2.5e102Initial program 94.0%
Simplified98.6%
Taylor expanded in z around 0 90.2%
associate-*r/90.2%
distribute-lft-in90.2%
metadata-eval90.2%
neg-mul-190.2%
sub-neg90.2%
Simplified90.2%
if 2.5e102 < z Initial program 81.2%
Simplified93.6%
Taylor expanded in z around inf 81.0%
add-sqr-sqrt37.8%
sqrt-unprod69.4%
sqr-neg69.4%
sqrt-unprod43.0%
add-sqr-sqrt81.0%
associate-*r/82.2%
*-commutative82.2%
add-sqr-sqrt45.9%
sqrt-unprod72.5%
sqr-neg72.5%
sqrt-unprod36.1%
add-sqr-sqrt82.2%
Applied egg-rr82.2%
Final simplification85.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 85.0%
Taylor expanded in z around 0 60.6%
associate-*r/60.6%
metadata-eval60.6%
Simplified60.6%
Taylor expanded in x around inf 60.6%
if -10.199999999999999 < x < 4Initial program 96.0%
Taylor expanded in x around 0 69.2%
Final simplification65.3%
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.1%
Taylor expanded in x around 0 40.4%
Final simplification40.4%
herbie shell --seed 2023244
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))