# Syntax Error in NDSolve Code [closed]

I am trying to solve the motion equations for the Trojan Asteroids in Sun-Jupiter system. However, i am getting this error

Syntax: '(' cannot be followed by 'x[t],y[t]'

in this code

Alpha = 0.000953875;
r_1 = Sqrt[(x - Alpha)^2 + y^2];
r_2 = Sqrt[(x + 1 - Alpha)^2 + y^2];
x_0 = -0.509;
y_0 = 0.883;
u_0 = 0.0259;
v_0 = 0.0149;

NDSolve[
{x'[t] == u[t],

y'[t] == v[t],

u'[t] == -(1 - Alpha) (x[t] - Alpha)/r_1 (x[t],  y[t])^3 - Alpha (x[t] +

1 - Alpha)/r_2(x[t], y[t])^3 + x[t] + 2 v[t],

v'[t] == -(1 - Alpha) y[t]/r_1 (x[t],

y[t])^3 - Alpha y[t]/r_2 (x[t], y[t])^3 + y[t] - 2 u[t],

x[0] == x_0, y[0] == y_0,

u[0] == u_0, v[0] == v_0},

{x, y, u, v}, {t, 0, t_max}]


Of course, i am extremely average at coding, so any kind of help will suffice

Thanks

## closed as off-topic by Szabolcs, Henrik Schumacher, Chris K, MarcoB, m_goldbergSep 4 '18 at 21:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Henrik Schumacher, Chris K, MarcoB, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• The _ has a predefined meaning in MMA. Try removing all those that you have used inside variable names and see how much that helps. – Bill Sep 3 '18 at 6:33
• My advice is to learn the basics before trying to do something complicated: go through a tutorial. Here you started to guess at the syntax (instead of looking it up), and of course not every guess was correct. At this stage, it's too early to ask questions on Mathematica.SE. Please make sure you have at least a basic understanding of the language before you ask. – Szabolcs Sep 3 '18 at 9:08
• Thank you everyone for the advice, i will definitely study basics before trying more complex things – Hector Manuel Chacon Carrillo Sep 3 '18 at 19:42

In addition to _ there is still a misuse of functions in () instead of []

Alpha = 0.000953875;
r01[x_, y_] := Sqrt[(x - Alpha)^2 + y^2];
r02[x_, y_] := Sqrt[(x + 1 - Alpha)^2 + y^2];
x00 = -0.509;
y00 = 0.883;
u00 = 0.0259;
v00 = 0.0149;
tmax = 100;

sol = NDSolve[{x'[t] == u[t], y'[t] == v[t],
u'[t] == -(1 - Alpha) (x[t] - Alpha)/r01[x[t], y[t]]^3 -
Alpha (x[t] + 1 - Alpha)/r02[x[t], y[t]]^3 + x[t] + 2 v[t],
v'[t] == -(1 - Alpha) y[t]/r01[x[t], y[t]]^3 -
Alpha y[t]/r02[x[t], y[t]]^3 + y[t] - 2 u[t], x[0] == x00,
y[0] == y00, u[0] == u00, v[0] == v00}, {x, y, u, v}, {t, 0, tmax}];

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, tmax}]