2
$\begingroup$

Im attempting to use the NDSolve funtction to solve a coupled system of 2nd order differential equations. The differential equations are the for the acceleration of a body due to the gravitational forces of other bodies

Where

enter image description here

and

enter image description here

variables

μ = 
 {0.00029591220828349645438389263285760599`10.122911634152604, 
  8.8876924487802410900708441245`8.697447781980085*^-10, 
  1.0931894685338682`*^-11}; 
rx = {0, 0.9832672274945706, 0.9847793657772581}
v = {0, 0.017491119160350586, 0.017965913470733775};

Code for NDSolve

eqn = 
 {x[i]''[t] == 
    Sum[
      If[j == i, 
        0, 
        (-μ[[j]] (x[i][t] - x[j][t]))/((x[i][t] - x[j][t])^2 + (y[i][t] - y[j][t])^2)^(3/2)], 
      {i, 3}, {j, 3}], 
  y[i]''[t] == 
    Sum[
      If[j == i, 
        0, 
        (-μ[[j]] (y[i][t] - y[j][t]))/((x[i][t] - x[j][t])^2 + (y[i][t] - y[j][t])^2)^(3/2)], 
      {i, 3}, {j, 3}]};

var = Table[{x[0] == rx[[i]], y[0] == 0,[x]'[0] == 0, [y]'[0] == v[[i]]}, {i, 3}]

soln = Table[NDSolve[{eqn, var, {x[i], y[i]}}, {t, 0, 365.2}], {i, 3}];

Problem

When I run this, I recieve the following error:

NDSolve::argm: NDSolve called with 2 arguments; 3 or more arguments are expected.

What is wrong with this code?

$\endgroup$
7
  • $\begingroup$ Don't wrap all the arguments to NDSolve in {}. $\endgroup$
    – Chris K
    Oct 23, 2019 at 10:00
  • $\begingroup$ So it should be: `soln = Table[NDSolve[eqn, var, {x[i], y[i]}, {t, 0, 365.2}], {i, 3}]; ? $\endgroup$
    – isaac5122
    Oct 23, 2019 at 10:02
  • $\begingroup$ Sorry it's not clear what your code is supposed to do. $\endgroup$
    – Chris K
    Oct 23, 2019 at 10:13
  • $\begingroup$ its a system of coupled ODE's to show the acceleration of a body due to gravitational forces of other bodies, ive updated the question with more detail. I hope this helps $\endgroup$
    – isaac5122
    Oct 23, 2019 at 10:17
  • $\begingroup$ To get three arguments, try moving one brace: NDSolve[{eqn, var}, {x[i], y[i]}, {t, 0, 365.2}] $\endgroup$
    – Michael E2
    Oct 23, 2019 at 10:57

0

Browse other questions tagged or ask your own question.