**Purpose.** To create an algorithm for constructing a three-dimensional masses distribution function of the planet and its derivatives taking into account the Stokes constants of arbitrary orders. Being based on this method, the task is to perform the research on the internal structure of the Earth. **Methodology**. The derivatives of the inhomogeneous mass distribution are presented by linear combinations of biorthogonal polynomials which coefficients are obtained from the system of equations. These equations follow from integral transformations of the Stokes constants, the calculation process is carried out by a sequential approximation and for the initial approximation we take a one-dimensional density model that is consistent with Stokes constants up to the second inclusive order. Next, the coefficients of expansion of the potential of higher orders are determined up to a predetermined order. In this case, the information on the power moments of the density of surface integrals makes it possible to analyze and control the iterative process. **Results.** The results of calculations using the software according to the described algorithm are obtained. A fairly high degree of approximation (sixth order) of three-dimensional mass distributions function is achieved. Carto diagrams were created being based on the values of deviations of the three-dimensional average distributions (“isodens”), which give a fairly detailed picture of the Earth’s internal structure. The presented maps of “inhomogeneity’s” at characteristic depths (2891 km core – mantle, 5150 km internal – external core) allow us to draw preliminary conclusions about global mass movements. At the same time, the information on derivatives is significant for interpretation. First of all, it should be noted that the gradient of “inhomogeneity’s” is directed toward the center of mass. The presented projections of this gradient on a plane perpendicular to the rotation axis (horizontal plane) show the tendency of spatial displacements. **Scientific novelty**. Vector diagrams of the gradient, in combination with carto diagrams, give a broad picture of the dynamics and possible mechanisms of mass movement within the planet. To a certain extent, these studies confirm the phenomenon of gravitational convection of masses. **Practical significance.** The proposed algorithm can be used in order to build regional models of the planet, and numerical results can be used to interpret global and local geodynamic processes inside and on the Earth’s surface.

1. Bullen, K. E. (1975). The earth's density. London, Chapman and Hall.

https://doi.org/10.1007/978-94-009-5700-8

2. Chernyaga, P. G., & Fys, M. M. (2012). A new approach to the use of Stokes constants for the construction of functions and its derivatives of mass distribution of planets. Collection of scientific works of Western geodesic society UTGK "Modern achievements in geodetic science and production". II (24), 40-43. (in Ukrainian).

3. Dzewonski, A., & Anderson, D. (1981). Preliminary reference Earth model. Physics of the earth and planetary interiors, 25(4), 297-356. doi: 10.1016/0031-9201(81)90046-7.

https://doi.org/10.1016/0031-9201(81)90046-7

4. Fys, M. M., Zazulyak, P. M., & Chernyaga, P. G. (2013). Values of Densities and their Variations at the Barycenters of Ellipsoidal Planets. Kinematics and physics of celestial bodies 29(2), 62-68. (in Ukrainian). https://www.mao.kiev.ua/biblio/jscans/kfnt/2013-29/kfnt-2013-29-2-06.pdf

https://doi.org/10.3103/S0884591313020025

5. Fys, M., Zazuliak, P., & Zajats', O. (2004). On the question of determining spherical functions in a general planetary coordinate system Collection of scientific works of Western geodesic society UTGK "Modern achievements in geodetic science and production". I (7), 401-408. (in Ukrainian).

6. Fys, M. M., Brydun, A. M., Yurkiv, M. I., & Sohor A. R.(2018). On definition of a function by its derivatives, represented by combinations of legendre polynomials of three variables. Young Scientist, 63(11). (in Ukrainian). http://molodyvcheny.in.ua/files/journal/2018/11/91.pdf

7. Fys, M., Yurkiv, M., Brydun, A., & Lozynskyi, V. (2016). One option of constructing three-dimensional distribution of the mass and its derivatives for a spherical planet earth. Geodynamics, 2(21), 36-44. https://doi.org/10.23939/jgd2016.02.036

https://doi.org/10.23939/jgd2016.02.036

8. Fys, M., Brydun, A., & Yurkiv, M. (2018). Method for approximate construction of three-dimensional mass distribution function and gradient of an elipsoidal planet based on external gravitational field parameters. Geodynamics, 2 (25), 27-36. https://doi.org/10.23939/jgd2018.02.027

https://doi.org/10.23939/jgd2018.02.027

9. Martinee, Z., & Pec, K. (1987). Three-Dimensional Density Distribution Generating the Observed Gravity Field of Planets: Part I. The Earth. In Figure and Dynamics of the Earth, Moon and Planets (p. 129). http://articles.adsabs.harvard.edu/full/conf/fdem./1987//0000129.000.html

10. Martinee, Z., & Pec, K. (1987). Three-Dimensional Density Distribution Generating the Observed Gravity Field of Planets: Part II. The Moon. In Figure and Dynamics of the Earth, Moon and Planets (p. 153).

11. Meshcheriakov, H. O. (1975). Application of the Stokes constants of the Earth for correction of its mechanical models. Geodesy, Cartography and Aerial Photography. 21, 23-30. (in Russian). http://science.lpnu.ua/sites/default/files/journal-paper/2018/apr/10725/...

12. Meshcheryakov, G. A., & Fys, M. M. (1981). Determination of the Earth's interior density by series using biorthogonal polynomial systems. Theory and methods of interpretation of gravitational and magnetic anomalies. Kyiv, Naukova Dumka, 329-334. (in Russian)

13. Meshcheryakov, G. A., & Fys, M. M. (1986). Three-dimensional and reference density models of the Earth. Geophysical Journal. 8(4), 68-75.(in Russian).

14. Meshcheryakov, G. A., & Fys, M. M. (1990). Threedimensional density model of the Earth І. Geophysical Journal. 12(4), 50-57.(in Russian).

15. Meshcheryakov, G. A., & Fys, M. M. (1990). Threedimensional density model of the Earth ІI.

16. Meshcheriakov, G. (1991). Problems of potential theory and generalized Earth. M: Science, Сhief editor of physical and mathematical literature. (in Russian).

17. Moritz, H. (1973). Ellipsoidal mass distributions. Report No. 206, Department of Geodetic Science, The Ohio State University, Columbus, Ohio.

18. Tserklevych, A. L., Zayats, O. S., & Fys, M. M. (2012). Earth group planets gravitational models of 3-d density distributions. Geodynamics, 1(12), 42-53. (in Ukrainian). https://doi.org/10.23939/jgd2012.01.042

https://doi.org/10.23939/jgd2012.01.042