3
$\begingroup$

I aim for using these differential equations to get y[t],x[t] and max range of projectile. I don't know if my physics is wrong or the code is wrong

  DSolve[
     {
      y'[0] == v0*Sin[a],
      y[0] == 0,
      m*y''[t] == -m*g,
      m*x''[t] == 0,
      x[0] == 0,
      x'[0] = v0*Cos[a]
      },
     {x, y}, {t, 0, 20}]
$\endgroup$
10
$\begingroup$

You had a syntax error. It should be == and not =. It is also better to break things out and write the ODEs on separate lines, and the ICs on separate lines, than to combine them - much easier to read and maintain. And since you are using DSolve, there is no need to fix the time span:

ClearAll[x,y,t,a,m,v0]

ode  = { m*y''[t] == -m*g, 
         m*x''[t] == 0 }

ic   = {y'[0] == v0*Sin[a], 
        y[0]  == 0, 
        x[0]  == 0, 
        x'[0] == v0*Cos[a]}

DSolve[ {ode, ic },  {x[t],y[t]},  t]

Mathematica graphics

If you had done the above, you would have more easily spotted the syntax error also.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ and a max range of projectile: Maximize[{1/2 (-g t^2 + 2 t v0 Sin[a]), Sin[a] > 0, v0 > 0, g > 0, t > 0}, t] $\endgroup$ – Mariusz Iwaniuk Dec 21 '17 at 15:28
  • $\begingroup$ @MariuszIwaniuk I dont understand the output. Wouldn't finding y==0 be better? $\endgroup$ – Ralnor Dec 21 '17 at 15:37
  • $\begingroup$ @Ralnor. Sure yes.:) $\endgroup$ – Mariusz Iwaniuk Dec 21 '17 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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