Three Body Problem
Description:
Three-body problem
Hello Everyone,
There is a famous problem in physics that can (only) be solved using Computers: The Three-body problem.
It is the problem of computing the trajectories of three bodies where their initial velocities, positions and masses are given. In this Kata you will solve the problem in 2d (all masses are on the same plane). You will receive three scalars m1, m2 and m3 as well as six lists (mathematical vectors) v1, v2, v3, p1, p2, p3 with two entries each describing the initial masses, velocities and positions of the three bodies respectively. You are expected to give the position of the FIRST mass after a total time sim_time has passed. The result needs to be in error range of +- 10 of the correct solution. The position should be returned as a list with two entries.
Note: time, positions, velocities and masses are all in "Units"
Also v, and p are vectors (lists):
vi = [vi_x, vi_y]
pi = [pi_x, pi_y]
solution = [p1_x, p1_y]
These differential equations govern the system:
where a1 to a3 are the accelerations of the masses respectively and G is the gravitational constant with
Note that these are vector equations. This means every single equations describes both the x and y components of the acceleration (ai) and position (pi) vectors.
Note that in this context the absolute of a 2d vector v = (v_x, v_y)
is defined as follows:
If your solution is slightly off the numerial error in your solution might be too great. Try decreasing the stepsize.
The wikipedia page describing the problem: https://en.wikipedia.org/wiki/Three-body_problem
Spoiler: One of the simplest numerical integrators: https://en.wikipedia.org/wiki/Euler_method
Note: Only initial conditions that lead to differential equations in the region of stability of the euler-cauchy integrator will be tested.
Similar Kata:
Stats:
Created | Aug 1, 2018 |
Warriors Trained | 63 |
Total Skips | 0 |
Total Code Submissions | 140 |
Total Times Completed | 19 |
Python Completions | 18 |
Total Stars | 5 |
% of votes with a positive feedback rating | 82% of 11 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |