0
$\begingroup$

I am having trouble solving this set of two coupled differential equations using NDSolve:

$$\left[\left\{-\frac{\mu _0 Q_e M_{\text{earth}} \text{vy}(t)}{4 \pi m_e \left(\left(5 R_{\text{earth}}-t \text{vx}(t)\right){}^2+t^2 \text{vy}(t)^2\right){}^4}=\text{vx}'(t),\frac{\mu _0 Q_e M_{\text{earth}} \text{vx}(t)}{4 \pi m_e \left(\left(5 R_{\text{earth}}-t \text{vx}(t)\right){}^2+t^2 \text{vy}(t)^2\right){}^4}=\text{vy}'(t),\text{vx}(0)=480000,\text{vy}(0)=0\right\},\{\text{vx},\text{vy}\},\{t,0,30\}\right]$$

NOTE: all the variables are defined prior to this, the same problem arises when I sub in numerical values. I am only using them here to make it easier for everyone to read.

The input code was the same as above expression:

NDSolve[{-((
    Subscript[M, earth] Subscript[Q, e] Subscript[\[Mu], 0] vy[t])/(
    4 \[Pi] Subscript[m, 
     e] ((5 Subscript[R, earth] - t vx[t])^2 + t^2 vy[t]^2)^4)) == 
   Derivative[1][vx][t], (
   Subscript[M, earth] Subscript[Q, e] Subscript[\[Mu], 0] vx[t])/(
   4 \[Pi] Subscript[m, 
    e] ((5 Subscript[R, earth] - t vx[t])^2 + t^2 vy[t]^2)^4) == 
   Derivative[1][vy][t], vx[0] == 480000, vy[0] == 0}, {vx, vy}, {t, 
  0, 30}]

There was a runtime error:

"NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`."

I followed the documentations when writing the input, is there anything else I should add?

$\endgroup$

closed as off-topic by zhk, m_goldberg, LCarvalho, bbgodfrey, xzczd Oct 18 '17 at 6:45

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." – zhk, m_goldberg, LCarvalho, bbgodfrey, xzczd
If this question can be reworded to fit the rules in the help center, please edit the question.

1
$\begingroup$

You need to assign values to all the parameters. I choose random ones,

Subscript[M, earth] = 1; Subscript[Q, e] = 1; Subscript[μ, 0] = 1;
 Subscript[m, e] = 1; Subscript[R, earth] = 1;

sol = NDSolve[{-((Subscript[M, earth] Subscript[Q, e] Subscript[μ,
           0] vy[t])/(4 π Subscript[m, 
          e] ((5 Subscript[R, earth] - t vx[t])^2 + 
            t^2 vy[t]^2)^4)) == 
    Derivative[1][vx][
     t], (Subscript[M, earth] Subscript[Q, e] Subscript[μ, 0] vx[
        t])/(4 π Subscript[m, 
        e] ((5 Subscript[R, earth] - t vx[t])^2 + t^2 vy[t]^2)^4) == 
    Derivative[1][vy][t], vx[0] == 480000, vy[0] == 0}, {vx, vy}, {t, 
   0, 30}]

Plot[{vx[t], vy[t]} /. sol, {t, 0, 30}]
$\endgroup$
  • $\begingroup$ Thanks for your reply zhk! I did assign values for all the parameters prior to using ty $\endgroup$ – Z.Yang Oct 16 '17 at 12:11
  • $\begingroup$ But replacing what I had with the rest of your code, I was able to get a solution. But what I get now, as a solution is this InterpolatingFunction, is this normal? $\endgroup$ – Z.Yang Oct 16 '17 at 12:12
  • $\begingroup$ @Z.Yang Yes it. Check documentation on NDSolve $\endgroup$ – zhk Oct 16 '17 at 13:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.