  Inelasticity--the fraction of a neutrino's energy transferred to hadrons--is
a quantity of interest in the study of astrophysical and atmospheric neutrino
interactions at multi-TeV energies with IceCube. In this work, a sample of
contained neutrino interactions in IceCube is obtained from 5 years of data and
classified as 2650 tracks and 965 cascades. Tracks arise predominantly from
charged-current $\nu_{\mu}$ interactions, and we demonstrate that we can
reconstruct their energy and inelasticity. The inelasticity distribution is
found to be consistent with the calculation of Cooper-Sarkar et al. across the
energy range from $\sim$ 1 TeV to $\sim$ 100 TeV. Along with cascades from
neutrinos of all flavors, we also perform a fit over the energy, zenith angle,
and inelasticity distribution to characterize the flux of astrophysical and
atmospheric neutrinos. The energy spectrum of diffuse astrophysical neutrinos
is well-described by a power-law in both track and cascade samples, and a
best-fit index $\gamma=2.62\pm0.07$ is found in the energy range from 3.5 TeV
to 2.6 PeV. Limits are set on the astrophysical flavor composition that are
compatible with a ratio of
$\left(\frac{1}{3}:\frac{1}{3}:\frac{1}{3}\right)_{\oplus}$. Exploiting the
distinct inelasticity distribution of $\nu_{\mu}$ and $\bar{\nu}_{\mu}$
interactions, the atmospheric $\nu_{\mu}$ to $\bar{\nu}_{\mu}$ flux ratio in
the energy range from 770 GeV to 21 TeV is found to be $0.77^{+0.44}_{-0.25}$
times the calculation by Honda et al. Lastly, the inelasticity distribution is
also sensitive to neutrino charged-current charm production. The data are
consistent with a leading-order calculation, with zero charm production
excluded at $91\%$ confidence level. Future analyses of inelasticity
distributions may probe new physics that affects neutrino interactions both in
and beyond the Standard Model.
