II'm currently writing a code to generate solar system and $N$ number of planets / moons.
I use real data to test (earth / sun / moon data).
iI succeeded in placing the earth and make it orbit around the sun using the correct mass and velocity. But when iI place the moon around the earth and launch the simulation , the moon is a kind of ignore the earth:ignoring Earth.
At start $(x,y)$:
Sun : 0,0
Earth : 1.4959826e8
Moon : 1.4959826e8-384400
using $F = (G \times a.mass \times b.mass) / (dist \times dist)$
At start $F$:
Sun & Earth: 3.5855635298968626E22
Earth & moon : 1.9817101152925866E20
Moon & Sun: 4.379973928784021E20
Since I placed them on $y=0$, moon has an $f_y$ of $0$ and $f_x$ of -2.39826381349143456E17 (because she's placed between sun and earth
At start, the moon has a velocity of 0.001022 km/sec
After velocity update ($v = v + dt \times F / mass$)
$v =$ 0.28200845732138924
$v_x =$ -0.28200660544886147
$v_y =$ 0.001022
So regarding the result, it make sense that the moon is attracted more by the sun than the earth (since vx is negative), but why? Where in my formulas I make a mistake ? I tested also to start the simulation with the velocity of moon = 29.783 + 0.001022 , (earth velocity) but then the moon just turn around the sun like the earth
(I surely forgot to put some info, don't hesitate to tell me to add things , I'm not really used to ask physics questions)
(Here's a video if you want an idea of what happen)