# [✓] Solve a path for the flight of a ball?

GROUPS:
 Hello all,I've run into a problem while I was trying to solve a path for the flight of a ball with lift force and drag. Sadly, even after searching the forums and reading the most common beginner mistakes post I still haven't found the issue. I fear it has to do with my defining of functions and use of DSolve, but I find the issue. Here is my code: ClearGlobal[] := (ClearAll["Global*"]; Clear[Derivative];); ClearGlobal[] (* First I start off by defining a few initial values. I hope the correct way to define these is with the ":=". *) cl := 0.3 m := 0.050 rball := 0.02 g := 9.81 vi := 60 cd := 0.3 \[Rho] := 1.225 g := 9.81 (* Here are some numerical calculations that have to be done. Again, I think the ":=" Is needed. *) area := Pi*rball^2 \[Alpha]d := (1/2)*\[Rho]*area*cd \[Alpha]l := (1/2)*\[Rho]*area*cl (* Here I define the position of the ball as 'r'. It's position as the time-derivative of r. And finally a vector that is dependant on v's direction in order to orient the lifting force due to spindrift. *) r[x_, y_] := {x, y} v := D[r, t] l := Normalize[Rotate[v, Pi/2]] (* Here are the supplied equations for the problem. The drag and lift forces are proportional to a constant and the velocity, with a direction given by l and normalizing v. *) fd[v_] :=-\[Alpha]d*Abs[v]^2*Normalize[v] fl[v_] := \[Alpha]l*Abs[v]^2*l fl[v_] := -m*g*{0, 1} (* This is the total force on the ball in flight. *) f[t_] := fd[v]+fd[v]+fd[v] (* This is a fuction for the acceleration, which i want to solve using the acceleration given by taking the second derivative of r. *) a[t_] := f[t]/m (* Here I try to solve for x and y using these initial values. *) DSolve[{D[r, {t, 2}] == a[t], x[0]==0, y[0]==0, v[0]==60}, x[t], {t,0,10}] (* And now, as you can see it doesn't recognize the functions, but just outputs that it is true. I'm quite sure there is a problem with my defining of functions or the setup of my Dsolve. *) Any help for this newbie would be greatly appreciated, as I couldn't find it myself.
5 months ago
4 Replies
 Bill Simpson 1 Vote Let's start with fd[v_] :=-αd*Abs[v]^2*Normalize[v] fl[v_] := αl*Abs[v]^2*l fl[v_] := -m*g*{0, 1} f[t_] := fd[v]+fd[v]+fd[v] Do you perhaps mean something more like fd[v_] :=-αd*Abs[v]^2*Normalize[v] fl[v_] := αl*Abs[v]^2*l fg[v_] := -m*g*{0, 1} f[t_] := fd[v]+fl[v]+fg[v] But that definition of f[t] doesn't seem right either. Maybe you mean f[v_]:=fd[v]+fl[v]+fg[v] but I'm not sure that is right either.Next let's look at a[t] In[20]:= a[t_] := f[t]/m a[t] Out[20]= {0., -9.81} and that value is unchanged if I try a[0] or a[5] or a[1000].Next let's look at what you are going to give to DSolve In[21]:= {D[r, {t, 2}] == a[t], x[0] == 0, y[0] == 0, v[0] == 60} Out[21]= {0 == {0., -9.81}, x[0] == 0, y[0] == 0, 0[0] == 60} That doesn't look like a differential equation.Can you use this to try to fix some problems before you try to give it to DSolve?
 Thank you all for the help! I was finally able to solve the problem. For any future reader who is encountering the same problem I will leave my code below. ClearGlobal[] := (ClearAll["Global*"]; Clear[Derivatives];); ClearGlobal[] cl := 0.3 m := 0.050 rball := 0.02 cd := 0.3 \[Rho] := 1.225 g := 9.81 v0 := 60 area := Pi*rball^2 \[Alpha]d := (1/2)*\[Rho]*area*cd \[Alpha]l := (1/2)*\[Rho]*area*cl \[Theta] := Pi/3 v1 := v0*{Cos[\[Theta]], Sin[\[Theta]]} v[t_] := r'[t] fd[t_] := -\[Alpha]d*Norm[v[t]]^2*Normalize[v[t]] fl[t_] := \[Alpha]l*Norm[v[t]]^2*RotationMatrix[Pi/2].Normalize[v[t]] fg[t_] := -m*g*{0, 1} f[t_] := fd[t]+fl[t]+fg[t] a[t_] := f[t]/m sol = NDSolve[{r''[t] == a[t], r[0]=={0,0}, v[0]==v1}, r[t], {t,0,10}]; ParametricPlot[Evaluate[r[t] /. First[%], {t, 0, 10}]]