Vih, your task can be solved in one step :)
Added 1 minute ago
But in general, the task is about mathematical modeling, and K.O. suggests that they are solved by building a mathematical model!
Bow down and hear our cry,
Our earthly rulers falter,
Our people drift and die,
The walls of gold entomb us,
The swords of scorn divide,
Take not thy thunder from us,
Take away our pride.
G.K. Chesterton: English Hymnal