A method based on the Newtonian and relativistic theories of body motion is proposed for calculating the density of dark matter, which, like visible (baryonic) matter, creates a gravitational field. Experimental data obtained by the Pioneer 10 and Pioneer 11 spacecraft and a variety of astronomical observations are used to detect and establish the mass of dark matter in the solar system, which turned out to be approximately equal to the mass of the Sun. Using the equations of motion of test bodies in the Newtonian and post-Newtonian approximations of the general theory of relativity, calculation formulas are obtained for calculating the density of dark matter in three cases: 1) baryonic and dark matter are uniformly distributed in space (their density is constant); 2) they are distributed according to spherically symmetrical laws; 3) baryonic matter is distributed spherically symmetrically, while dark matter is uniformly distributed. In the volume of a sphere with radius of 45 a. u. with the center in the center of gravity of the Sun, on the basis of known experimental data, the average density of the gas-dust and relict matter located in it is calculated, equal to 1,26 · 10–16 g · cm–3. In the same volume, the density of dark matter in all three cases varies according to the derived calculation formulas in the range from 3,38 · 10–16 to 3,34 · 10–16 g · cm–3, which gives the superiority of dark matter over baryonic one from 2.68 to 2.72 times. The given numerical estimates may change when the experimental data used change. The paper also contains a brief discussion of other methods for calculating the density of dark matter in space and a comparison with our results.