
(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 (<= y -1e+40) (fabs (fma x (/ z y) (/ (- -4.0 x) y))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+40) {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
} else {
tmp = fabs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1e+40) tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1e+40], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $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}\;y \leq -1 \cdot 10^{+40}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if y < -1.00000000000000003e40Initial program 96.3%
fabs-sub96.3%
associate-*l/89.4%
*-commutative89.4%
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%
if -1.00000000000000003e40 < y Initial program 90.5%
associate-*l/94.1%
sub-div99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ x y))) (t_2 (fabs (/ (* x z) y))))
(if (<= x -1.65e+26)
t_1
(if (<= x -4.7e-23)
t_2
(if (<= x 2.2e-144)
t_0
(if (<= x 4e-111)
t_2
(if (<= x 1.5e-35)
t_0
(if (<= x 9.5e+182) (fabs (* z (/ x y))) t_1))))))))
double code(double x, double y, double z) {
double t_0 = fabs((4.0 / y));
double t_1 = fabs((x / y));
double t_2 = fabs(((x * z) / y));
double tmp;
if (x <= -1.65e+26) {
tmp = t_1;
} else if (x <= -4.7e-23) {
tmp = t_2;
} else if (x <= 2.2e-144) {
tmp = t_0;
} else if (x <= 4e-111) {
tmp = t_2;
} else if (x <= 1.5e-35) {
tmp = t_0;
} else if (x <= 9.5e+182) {
tmp = fabs((z * (x / y)));
} 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) :: t_2
real(8) :: tmp
t_0 = abs((4.0d0 / y))
t_1 = abs((x / y))
t_2 = abs(((x * z) / y))
if (x <= (-1.65d+26)) then
tmp = t_1
else if (x <= (-4.7d-23)) then
tmp = t_2
else if (x <= 2.2d-144) then
tmp = t_0
else if (x <= 4d-111) then
tmp = t_2
else if (x <= 1.5d-35) then
tmp = t_0
else if (x <= 9.5d+182) then
tmp = abs((z * (x / y)))
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((4.0 / y));
double t_1 = Math.abs((x / y));
double t_2 = Math.abs(((x * z) / y));
double tmp;
if (x <= -1.65e+26) {
tmp = t_1;
} else if (x <= -4.7e-23) {
tmp = t_2;
} else if (x <= 2.2e-144) {
tmp = t_0;
} else if (x <= 4e-111) {
tmp = t_2;
} else if (x <= 1.5e-35) {
tmp = t_0;
} else if (x <= 9.5e+182) {
tmp = Math.abs((z * (x / y)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((4.0 / y)) t_1 = math.fabs((x / y)) t_2 = math.fabs(((x * z) / y)) tmp = 0 if x <= -1.65e+26: tmp = t_1 elif x <= -4.7e-23: tmp = t_2 elif x <= 2.2e-144: tmp = t_0 elif x <= 4e-111: tmp = t_2 elif x <= 1.5e-35: tmp = t_0 elif x <= 9.5e+182: tmp = math.fabs((z * (x / y))) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(4.0 / y)) t_1 = abs(Float64(x / y)) t_2 = abs(Float64(Float64(x * z) / y)) tmp = 0.0 if (x <= -1.65e+26) tmp = t_1; elseif (x <= -4.7e-23) tmp = t_2; elseif (x <= 2.2e-144) tmp = t_0; elseif (x <= 4e-111) tmp = t_2; elseif (x <= 1.5e-35) tmp = t_0; elseif (x <= 9.5e+182) tmp = abs(Float64(z * Float64(x / y))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((4.0 / y)); t_1 = abs((x / y)); t_2 = abs(((x * z) / y)); tmp = 0.0; if (x <= -1.65e+26) tmp = t_1; elseif (x <= -4.7e-23) tmp = t_2; elseif (x <= 2.2e-144) tmp = t_0; elseif (x <= 4e-111) tmp = t_2; elseif (x <= 1.5e-35) tmp = t_0; elseif (x <= 9.5e+182) tmp = abs((z * (x / y))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.65e+26], t$95$1, If[LessEqual[x, -4.7e-23], t$95$2, If[LessEqual[x, 2.2e-144], t$95$0, If[LessEqual[x, 4e-111], t$95$2, If[LessEqual[x, 1.5e-35], t$95$0, If[LessEqual[x, 9.5e+182], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
t_2 := \left|\frac{x \cdot z}{y}\right|\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+26}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.7 \cdot 10^{-23}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-144}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-111}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-35}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+182}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.64999999999999997e26 or 9.50000000000000002e182 < x Initial program 84.8%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
sub-neg99.8%
mul-1-neg99.8%
distribute-lft-in89.3%
associate-*r/89.5%
*-rgt-identity89.5%
mul-1-neg89.5%
distribute-rgt-neg-in89.5%
unsub-neg89.5%
*-lft-identity89.5%
associate-/l*89.3%
*-commutative89.3%
associate-/r/84.6%
div-sub99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in z around 0 72.1%
if -1.64999999999999997e26 < x < -4.7000000000000001e-23 or 2.20000000000000006e-144 < x < 4.00000000000000035e-111Initial program 93.1%
*-rgt-identity93.1%
fabs-sub93.1%
metadata-eval93.1%
metadata-eval93.1%
fabs-mul93.1%
metadata-eval93.1%
*-rgt-identity93.1%
associate-*l/99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
sub-neg99.8%
neg-mul-199.8%
associate-*l/99.5%
remove-double-neg99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
Taylor expanded in z around inf 93.8%
if -4.7000000000000001e-23 < x < 2.20000000000000006e-144 or 4.00000000000000035e-111 < x < 1.49999999999999994e-35Initial program 97.3%
Taylor expanded in x around 0 79.1%
if 1.49999999999999994e-35 < x < 9.50000000000000002e182Initial program 89.8%
*-rgt-identity89.8%
fabs-sub89.8%
metadata-eval89.8%
metadata-eval89.8%
fabs-mul89.8%
metadata-eval89.8%
*-rgt-identity89.8%
associate-*l/90.2%
div-sub95.2%
sub-neg95.2%
+-commutative95.2%
remove-double-neg95.2%
distribute-neg-in95.2%
sub-neg95.2%
neg-mul-195.2%
associate-*l/95.0%
remove-double-neg95.0%
distribute-lft-neg-in95.0%
distribute-rgt-neg-in95.0%
Simplified95.0%
Taylor expanded in z around inf 52.8%
*-commutative52.8%
associate-*l/64.5%
Applied egg-rr64.5%
Final simplification75.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* z (/ x y)))))
(if (<= x -1.4e+26)
t_0
(if (<= x -7.8e-22)
t_1
(if (<= x 3.8e-36) (fabs (/ 4.0 y)) (if (<= x 3.8e+182) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((z * (x / y)));
double tmp;
if (x <= -1.4e+26) {
tmp = t_0;
} else if (x <= -7.8e-22) {
tmp = t_1;
} else if (x <= 3.8e-36) {
tmp = fabs((4.0 / y));
} else if (x <= 3.8e+182) {
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((z * (x / y)))
if (x <= (-1.4d+26)) then
tmp = t_0
else if (x <= (-7.8d-22)) then
tmp = t_1
else if (x <= 3.8d-36) then
tmp = abs((4.0d0 / y))
else if (x <= 3.8d+182) 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((z * (x / y)));
double tmp;
if (x <= -1.4e+26) {
tmp = t_0;
} else if (x <= -7.8e-22) {
tmp = t_1;
} else if (x <= 3.8e-36) {
tmp = Math.abs((4.0 / y));
} else if (x <= 3.8e+182) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((z * (x / y))) tmp = 0 if x <= -1.4e+26: tmp = t_0 elif x <= -7.8e-22: tmp = t_1 elif x <= 3.8e-36: tmp = math.fabs((4.0 / y)) elif x <= 3.8e+182: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(z * Float64(x / y))) tmp = 0.0 if (x <= -1.4e+26) tmp = t_0; elseif (x <= -7.8e-22) tmp = t_1; elseif (x <= 3.8e-36) tmp = abs(Float64(4.0 / y)); elseif (x <= 3.8e+182) 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((z * (x / y))); tmp = 0.0; if (x <= -1.4e+26) tmp = t_0; elseif (x <= -7.8e-22) tmp = t_1; elseif (x <= 3.8e-36) tmp = abs((4.0 / y)); elseif (x <= 3.8e+182) 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.4e+26], t$95$0, If[LessEqual[x, -7.8e-22], t$95$1, If[LessEqual[x, 3.8e-36], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.8e+182], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-36}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+182}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.4e26 or 3.80000000000000013e182 < x Initial program 84.8%
Taylor expanded in x around inf 99.8%
*-commutative99.8%
sub-neg99.8%
mul-1-neg99.8%
distribute-lft-in89.3%
associate-*r/89.5%
*-rgt-identity89.5%
mul-1-neg89.5%
distribute-rgt-neg-in89.5%
unsub-neg89.5%
*-lft-identity89.5%
associate-/l*89.3%
*-commutative89.3%
associate-/r/84.6%
div-sub99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in z around 0 72.1%
if -1.4e26 < x < -7.79999999999999996e-22 or 3.79999999999999971e-36 < x < 3.80000000000000013e182Initial program 91.7%
*-rgt-identity91.7%
fabs-sub91.7%
metadata-eval91.7%
metadata-eval91.7%
fabs-mul91.7%
metadata-eval91.7%
*-rgt-identity91.7%
associate-*l/92.1%
div-sub96.2%
sub-neg96.2%
+-commutative96.2%
remove-double-neg96.2%
distribute-neg-in96.2%
sub-neg96.2%
neg-mul-196.2%
associate-*l/95.9%
remove-double-neg95.9%
distribute-lft-neg-in95.9%
distribute-rgt-neg-in95.9%
Simplified95.9%
Taylor expanded in z around inf 60.4%
*-commutative60.4%
associate-*l/69.6%
Applied egg-rr69.6%
if -7.79999999999999996e-22 < x < 3.79999999999999971e-36Initial program 96.6%
Taylor expanded in x around 0 76.1%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (if (<= y -1e+32) (fabs (- (/ (+ x 4.0) y) (/ x (/ y z)))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+32) {
tmp = fabs((((x + 4.0) / y) - (x / (y / z))));
} 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 (y <= (-1d+32)) then
tmp = abs((((x + 4.0d0) / y) - (x / (y / z))))
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 (y <= -1e+32) {
tmp = Math.abs((((x + 4.0) / y) - (x / (y / z))));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+32: tmp = math.fabs((((x + 4.0) / y) - (x / (y / z)))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+32) tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x / Float64(y / z)))); 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 (y <= -1e+32) tmp = abs((((x + 4.0) / y) - (x / (y / z)))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+32], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $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}\;y \leq -1 \cdot 10^{+32}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if y < -1.00000000000000005e32Initial program 96.3%
associate-*l/89.4%
associate-/l*99.8%
Applied egg-rr99.8%
if -1.00000000000000005e32 < y Initial program 90.5%
associate-*l/94.1%
sub-div99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -1.95e+28)
t_0
(if (<= x -2.9e-26)
(fabs (* x (/ z y)))
(if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -1.95e+28) {
tmp = t_0;
} else if (x <= -2.9e-26) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} 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) :: tmp
t_0 = abs((x / y))
if (x <= (-1.95d+28)) then
tmp = t_0
else if (x <= (-2.9d-26)) then
tmp = abs((x * (z / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
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 tmp;
if (x <= -1.95e+28) {
tmp = t_0;
} else if (x <= -2.9e-26) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -1.95e+28: tmp = t_0 elif x <= -2.9e-26: tmp = math.fabs((x * (z / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -1.95e+28) tmp = t_0; elseif (x <= -2.9e-26) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -1.95e+28) tmp = t_0; elseif (x <= -2.9e-26) tmp = abs((x * (z / y))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.95e+28], t$95$0, If[LessEqual[x, -2.9e-26], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-26}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.9499999999999999e28 or 4 < x Initial program 85.5%
Taylor expanded in x around inf 99.5%
*-commutative99.5%
sub-neg99.5%
mul-1-neg99.5%
distribute-lft-in90.1%
associate-*r/90.3%
*-rgt-identity90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
unsub-neg90.3%
*-lft-identity90.3%
associate-/l*90.2%
*-commutative90.2%
associate-/r/86.8%
div-sub99.5%
associate-/r/99.5%
Simplified99.5%
Taylor expanded in z around 0 66.9%
if -1.9499999999999999e28 < x < -2.8999999999999998e-26Initial program 99.4%
*-rgt-identity99.4%
fabs-sub99.4%
metadata-eval99.4%
metadata-eval99.4%
fabs-mul99.4%
metadata-eval99.4%
*-rgt-identity99.4%
associate-*l/99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
remove-double-neg99.8%
distribute-neg-in99.8%
sub-neg99.8%
neg-mul-199.8%
associate-*l/99.4%
remove-double-neg99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
Simplified99.4%
Taylor expanded in z around inf 90.8%
associate-*l/82.2%
*-commutative82.2%
Simplified82.2%
if -2.8999999999999998e-26 < x < 4Initial program 96.8%
Taylor expanded in x around 0 73.8%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.2e+106) (fabs (/ (* x z) y)) (if (<= z 5.4e+84) (fabs (/ (- -4.0 x) y)) (fabs (* z (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+106) {
tmp = fabs(((x * z) / y));
} else if (z <= 5.4e+84) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((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 (z <= (-1.2d+106)) then
tmp = abs(((x * z) / y))
else if (z <= 5.4d+84) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+106) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 5.4e+84) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.2e+106: tmp = math.fabs(((x * z) / y)) elif z <= 5.4e+84: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.2e+106) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 5.4e+84) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.2e+106) tmp = abs(((x * z) / y)); elseif (z <= 5.4e+84) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.2e+106], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 5.4e+84], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+106}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{+84}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -1.2e106Initial program 93.2%
*-rgt-identity93.2%
fabs-sub93.2%
metadata-eval93.2%
metadata-eval93.2%
fabs-mul93.2%
metadata-eval93.2%
*-rgt-identity93.2%
associate-*l/95.3%
div-sub95.3%
sub-neg95.3%
+-commutative95.3%
remove-double-neg95.3%
distribute-neg-in95.3%
sub-neg95.3%
neg-mul-195.3%
associate-*l/95.3%
remove-double-neg95.3%
distribute-lft-neg-in95.3%
distribute-rgt-neg-in95.3%
Simplified95.3%
Taylor expanded in z around inf 86.5%
if -1.2e106 < z < 5.4e84Initial program 93.9%
*-rgt-identity93.9%
fabs-sub93.9%
metadata-eval93.9%
metadata-eval93.9%
fabs-mul93.9%
metadata-eval93.9%
*-rgt-identity93.9%
associate-*l/97.0%
div-sub99.5%
sub-neg99.5%
+-commutative99.5%
remove-double-neg99.5%
distribute-neg-in99.5%
sub-neg99.5%
neg-mul-199.5%
associate-*l/99.3%
remove-double-neg99.3%
distribute-lft-neg-in99.3%
distribute-rgt-neg-in99.3%
Simplified99.3%
Taylor expanded in z around 0 92.1%
associate-*r/92.1%
distribute-lft-in92.1%
metadata-eval92.1%
neg-mul-192.1%
sub-neg92.1%
Simplified92.1%
if 5.4e84 < z Initial program 83.0%
*-rgt-identity83.0%
fabs-sub83.0%
metadata-eval83.0%
metadata-eval83.0%
fabs-mul83.0%
metadata-eval83.0%
*-rgt-identity83.0%
associate-*l/78.0%
div-sub92.2%
sub-neg92.2%
+-commutative92.2%
remove-double-neg92.2%
distribute-neg-in92.2%
sub-neg92.2%
neg-mul-192.2%
associate-*l/92.1%
remove-double-neg92.1%
distribute-lft-neg-in92.1%
distribute-rgt-neg-in92.1%
Simplified92.1%
Taylor expanded in z around inf 84.4%
*-commutative84.4%
associate-*l/89.4%
Applied egg-rr89.4%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (fabs (/ (- (+ x 4.0) (* x z)) y)))
double code(double x, double y, double z) {
return fabs((((x + 4.0) - (x * z)) / 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((((x + 4.0d0) - (x * z)) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) - (x * z)) / y));
}
def code(x, y, z): return math.fabs((((x + 4.0) - (x * z)) / y))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) - (x * z)) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|
\end{array}
Initial program 91.7%
associate-*l/93.1%
sub-div97.4%
Applied egg-rr97.4%
Final simplification97.4%
(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 86.2%
Taylor expanded in x around inf 99.5%
*-commutative99.5%
sub-neg99.5%
mul-1-neg99.5%
distribute-lft-in90.6%
associate-*r/90.8%
*-rgt-identity90.8%
mul-1-neg90.8%
distribute-rgt-neg-in90.8%
unsub-neg90.8%
*-lft-identity90.8%
associate-/l*90.6%
*-commutative90.6%
associate-/r/87.4%
div-sub99.5%
associate-/r/99.5%
Simplified99.5%
Taylor expanded in z around 0 63.9%
if -10.5 < x < 4Initial program 96.9%
Taylor expanded in x around 0 72.4%
Final simplification68.3%
(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.7%
Taylor expanded in x around 0 39.5%
Final simplification39.5%
herbie shell --seed 2023171
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))