
(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 (<= x -2e+47) (fabs (* x (/ (- 1.0 z) y))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2e+47) {
tmp = fabs((x * ((1.0 - z) / y)));
} else {
tmp = fabs((((x + 4.0) - (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 <= (-2d+47)) then
tmp = abs((x * ((1.0d0 - z) / y)))
else
tmp = abs((((x + 4.0d0) - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2e+47) {
tmp = Math.abs((x * ((1.0 - z) / y)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2e+47: tmp = math.fabs((x * ((1.0 - z) / y))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2e+47) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2e+47) tmp = abs((x * ((1.0 - z) / y))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2e+47], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+47}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -2.0000000000000001e47Initial program 73.9%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
sub-neg99.8%
mul-1-neg99.8%
distribute-lft-in77.7%
associate-*r/77.8%
*-rgt-identity77.8%
mul-1-neg77.8%
distribute-rgt-neg-in77.8%
unsub-neg77.8%
*-lft-identity77.8%
associate-/l*77.8%
*-commutative77.8%
associate-/r/73.8%
div-sub99.8%
associate-/r/99.8%
Simplified99.8%
if -2.0000000000000001e47 < x Initial program 95.3%
associate-*l/97.0%
sub-div99.0%
Applied egg-rr99.0%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
(if (<= x -6.5e+140)
t_0
(if (<= x -9e+39)
t_1
(if (<= x -6.8e-16)
t_0
(if (<= x 1.55e-53)
(fabs (/ 4.0 y))
(if (<= x 1.65e+134) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -6.5e+140) {
tmp = t_0;
} else if (x <= -9e+39) {
tmp = t_1;
} else if (x <= -6.8e-16) {
tmp = t_0;
} else if (x <= 1.55e-53) {
tmp = fabs((4.0 / y));
} else if (x <= 1.65e+134) {
tmp = t_0;
} else {
tmp = t_1;
}
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((z * (x / y)))
t_1 = abs((x / y))
if (x <= (-6.5d+140)) then
tmp = t_0
else if (x <= (-9d+39)) then
tmp = t_1
else if (x <= (-6.8d-16)) then
tmp = t_0
else if (x <= 1.55d-53) then
tmp = abs((4.0d0 / y))
else if (x <= 1.65d+134) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((z * (x / y)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -6.5e+140) {
tmp = t_0;
} else if (x <= -9e+39) {
tmp = t_1;
} else if (x <= -6.8e-16) {
tmp = t_0;
} else if (x <= 1.55e-53) {
tmp = Math.abs((4.0 / y));
} else if (x <= 1.65e+134) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((z * (x / y))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -6.5e+140: tmp = t_0 elif x <= -9e+39: tmp = t_1 elif x <= -6.8e-16: tmp = t_0 elif x <= 1.55e-53: tmp = math.fabs((4.0 / y)) elif x <= 1.65e+134: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -6.5e+140) tmp = t_0; elseif (x <= -9e+39) tmp = t_1; elseif (x <= -6.8e-16) tmp = t_0; elseif (x <= 1.55e-53) tmp = abs(Float64(4.0 / y)); elseif (x <= 1.65e+134) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -6.5e+140) tmp = t_0; elseif (x <= -9e+39) tmp = t_1; elseif (x <= -6.8e-16) tmp = t_0; elseif (x <= 1.55e-53) tmp = abs((4.0 / y)); elseif (x <= 1.65e+134) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e+140], t$95$0, If[LessEqual[x, -9e+39], t$95$1, If[LessEqual[x, -6.8e-16], t$95$0, If[LessEqual[x, 1.55e-53], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.65e+134], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6.8 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+134}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -6.4999999999999999e140 or -8.99999999999999991e39 < x < -6.8e-16 or 1.55000000000000008e-53 < x < 1.65e134Initial program 86.5%
Simplified91.8%
Taylor expanded in z around inf 60.4%
add-sqr-sqrt29.1%
sqrt-unprod47.4%
sqr-neg47.4%
sqrt-unprod31.2%
add-sqr-sqrt60.4%
*-commutative60.4%
associate-*l/70.4%
clear-num70.4%
clear-num70.4%
add-sqr-sqrt37.9%
sqrt-unprod52.0%
sqr-neg52.0%
sqrt-unprod32.4%
add-sqr-sqrt70.4%
Applied egg-rr70.4%
if -6.4999999999999999e140 < x < -8.99999999999999991e39 or 1.65e134 < x Initial program 85.2%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
sub-neg99.7%
mul-1-neg99.7%
distribute-lft-in88.6%
associate-*r/88.7%
*-rgt-identity88.7%
mul-1-neg88.7%
distribute-rgt-neg-in88.7%
unsub-neg88.7%
*-lft-identity88.7%
associate-/l*88.6%
*-commutative88.6%
associate-/r/86.8%
div-sub99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in z around 0 74.4%
if -6.8e-16 < x < 1.55000000000000008e-53Initial program 97.0%
Taylor expanded in x around 0 86.8%
Final simplification78.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ z (/ y x)))) (t_1 (fabs (/ x y))))
(if (<= x -1.65e+135)
(fabs (* z (/ x y)))
(if (<= x -9e+39)
t_1
(if (<= x -6e-15)
t_0
(if (<= x 6.2e-47)
(fabs (/ 4.0 y))
(if (<= x 1.75e+130) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = fabs((z / (y / x)));
double t_1 = fabs((x / y));
double tmp;
if (x <= -1.65e+135) {
tmp = fabs((z * (x / y)));
} else if (x <= -9e+39) {
tmp = t_1;
} else if (x <= -6e-15) {
tmp = t_0;
} else if (x <= 6.2e-47) {
tmp = fabs((4.0 / y));
} else if (x <= 1.75e+130) {
tmp = t_0;
} else {
tmp = t_1;
}
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((z / (y / x)))
t_1 = abs((x / y))
if (x <= (-1.65d+135)) then
tmp = abs((z * (x / y)))
else if (x <= (-9d+39)) then
tmp = t_1
else if (x <= (-6d-15)) then
tmp = t_0
else if (x <= 6.2d-47) then
tmp = abs((4.0d0 / y))
else if (x <= 1.75d+130) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((z / (y / x)));
double t_1 = Math.abs((x / y));
double tmp;
if (x <= -1.65e+135) {
tmp = Math.abs((z * (x / y)));
} else if (x <= -9e+39) {
tmp = t_1;
} else if (x <= -6e-15) {
tmp = t_0;
} else if (x <= 6.2e-47) {
tmp = Math.abs((4.0 / y));
} else if (x <= 1.75e+130) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((z / (y / x))) t_1 = math.fabs((x / y)) tmp = 0 if x <= -1.65e+135: tmp = math.fabs((z * (x / y))) elif x <= -9e+39: tmp = t_1 elif x <= -6e-15: tmp = t_0 elif x <= 6.2e-47: tmp = math.fabs((4.0 / y)) elif x <= 1.75e+130: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(z / Float64(y / x))) t_1 = abs(Float64(x / y)) tmp = 0.0 if (x <= -1.65e+135) tmp = abs(Float64(z * Float64(x / y))); elseif (x <= -9e+39) tmp = t_1; elseif (x <= -6e-15) tmp = t_0; elseif (x <= 6.2e-47) tmp = abs(Float64(4.0 / y)); elseif (x <= 1.75e+130) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((z / (y / x))); t_1 = abs((x / y)); tmp = 0.0; if (x <= -1.65e+135) tmp = abs((z * (x / y))); elseif (x <= -9e+39) tmp = t_1; elseif (x <= -6e-15) tmp = t_0; elseif (x <= 6.2e-47) tmp = abs((4.0 / y)); elseif (x <= 1.75e+130) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.65e+135], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -9e+39], t$95$1, If[LessEqual[x, -6e-15], t$95$0, If[LessEqual[x, 6.2e-47], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.75e+130], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+135}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-47}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+130}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.65e135Initial program 64.4%
Simplified78.9%
Taylor expanded in z around inf 54.8%
add-sqr-sqrt20.6%
sqrt-unprod53.4%
sqr-neg53.4%
sqrt-unprod34.3%
add-sqr-sqrt54.8%
*-commutative54.8%
associate-*l/81.6%
clear-num81.5%
clear-num81.6%
add-sqr-sqrt52.1%
sqrt-unprod65.7%
sqr-neg65.7%
sqrt-unprod29.4%
add-sqr-sqrt81.6%
Applied egg-rr81.6%
if -1.65e135 < x < -8.99999999999999991e39 or 1.75e130 < x Initial program 85.7%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
sub-neg99.7%
mul-1-neg99.7%
distribute-lft-in88.9%
associate-*r/89.1%
*-rgt-identity89.1%
mul-1-neg89.1%
distribute-rgt-neg-in89.1%
unsub-neg89.1%
*-lft-identity89.1%
associate-/l*89.0%
*-commutative89.0%
associate-/r/87.2%
div-sub99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in z around 0 73.6%
if -8.99999999999999991e39 < x < -6e-15 or 6.1999999999999996e-47 < x < 1.75e130Initial program 99.8%
Taylor expanded in z around inf 64.2%
associate-*r/64.2%
mul-1-neg64.2%
distribute-rgt-neg-out64.2%
associate-*r/64.2%
distribute-frac-neg64.2%
mul-1-neg64.2%
metadata-eval64.2%
times-frac64.2%
*-lft-identity64.2%
neg-mul-164.2%
Simplified64.2%
associate-*r/64.2%
add-sqr-sqrt28.4%
sqrt-unprod45.5%
sqr-neg45.5%
sqrt-unprod35.6%
add-sqr-sqrt64.2%
associate-/l*64.3%
Applied egg-rr64.3%
if -6e-15 < x < 6.1999999999999996e-47Initial program 97.0%
Taylor expanded in x around 0 86.8%
Final simplification78.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* x (/ z y)))))
(if (<= x -5e-17)
t_0
(if (<= x 5.8e-47)
(fabs (/ 4.0 y))
(if (<= x 2.5e+129) t_0 (fabs (/ x y)))))))
double code(double x, double y, double z) {
double t_0 = fabs((x * (z / y)));
double tmp;
if (x <= -5e-17) {
tmp = t_0;
} else if (x <= 5.8e-47) {
tmp = fabs((4.0 / y));
} else if (x <= 2.5e+129) {
tmp = t_0;
} else {
tmp = fabs((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) :: t_0
real(8) :: tmp
t_0 = abs((x * (z / y)))
if (x <= (-5d-17)) then
tmp = t_0
else if (x <= 5.8d-47) then
tmp = abs((4.0d0 / y))
else if (x <= 2.5d+129) then
tmp = t_0
else
tmp = abs((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x * (z / y)));
double tmp;
if (x <= -5e-17) {
tmp = t_0;
} else if (x <= 5.8e-47) {
tmp = Math.abs((4.0 / y));
} else if (x <= 2.5e+129) {
tmp = t_0;
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x * (z / y))) tmp = 0 if x <= -5e-17: tmp = t_0 elif x <= 5.8e-47: tmp = math.fabs((4.0 / y)) elif x <= 2.5e+129: tmp = t_0 else: tmp = math.fabs((x / y)) return tmp
function code(x, y, z) t_0 = abs(Float64(x * Float64(z / y))) tmp = 0.0 if (x <= -5e-17) tmp = t_0; elseif (x <= 5.8e-47) tmp = abs(Float64(4.0 / y)); elseif (x <= 2.5e+129) tmp = t_0; else tmp = abs(Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x * (z / y))); tmp = 0.0; if (x <= -5e-17) tmp = t_0; elseif (x <= 5.8e-47) tmp = abs((4.0 / y)); elseif (x <= 2.5e+129) tmp = t_0; else tmp = abs((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5e-17], t$95$0, If[LessEqual[x, 5.8e-47], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.5e+129], t$95$0, N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -5 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-47}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+129}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -4.9999999999999999e-17 or 5.8000000000000001e-47 < x < 2.5000000000000001e129Initial program 87.3%
Simplified91.6%
Taylor expanded in z around inf 54.2%
associate-*l/61.4%
*-commutative61.4%
Simplified61.4%
if -4.9999999999999999e-17 < x < 5.8000000000000001e-47Initial program 97.0%
Taylor expanded in x around 0 86.8%
if 2.5000000000000001e129 < x Initial program 81.8%
Taylor expanded in x around inf 99.7%
*-commutative99.7%
sub-neg99.7%
mul-1-neg99.7%
distribute-lft-in87.6%
associate-*r/87.8%
*-rgt-identity87.8%
mul-1-neg87.8%
distribute-rgt-neg-in87.8%
unsub-neg87.8%
*-lft-identity87.8%
associate-/l*87.5%
*-commutative87.5%
associate-/r/84.5%
div-sub99.7%
associate-/r/99.7%
Simplified99.7%
Taylor expanded in z around 0 77.2%
Final simplification75.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e-15) (not (<= x 2.5e-53))) (fabs (* x (/ (- 1.0 z) y))) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e-15) || !(x <= 2.5e-53)) {
tmp = fabs((x * ((1.0 - z) / 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 <= (-2.1d-15)) .or. (.not. (x <= 2.5d-53))) then
tmp = abs((x * ((1.0d0 - z) / 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 <= -2.1e-15) || !(x <= 2.5e-53)) {
tmp = Math.abs((x * ((1.0 - z) / y)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e-15) or not (x <= 2.5e-53): tmp = math.fabs((x * ((1.0 - z) / y))) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e-15) || !(x <= 2.5e-53)) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y))); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.1e-15) || ~((x <= 2.5e-53))) tmp = abs((x * ((1.0 - z) / y))); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e-15], N[Not[LessEqual[x, 2.5e-53]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-15} \lor \neg \left(x \leq 2.5 \cdot 10^{-53}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -2.09999999999999981e-15 or 2.5e-53 < x Initial program 86.0%
Taylor expanded in x around inf 93.3%
*-commutative93.3%
sub-neg93.3%
mul-1-neg93.3%
distribute-lft-in82.3%
associate-*r/82.5%
*-rgt-identity82.5%
mul-1-neg82.5%
distribute-rgt-neg-in82.5%
unsub-neg82.5%
*-lft-identity82.5%
associate-/l*82.4%
*-commutative82.4%
associate-/r/80.8%
div-sub94.0%
associate-/r/93.3%
Simplified93.3%
if -2.09999999999999981e-15 < x < 2.5e-53Initial program 97.0%
Taylor expanded in x around 0 86.8%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e-13) (not (<= x 4.8e-49))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e-13) || !(x <= 4.8e-49)) {
tmp = fabs(((z + -1.0) / (y / x)));
} 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 <= (-2.9d-13)) .or. (.not. (x <= 4.8d-49))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
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 <= -2.9e-13) || !(x <= 4.8e-49)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e-13) or not (x <= 4.8e-49): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e-13) || !(x <= 4.8e-49)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.9e-13) || ~((x <= 4.8e-49))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e-13], N[Not[LessEqual[x, 4.8e-49]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-13} \lor \neg \left(x \leq 4.8 \cdot 10^{-49}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -2.8999999999999998e-13 or 4.79999999999999985e-49 < x Initial program 86.0%
Simplified92.2%
Taylor expanded in x around inf 86.6%
associate-/l*94.0%
sub-neg94.0%
metadata-eval94.0%
Simplified94.0%
if -2.8999999999999998e-13 < x < 4.79999999999999985e-49Initial program 97.0%
Taylor expanded in x around 0 86.8%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (<= z -4.9e+39) (fabs (* z (/ x y))) (if (<= z 3.7e+93) (fabs (/ (- -4.0 x) y)) (fabs (/ (* x z) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.9e+39) {
tmp = fabs((z * (x / y)));
} else if (z <= 3.7e+93) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs(((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 (z <= (-4.9d+39)) then
tmp = abs((z * (x / y)))
else if (z <= 3.7d+93) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs(((x * z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.9e+39) {
tmp = Math.abs((z * (x / y)));
} else if (z <= 3.7e+93) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs(((x * z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.9e+39: tmp = math.fabs((z * (x / y))) elif z <= 3.7e+93: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs(((x * z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.9e+39) tmp = abs(Float64(z * Float64(x / y))); elseif (z <= 3.7e+93) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(x * z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.9e+39) tmp = abs((z * (x / y))); elseif (z <= 3.7e+93) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((x * z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.9e+39], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.7e+93], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+39}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+93}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\end{array}
\end{array}
if z < -4.89999999999999987e39Initial program 97.9%
Simplified86.5%
Taylor expanded in z around inf 62.1%
add-sqr-sqrt25.8%
sqrt-unprod42.6%
sqr-neg42.6%
sqrt-unprod36.1%
add-sqr-sqrt62.1%
*-commutative62.1%
associate-*l/73.7%
clear-num73.7%
clear-num73.7%
add-sqr-sqrt41.9%
sqrt-unprod47.1%
sqr-neg47.1%
sqrt-unprod31.6%
add-sqr-sqrt73.7%
Applied egg-rr73.7%
if -4.89999999999999987e39 < z < 3.69999999999999987e93Initial program 92.4%
Simplified99.2%
Taylor expanded in z around 0 93.0%
associate-*r/93.0%
distribute-lft-in93.0%
metadata-eval93.0%
neg-mul-193.0%
sub-neg93.0%
Simplified93.0%
if 3.69999999999999987e93 < z Initial program 72.5%
Simplified96.8%
Taylor expanded in z around inf 75.8%
Final simplification86.0%
(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 84.3%
Taylor expanded in x around inf 98.2%
*-commutative98.2%
sub-neg98.2%
mul-1-neg98.2%
distribute-lft-in85.9%
associate-*r/86.1%
*-rgt-identity86.1%
mul-1-neg86.1%
distribute-rgt-neg-in86.1%
unsub-neg86.1%
*-lft-identity86.1%
associate-/l*86.0%
*-commutative86.0%
associate-/r/83.5%
div-sub98.3%
associate-/r/98.2%
Simplified98.2%
Taylor expanded in z around 0 60.9%
if -10.5 < x < 4Initial program 97.3%
Taylor expanded in x around 0 80.3%
Final simplification71.0%
(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 91.1%
Taylor expanded in x around 0 44.5%
Final simplification44.5%
herbie shell --seed 2023192
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))