  Because of its proximity and the large size of its black hole, M87 is one of
the best targets for studying the launching mechanism of active galactic
nucleus jets. Currently, magnetic fields are considered to be an essential
factor in the launching and accelerating of the jet. However, current
observational estimates of the magnetic field strength of the M87 jet are
limited to the innermost part of the jet or to HST-1. No attempt has yet been
made to measure the magnetic field strength in between. We aim to infer the
magnetic field strength of the M87 jet out to a distance of several thousand
$r_s$ by tracking the distance-dependent changes in the synchrotron spectrum of
the jet from high-resolution very long baseline interferometry observations. In
order to obtain high-quality spectral index maps, quasi-simultaneous
observations at 22 and 43 GHz were conducted using the KVN and VERA Array
(KaVA) and the VLBA. We compared the spectral index distributions obtained from
the observations with a model and placed limits on the magnetic field strengths
as a function of distance. The overall spectral morphology is broadly
consistent over the course of these observations. The observed synchrotron
spectrum rapidly steepens from $\alpha_{22-43 GHz}$ ~ -0.7 at ~ 2 mas to
$\alpha_{22-43 GHz}$ ~ -2.5 at ~ 6 mas. A spectral index model in which
nonthermal electron injections inside the jet decrease with distance can
adequately reproduce the observed trend. This suggests the magnetic field
strength of the jet at a distance of 2 - 10 mas (~ 900 $r_s$ - ~ 4500 $r_s$ in
the deprojected distance) has a range of $B=(0.3 - 1.0 G)(z/2 mas)^{-0.73}$.
Extrapolating to the EHT scale yields consistent results, suggesting that the
majority of the magnetic flux of the jet near the black hole is preserved out
to ~ 4500 $r_s$ without significant dissipation.
