
(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}
(FPCore (x y z) :precision binary64 (if (or (<= x -1.85e+109) (not (<= x 3.6e+16))) (fabs (/ x (/ y (- 1.0 z)))) (fabs (/ (- (+ 4.0 x) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.85e+109) || !(x <= 3.6e+16)) {
tmp = fabs((x / (y / (1.0 - z))));
} else {
tmp = fabs((((4.0 + x) - (x * z)) / 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.85d+109)) .or. (.not. (x <= 3.6d+16))) then
tmp = abs((x / (y / (1.0d0 - z))))
else
tmp = abs((((4.0d0 + x) - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.85e+109) || !(x <= 3.6e+16)) {
tmp = Math.abs((x / (y / (1.0 - z))));
} else {
tmp = Math.abs((((4.0 + x) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.85e+109) or not (x <= 3.6e+16): tmp = math.fabs((x / (y / (1.0 - z)))) else: tmp = math.fabs((((4.0 + x) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.85e+109) || !(x <= 3.6e+16)) tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); else tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.85e+109) || ~((x <= 3.6e+16))) tmp = abs((x / (y / (1.0 - z)))); else tmp = abs((((4.0 + x) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.85e+109], N[Not[LessEqual[x, 3.6e+16]], $MachinePrecision]], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{+109} \lor \neg \left(x \leq 3.6 \cdot 10^{+16}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -1.8500000000000001e109 or 3.6e16 < x Initial program 87.0%
Taylor expanded in y around 0 90.5%
Taylor expanded in x around inf 90.5%
associate-/l*99.9%
Simplified99.9%
if -1.8500000000000001e109 < x < 3.6e16Initial program 96.7%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.3e-99) (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 <= 1.3e-99) {
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 <= 1.3e-99) 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, 1.3e-99], 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 1.3 \cdot 10^{-99}:\\
\;\;\;\;\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 < 1.30000000000000003e-99Initial program 90.4%
Taylor expanded in y around 0 96.5%
if 1.30000000000000003e-99 < y Initial program 96.6%
Simplified99.9%
Final simplification97.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (/ x (/ y z)))))
(if (<= x -1.05e+21)
t_0
(if (<= x -5.8e-12)
t_1
(if (<= x 2.15e-20)
(fabs (/ 4.0 y))
(if (or (<= x 1.35e+38) (not (<= x 1.5e+103))) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((x / (y / z)));
double tmp;
if (x <= -1.05e+21) {
tmp = t_0;
} else if (x <= -5.8e-12) {
tmp = t_1;
} else if (x <= 2.15e-20) {
tmp = fabs((4.0 / y));
} else if ((x <= 1.35e+38) || !(x <= 1.5e+103)) {
tmp = t_1;
} else {
tmp = t_0;
}
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((x / y))
t_1 = abs((x / (y / z)))
if (x <= (-1.05d+21)) then
tmp = t_0
else if (x <= (-5.8d-12)) then
tmp = t_1
else if (x <= 2.15d-20) then
tmp = abs((4.0d0 / y))
else if ((x <= 1.35d+38) .or. (.not. (x <= 1.5d+103))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double t_1 = Math.abs((x / (y / z)));
double tmp;
if (x <= -1.05e+21) {
tmp = t_0;
} else if (x <= -5.8e-12) {
tmp = t_1;
} else if (x <= 2.15e-20) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 1.35e+38) || !(x <= 1.5e+103)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((x / (y / z))) tmp = 0 if x <= -1.05e+21: tmp = t_0 elif x <= -5.8e-12: tmp = t_1 elif x <= 2.15e-20: tmp = math.fabs((4.0 / y)) elif (x <= 1.35e+38) or not (x <= 1.5e+103): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(x / Float64(y / z))) tmp = 0.0 if (x <= -1.05e+21) tmp = t_0; elseif (x <= -5.8e-12) tmp = t_1; elseif (x <= 2.15e-20) tmp = abs(Float64(4.0 / y)); elseif ((x <= 1.35e+38) || !(x <= 1.5e+103)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((x / (y / z))); tmp = 0.0; if (x <= -1.05e+21) tmp = t_0; elseif (x <= -5.8e-12) tmp = t_1; elseif (x <= 2.15e-20) tmp = abs((4.0 / y)); elseif ((x <= 1.35e+38) || ~((x <= 1.5e+103))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.05e+21], t$95$0, If[LessEqual[x, -5.8e-12], t$95$1, If[LessEqual[x, 2.15e-20], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.35e+38], N[Not[LessEqual[x, 1.5e+103]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+21}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-12}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{-20}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+38} \lor \neg \left(x \leq 1.5 \cdot 10^{+103}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.05e21 or 1.34999999999999998e38 < x < 1.5e103Initial program 88.8%
Taylor expanded in y around 0 90.8%
Taylor expanded in x around inf 90.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 70.0%
if -1.05e21 < x < -5.8000000000000003e-12 or 2.15000000000000006e-20 < x < 1.34999999999999998e38 or 1.5e103 < x Initial program 89.8%
Taylor expanded in z around inf 68.4%
mul-1-neg68.4%
associate-*l/79.1%
distribute-rgt-neg-out79.1%
Simplified79.1%
associate-*l/68.4%
associate-/l*73.7%
add-sqr-sqrt41.6%
sqrt-unprod59.8%
sqr-neg59.8%
sqrt-unprod32.0%
add-sqr-sqrt73.7%
Applied egg-rr73.7%
if -5.8000000000000003e-12 < x < 2.15000000000000006e-20Initial program 96.6%
Taylor expanded in x around 0 80.3%
Final simplification75.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (/ x (/ y z)))))
(if (<= x -4.4e+27)
t_0
(if (<= x -4.5e-13)
t_1
(if (<= x 1.25e-20)
(fabs (/ 4.0 y))
(if (<= x 1.65e+38)
t_1
(if (<= x 6.5e+97) t_0 (fabs (/ z (/ y x))))))))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((x / (y / z)));
double tmp;
if (x <= -4.4e+27) {
tmp = t_0;
} else if (x <= -4.5e-13) {
tmp = t_1;
} else if (x <= 1.25e-20) {
tmp = fabs((4.0 / y));
} else if (x <= 1.65e+38) {
tmp = t_1;
} else if (x <= 6.5e+97) {
tmp = t_0;
} 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((x / y))
t_1 = abs((x / (y / z)))
if (x <= (-4.4d+27)) then
tmp = t_0
else if (x <= (-4.5d-13)) then
tmp = t_1
else if (x <= 1.25d-20) then
tmp = abs((4.0d0 / y))
else if (x <= 1.65d+38) then
tmp = t_1
else if (x <= 6.5d+97) then
tmp = t_0
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((x / y));
double t_1 = Math.abs((x / (y / z)));
double tmp;
if (x <= -4.4e+27) {
tmp = t_0;
} else if (x <= -4.5e-13) {
tmp = t_1;
} else if (x <= 1.25e-20) {
tmp = Math.abs((4.0 / y));
} else if (x <= 1.65e+38) {
tmp = t_1;
} else if (x <= 6.5e+97) {
tmp = t_0;
} else {
tmp = Math.abs((z / (y / x)));
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((x / (y / z))) tmp = 0 if x <= -4.4e+27: tmp = t_0 elif x <= -4.5e-13: tmp = t_1 elif x <= 1.25e-20: tmp = math.fabs((4.0 / y)) elif x <= 1.65e+38: tmp = t_1 elif x <= 6.5e+97: tmp = t_0 else: tmp = math.fabs((z / (y / x))) return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(x / Float64(y / z))) tmp = 0.0 if (x <= -4.4e+27) tmp = t_0; elseif (x <= -4.5e-13) tmp = t_1; elseif (x <= 1.25e-20) tmp = abs(Float64(4.0 / y)); elseif (x <= 1.65e+38) tmp = t_1; elseif (x <= 6.5e+97) tmp = t_0; else tmp = abs(Float64(z / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((x / (y / z))); tmp = 0.0; if (x <= -4.4e+27) tmp = t_0; elseif (x <= -4.5e-13) tmp = t_1; elseif (x <= 1.25e-20) tmp = abs((4.0 / y)); elseif (x <= 1.65e+38) tmp = t_1; elseif (x <= 6.5e+97) tmp = t_0; else tmp = abs((z / (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.4e+27], t$95$0, If[LessEqual[x, -4.5e-13], t$95$1, If[LessEqual[x, 1.25e-20], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.65e+38], t$95$1, If[LessEqual[x, 6.5e+97], t$95$0, N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-20}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+97}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if x < -4.3999999999999997e27 or 1.65e38 < x < 6.4999999999999999e97Initial program 88.8%
Taylor expanded in y around 0 90.8%
Taylor expanded in x around inf 90.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 70.0%
if -4.3999999999999997e27 < x < -4.5e-13 or 1.25e-20 < x < 1.65e38Initial program 99.7%
Taylor expanded in z around inf 77.4%
mul-1-neg77.4%
associate-*l/77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
associate-*l/77.4%
associate-/l*77.5%
add-sqr-sqrt48.0%
sqrt-unprod54.5%
sqr-neg54.5%
sqrt-unprod29.5%
add-sqr-sqrt77.5%
Applied egg-rr77.5%
if -4.5e-13 < x < 1.25e-20Initial program 96.6%
Taylor expanded in x around 0 80.3%
if 6.4999999999999999e97 < x Initial program 85.6%
Taylor expanded in z around inf 64.5%
mul-1-neg64.5%
associate-*l/79.8%
distribute-rgt-neg-out79.8%
Simplified79.8%
add-sqr-sqrt44.8%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod34.9%
add-sqr-sqrt79.8%
associate-*l/64.5%
*-commutative64.5%
associate-/l*79.9%
Applied egg-rr79.9%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= y 5e-11) (fabs (/ (- (+ 4.0 x) (* x z)) y)) (fabs (- (/ (+ 4.0 x) y) (* z (/ 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((((4.0 + x) / y) - (z * (x / 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 (y <= 5d-11) then
tmp = abs((((4.0d0 + x) - (x * z)) / y))
else
tmp = abs((((4.0d0 + x) / y) - (z * (x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5e-11) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y));
} else {
tmp = Math.abs((((4.0 + x) / y) - (z * (x / y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5e-11: tmp = math.fabs((((4.0 + x) - (x * z)) / y)) else: tmp = math.fabs((((4.0 + x) / y) - (z * (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(Float64(Float64(Float64(4.0 + x) / y) - Float64(z * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5e-11) tmp = abs((((4.0 + x) - (x * z)) / y)); else tmp = abs((((4.0 + x) / y) - (z * (x / y)))); end tmp_2 = 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[(N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(x / y), $MachinePrecision]), $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|\frac{4 + x}{y} - z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if y < 5.00000000000000018e-11Initial program 90.4%
Taylor expanded in y around 0 96.9%
if 5.00000000000000018e-11 < y Initial program 98.5%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (<= y 5e-57) (fabs (/ (- (+ 4.0 x) (* x z)) y)) (fabs (- (/ (+ 4.0 x) y) (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-57) {
tmp = fabs((((4.0 + x) - (x * z)) / y));
} else {
tmp = fabs((((4.0 + x) / y) - (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 (y <= 5d-57) then
tmp = abs((((4.0d0 + x) - (x * z)) / y))
else
tmp = abs((((4.0d0 + x) / y) - (x / (y / z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5e-57) {
tmp = Math.abs((((4.0 + x) - (x * z)) / y));
} else {
tmp = Math.abs((((4.0 + x) / y) - (x / (y / z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5e-57: tmp = math.fabs((((4.0 + x) - (x * z)) / y)) else: tmp = math.fabs((((4.0 + x) / y) - (x / (y / z)))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5e-57) tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(4.0 + x) / y) - Float64(x / Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5e-57) tmp = abs((((4.0 + x) - (x * z)) / y)); else tmp = abs((((4.0 + x) / y) - (x / (y / z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5e-57], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-57}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if y < 5.0000000000000002e-57Initial program 89.8%
Taylor expanded in y around 0 96.7%
if 5.0000000000000002e-57 < y Initial program 98.7%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.8e+53) (fabs (/ x (/ y z))) (if (<= z 4.1e+21) (fabs (/ (- -4.0 x) y)) (fabs (/ z (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.8e+53) {
tmp = fabs((x / (y / z)));
} else if (z <= 4.1e+21) {
tmp = fabs(((-4.0 - x) / y));
} 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) :: tmp
if (z <= (-4.8d+53)) then
tmp = abs((x / (y / z)))
else if (z <= 4.1d+21) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z / (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.8e+53) {
tmp = Math.abs((x / (y / z)));
} else if (z <= 4.1e+21) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z / (y / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.8e+53: tmp = math.fabs((x / (y / z))) elif z <= 4.1e+21: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z / (y / x))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.8e+53) tmp = abs(Float64(x / Float64(y / z))); elseif (z <= 4.1e+21) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.8e+53) tmp = abs((x / (y / z))); elseif (z <= 4.1e+21) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z / (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.8e+53], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.1e+21], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+53}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+21}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if z < -4.8e53Initial program 93.6%
Taylor expanded in z around inf 76.4%
mul-1-neg76.4%
associate-*l/79.2%
distribute-rgt-neg-out79.2%
Simplified79.2%
associate-*l/76.4%
associate-/l*84.0%
add-sqr-sqrt83.8%
sqrt-unprod51.4%
sqr-neg51.4%
sqrt-unprod0.0%
add-sqr-sqrt84.0%
Applied egg-rr84.0%
if -4.8e53 < z < 4.1e21Initial program 93.7%
Simplified99.3%
Taylor expanded in z around 0 96.2%
associate-*r/96.2%
distribute-lft-in96.2%
metadata-eval96.2%
neg-mul-196.2%
sub-neg96.2%
Simplified96.2%
if 4.1e21 < z Initial program 88.3%
Taylor expanded in z around inf 71.6%
mul-1-neg71.6%
associate-*l/80.7%
distribute-rgt-neg-out80.7%
Simplified80.7%
add-sqr-sqrt0.0%
sqrt-unprod59.9%
sqr-neg59.9%
sqrt-unprod80.5%
add-sqr-sqrt80.7%
associate-*l/71.6%
*-commutative71.6%
associate-/l*80.7%
Applied egg-rr80.7%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 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;
}
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
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;
}
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
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
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
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}
\\
\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 88.6%
Taylor expanded in y around 0 92.2%
Taylor expanded in x around inf 91.4%
associate-/l*99.1%
Simplified99.1%
Taylor expanded in z around 0 59.0%
if -10.5 < x < 4Initial program 96.9%
Taylor expanded in x around 0 75.8%
Final simplification67.1%
(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 92.6%
Taylor expanded in x around 0 39.0%
Final simplification39.0%
herbie shell --seed 2024011
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))