Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 372
Kernel: VPython
ParseError: KaTeX parse error: Undefined control sequence: \require at position 1: \̲r̲e̲q̲u̲i̲r̲e̲{cancel}ParseError: KaTeX parse error: Undefined control sequence: \require at position 1: \̲r̲e̲q̲u̲i̲r̲e̲{enclose}

Momentum

PY345

Momentum

  • the total momentum p=mv\vec{p}=m\vec{v} of an isolated system stays the same

  • a system is isolated if Fnet=0\vec{F}_\text{net}=0

  • Newton's Second Law is more accurately written as Fnet=dpdt\vec{F}_\text{net}=\frac{d\vec{p}}{dt}

Practice


For each situation below, indicate for what choice of system momentum will be conserved (if any).

  1. Two carts roll toward each other on a horizontal track and collide.

  2. Alice and Bob are on rollerblades and initially at rest. Alice abruptly pushes Bob from behind.

  3. Alice and Bob are on rollerblades and initially at rest. Alice and Bob both push away from one another with their hands.

  4. A ball is thrown downward and hits the earth.

  5. Two cars collide with each other.

  6. A ball hits a wall.

  7. A satellite slingshots around a comet.

Solution


  1. By choosing the system to be both carts, the only external forces are the gravitational force and the normal force, which cancel out because there is no vertical acceleration. If a single cart is chosen as the system, then the system would not be isolated because the interaction between the two carts would be external. two colliding carts

  2. Even though Alice and Bob both start from rest, the interaction diagram is the same as the colliding carts, so the reasoning is the same as before. Alice pushes Bob

  3. The interaction diagram is the same as before. It doesn't matter who is doing the pushing. Alice pushes Bob

  4. The only objects involved are the ball and the earth, and there are two types of interactions. The first interaction is through the gravitational field. The second interaction is the contact between the ball and the ground. The ball alone can't constitute an isolated system because both of those interactions with the earth would be considered external. The only choice of isolated system is ball + earth, in which case there are no external forces. This is why the force diagram has no force vectors on it. Note that we could have included interaction with air (drag) in this diagram (or any of these diagrams for that matter). That would make the system no longer isolated, but the effect of the drag is likely small enough to be negligible. ball hits earth

  5. This is similar to the colliding carts, except this time there is likely more friction between the cars and the ground. Furthermore, the amount of friction on each car is likely to be different, so technically the system is not isolated because the net force acting on the system of two cars is not zero. However, if we restrict ourselves to a narrow window of time from just before the collision to just after, then we could say that the small net force will not have had enough time to appreciably change the momentum of the system. We say that the system is momentarily isolated. If we look at a much larger window of time then we can no longer say that the system is isolated. two colliding cars

  6. In many collisions between two bodies, the two bodies together as a system is isolated. This is not one of those cases. The wall experience two (or arguably three) interactions with the earth. The first is gravitational, and the second is a contact force (both vertical and potentially horizontal) due to the fact that the wall is attached to the ground. Since the wall does not move when the ball hits it, that means that there must be a horizontal force on the wall from the ground. This is the force that makes ball + wall not isolated. The only choice of isolate system is ball + wall + earth. ball hits wall

  7. There is only one interaction between the satellite and the comet, and that is through the gravitational field. There are no external forces on the system if the system is chosen to be the satellite and comet together. satellite slingshot

Practice


Two cars collide at an intersection and stick together. Determine an expression for the final velocity of the two cars (just after they collide) in terms of their masses and initial velocities.

Solution


Assumptions

  • the masses of the cars are m1m_1 and m2m_2, and their initial velocities are v1\vec{v}_1 and v2\vec{v}_2, respectively

  • the cars are points masses

  • the final velocity of the two cars is vf\vec{v}_f

  • the two cars constitute a momentarily isolated system

Diagrams

two colliding cars

Analysis

If we consider a very short window of time from just before the collision to just after the collision, then the system consisting of the two cars is momentarily isolated. That means that the total momentum of the cars before the collision is equal to the total momentum of the system after the collision.

m1v1+m2v2=(m1+m2)vfm_1\vec{v}_1+m_2\vec{v}_2=(m_1+m_2)\vec{v}_f

Solve for vf\vec{v}_f.

vf=m1v1+m2v2m1+m2\vec{v}_f=\frac{m_1\vec{v}_1+m_2\vec{v}_2}{m_1+m_2}

Check

The units of our answer are [kg][m/s][kg]=[m/s]\frac{[kg][m/s]}{[kg]}=[m/s], which are what we expect for a velocity.

Let's check limiting cases. If m1=0m_1=0 then we would expect the final velocity to be equal to v2\vec{v}_2.

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{m_1\to …

The same argument applies if m2m1m_2\gg m_1.

Interpretation

Because the final velocity is a linear combination of the two initial velocities (with positive coefficients), that means that the final velocity will always be between the two initial velocities. For example, if one car travels north and the other east, then the final velocity will be somewhere between north and east.

Practice


A rocket shell is launched at an angle and travels along the usual parabolic path above flat ground. Right at the very peak of its path, it explodes into two pieces of equal mass. Just after the explosion, one of those pieces is observed to "stop dead" before falling straight to the ground. Determine the trajectory of the other piece.

Solution


Assumptions

  • the rocket shell is launched with speed v0v_0 at an angle of θ\theta from the horizontal

  • the rocket shell has mass mm before the explosion, and each of the pieces has mass m2\frac{m}{2}

  • the only force acting on the shell(s) before and after the collision is gravity

  • the shell is a point mass

  • drag is negligible

Diagrams

phase 1

phase 2

phase 3

Analysis

There are three phases to the motion: 1) the parabolic trajectory before the explosion, 2) the explosion itself, and 3) the trajectory after the explosion. Let's do one piece at a time.

  1. According to the free body diagram before the explosion

Fesg=my¨-F_{es}^g=m\ddot{y}

mg=my¨-\cancel{m}g=\cancel{m}\ddot{y}

and

0=mx¨0=m\ddot{x}.

By integrating these (which we have done previously), we arrive at the solutions

x(t)=v0cosθt+x0x(t)=v_0\cos\theta t+x_0

vx(t)=v0cosθv_x(t)=v_0\cos\theta

y(t)=12gt2+v0sinθt+y0y(t)=-\frac{1}{2}gt^2+v_0\sin\theta t+y_0

vy(t)=gt+v0sinθv_y(t)=-gt+v_0\sin\theta.

At the top of the trajectory vy(ttop)=0v_y(t_\text{top})=0.

vy(ttop)=gt+v0sinθ=0ttop=v0sinθgv_y(t_\text{top})=-gt+v_0\sin\theta=0\Rightarrow t_\text{top}=\frac{v_0\sin\theta}{g}

The x- and y-coordinates of the shell at this time are

xtop=v0cosθ(v0sinθg)+x0=v02sinθcosθg+x0x_\text{top}=v_0\cos\theta \left (\frac{v_0\sin\theta}{g}\right )+x_0=\frac{v_0^2\sin\theta\cos\theta}{g} +x_0

and

ytop=12g(v0sinθg)2+v0sinθ(v0sinθg)+y0=v02sin2θ2g+y0y_\text{top}=-\frac{1}{2}g\left (\frac{v_0\sin\theta}{g}\right )^2+v_0\sin\theta\left (\frac{v_0\sin\theta}{g}\right )+y_0=\frac{v_0^2\sin^2\theta}{2g}+y_0

  1. The two pieces of the shell are not truly isolated during the explosion, but it is reasonable to approximate that they are momentarily isolated. Therefore momentum is conserved. Since the explosion occurs at the top of the trajectory, we know that there is no y-component to the momentum of the shell before the explosion. This means that there is also no y-component to the momentum after the collision.

mv0cosθx^+0y^=m2(0)x^+m2(0)y^+m2vfxx^+m2vfyy^mv_0\cos\theta\hat{x}+0\hat{y}=\frac{m}{2}(0)\hat{x}+\frac{m}{2}(0)\hat{y}+\frac{m}{2}v_{fx}\hat{x}+\frac{m}{2}v_{fy}\hat{y}

Separating this into two equation, we get

mv0cosθ=m2vfxvfx=2v0cosθmv_0\cos\theta=\frac{m}{2}v_{fx}\Rightarrow v_{fx}=2v_0\cos\theta

and

0=m2vfyvfy=00=\frac{m}{2}v_{fy}\Rightarrow v_{fy}=0.

  1. The third phase of the motion is back to parabolic projectile motion. I am going to reset the clock to t=0t=0 and set the initial coordinates of the motion to be equal to the final coordinates of the motion from the first phase of motion. The initial velocities are taken from the final velocities of phase 2.

x(t)=(2v0cosθ)t+v02sinθcosθg+x0x(t)=(2v_0\cos\theta)t+\frac{v_0^2\sin\theta\cos\theta}{g}+x_0

y(t)=12gt2+v0sin2θ2g+y0y(t)=-\frac{1}{2}gt^2+\frac{v_0\sin^2\theta}{2g}+y_0

When the shell lands, y(t)=y0y(t)=y_0.

y(t)=12gt2+v02sin2θ2g+y0=y0y(t)=-\frac{1}{2}gt^2+\frac{v_0^2\sin^2\theta}{2g}+y_0=y_0

12gt2=v02sin2θ2gt=v0sinθg\frac{1}{2}gt^2=\frac{v_0^2\sin^2\theta}{2g}\Rightarrow t=\frac{v_0\sin\theta}{g}

We can use this time to figure out the final x-coordinate.

x(tland)=2v0cosθ(v0sinθg)+v02sinθcosθg+x0x(t_\text{land})=2v_0\cos\theta\left (\frac{v_0\sin\theta}{g}\right )+\frac{v_0^2\sin\theta\cos\theta}{g}+x_0

x(tland)=3v02sinθcosθg+x0x(t_\text{land})=\frac{3v_0^2\sin\theta\cos\theta}{g}+x_0

Check

v02g\frac{v_0^2}{g} has units of [m/s]2[m/s2]=[m]\frac{[m/s]^2}{[m/s^2]}=[m], which is what we expect for a distance.

Let's explore the limits of θ=0\theta=0 and θ=90\theta=90^\circ. In the former case, the shell should immediately hit the ground. In the later case, it should land back where it started.

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{\theta\…

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{\theta\…

Interpretation

Had the shell not exploded, the projectile would have landed at 2v02sinθcosθg+x0\frac{2v_0^2\sin\theta\cos\theta}{g}+x_0. This projectile makes it farther than that because the explosion doubles the x-component of the velocity.

from __future__ import division, print_function from vpython import * #initial conditions x0=0 #x-coordinate y0=0 #y-coordinate v0=20 #speed theta=45*pi/180 #angle converted to radians m=1 #mass of shell g=9.8 #gravitional field strength Fg=vec(0,-m*g,0) #gravitational force a=Fg/m #acceleration t=0 dt=0.01 #time step #draw objects scene=canvas(title="exploding shell",center=vec(0.5*(3*v0**2*sin(theta)*cos(theta)/g+x0),5,0)) shell=sphere(pos=vec(x0,y0,0),v=vec(v0*cos(theta),v0*sin(theta),0), radius=1,color=color.red, make_trail=True) ground=box(pos=vec(0.5*(3*v0**2*sin(theta)*cos(theta)/g+x0),0,-0.1),length=(3*v0**2*sin(theta)*cos(theta)/g+x0), width=5, height=0.1, color=color.green) #continue until shell reaches top of trajectory while shell.v.y>=0: rate(1/dt) #ensure that looping rate does not exceed real time shell.v=shell.v+a*dt #update velocity shell.pos=shell.pos+shell.v*dt #update position t=t+dt #increment time shell.visible=False #make the initial shell disappear m1=m/2 #mass of piece 1 m2=m/2 #mass of piece 2 F1g=vec(0,-m1*g,0) #gravitational force on piece 1 F2g=vec(0,-m2*g,0) #gravitational force on piece 2 a1=F1g/m1 #acceleration of piece 1 a2=F2g/m2 #acceleration of piece 2 #draw the two shell pieces #make velocity of piece 1 zero while doubling velocity of piece 2 piece1=sphere(pos=shell.pos, v=vec(2*shell.v.x,0,0),radius=0.5,color=color.blue, make_trail=True) piece2=sphere(pos=shell.pos, v=vec(0,0,0),radius=0.5,color=color.yellow, make_trail=True) #continue until pieces hit the ground while piece1.pos.y>=0: rate(1/dt) piece1.v=piece1.v+a1*dt piece2.v=piece2.v+a2*dt piece1.pos=piece1.pos+piece1.v*dt piece2.pos=piece2.pos+piece2.v*dt t=t+dt
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>

Practice


Rockets accelerate basically by expelling bits of mass out the back. Determine an expression for the velocity of a rocket (that starts from rest) as a function of time.

Solution


Assumptions

  • the rocket starts with mass m0m_0

  • the motion is one-dimensional

  • the initial velocity of the rocket relative to the observer is v0=0v_0=0

  • the speed of the exhaust relative to the rocket is vexv_{ex}, which means that the velocity of the exhaust relative to the observer is vvexv-v_{ex} (since the rocket is moving forward and the exhaust is moving backward relative to it)

  • in a time dtdt, the mass of the rocket changes by dmdm and the speed of the rocket changes by dvdv

  • dtdt, dmdm, dvdv, vv, and vexv_{ex} are all assumed to be positive quantities (they aren't all positive, but the math will take care of that)

Diagrams

diagrams for accelerating rocket

To be clear, I am assuming that dmdm, dvdv, and vexv_{ex} are all positive quantities.

Analysis

At a given initial moment before a bit is expelled, the total momentum of the system is

p(t)=mvp(t)=mv.

(Note that because the motion is one-dimesional, I am dropping vector signs.) After a time dtdt has elapsed and a bit has been expelled, the total momentum of the system is

p(t+dt)=(m+dm)(v+dv)+(dm)(vvex)p(t+dt)=(m+dm)(v+dv)+(-dm)(v-v_{ex}).

The change in momentum of the system is

dp=p(t+dt)p(t)=(m+dm)(v+dv)+(dm)(vvex)mvdp=p(t+dt)-p(t)=(m+dm)(v+dv)+(-dm)(v-v_{ex})-mv

dp=mv+mdv+vdm+(dm)(dv)vdm+vexdmmvdp=\cancel{mv}+mdv+\cancel{vdm}+(dm)(dv)-\cancel{vdm}+v_{ex}dm-\cancel{mv}

If dmdm and dvdv are each infinitesimally small quantities, then the product (dm)(dv)(dm)(dv) is unimaginably small, so we will ignore it.

ParseError: KaTeX parse error: Undefined control sequence: \cancelto at position 8: dp=mdv+\̲c̲a̲n̲c̲e̲l̲t̲o̲{0}{(dm)(dv)}+v…

Since the system of rocket + bit is isolated, the total momentum of the system stays the same. That means that

dp=0=mdv+vexdmdp=0=mdv+v_{ex}dm

This is a separable differential equation. Move v's to one side and m's to the other (vexv_{ex} is a constant so it doesn't matter what side it is on).

vexdmm=dv\frac{v_{ex}dm}{m}=dv

Integrate both sides.

vexm0m(t)dm=v0v(t)dv-v_{ex}\int\limits_{m_0}^{m(t)}dm=\int\limits_{v_0}^{v(t)}dv

vexln(m(t)m0)=v(t)v0-v_{ex}\ln\left (\frac{m(t)}{m_0}\right )=v(t)-v_0

v(t)=v0vexln(m(t)m0)=v0+vexln(m0m(t))v(t)=v_0-v_{ex}ln\left (\frac{m(t)}{m_0}\right )=v_0+v_{ex}\ln \left (\frac{m_0}{m(t)}\right )

Check

m0m(t)\frac{m_0}{m(t)} has no units, which is good because the argument of a natural log function can't have units.

If m(t)=m0m(t)=m_0 (no mass loss, in other words), then ParseError: KaTeX parse error: Undefined control sequence: \cancelto at position 16: v(t)=v_0+v_{ex}\̲c̲a̲n̲c̲e̲l̲t̲o̲{0}\ln(0)=v_0. This makes sense, since no mass loss means that the rocket isn't actually expelling any fuel.

Interpretation

The relative magnitude of the exhaust speed relative to the speed of the rocket doesn't change whether the rocket speeds up or slows down. As long as the exhaust is backwards relative to the rocket, the rocket will speed up. We can also see from the final equation that if the exhaust is propelled forward (which means that we switch its sign), then the rocket will slow down with time.

from __future__ import division, print_function from vpython import * import matplotlib.pyplot as plt %matplotlib inline scene=canvas(range=50) #sets up the drawing area #draw rocket body=cylinder(pos=vec(0,0,0),axis=vec(3,0,0)) #body of rocket head=cone(pos=vec(3,0,0),axis=vec(1,0,0)) #head of rocket fin1=triangle(v0=vertex(pos=vec(0,-1,0)),v1=vertex(pos=vec(0,-2,0)),v2=vertex(pos=vec(1,-1,0))) #rocket fin fin2=triangle(v0=vertex(pos=vec(0,1,0)),v1=vertex(pos=vec(0,2,0)),v2=vertex(pos=vec(1,1,0))) #rocket fin rocket=compound([body,head,fin1,fin2]) #treat all of the rocket pieces as one object #initial conditions v0=vec(0,0,0) m0=1 rocket.m=m0 #mass of rocket rocket.v=v0 #initial velocity of rocket vex=vec(50,0,0) t=0 #initialize time dt=0.01 #time step dm=-0.002 #create graph tdata=[] numericaldata=[] exactdata=[] while rocket.m>=m0/2: #assume that half of the rocket's initial mass is fuel rate(1/dt) #100 calculations per second so we can see it rocket.v=rocket.v-vex*dm/rocket.m rocket.pos=rocket.pos+rocket.v*dt #calculate new position of rocket tdata.append(t) numericaldata.append(rocket.v.x) #plot the velocity and time exactdata.append(v0.x+vex.x*log(m0/rocket.m)) #plot exact result t=t+dt #increment the time rocket.m=rocket.m+dm #calculate the new mass of the rocket plt.title("velocity vs. time") plt.xlabel("t (s)") plt.ylabel("v (m/s)") plt.plot(tdata,numericaldata, "ro", tdata, exactdata, "b.") plt.legend(["numerical","exact"])
<IPython.core.display.Javascript object>
<matplotlib.legend.Legend at 0x10b966a90>
Image in a Jupyter notebook

Practice


A cart full of water is propelled by a powerful fan. The cart is leaking at a constant rate. Determine the velocity of the cart as a function of time.

Solution


Assumptions

  • the fan exerts a constant force FaccF_{ac}^c

  • the mass of the cart system changes by dmdm whenever a water droplet drops, and the velocity of the drops relative to the cart is 0

  • the mass of the cart is m(t)=m0btm(t)=m_0-bt, where bb is a constant

  • the motion is one dimensional

Diagrams

diagrams for leaking fan cart

Analysis

At any given time, the momentum of the cart is

p(t)=mvp(t)=mv.

At a time dtdt later, the momentum of the cart + drop is

ParseError: KaTeX parse error: Undefined control sequence: \cancelto at position 45: …v+\cancel{vdm}+\̲c̲a̲n̲c̲e̲l̲t̲o̲{0}{(dm)(dv)}-\….

The change in momentum during that time is

dp=p(t+dt)p(t)=mv+mdvmv=mdvdp=p(t+dt)-p(t)=mv+mdv-mv=mdv.

According to Newton's Second Law and the free body diagram

Fa(c+d)c=dpdt=mdvdt=(m0bt)dvdtF_{a(c+d)}^c=\frac{dp}{dt}=\frac{mdv}{dt}=(m_0-bt)\frac{dv}{dt}.

As before, we put terms with tt on one side and terms with vv on the other side. Fa(c+d)cF_{a(c+d)}^c is a constant, so it doesn't matter what side we put it on.

Fa(c+d)cdtm0bt=dvF_{a(c+d)}^c\frac{dt}{m_0-bt}=dv

Integrate both sides.

Fa(c+d)c0tdtm0bt=v0v(t)F_{a(c+d)}^c\int\limits_{0}^t\frac{dt}{m_0-bt}=\int\limits_{v_0}^{v(t)}

If the m0m_0 were not there, we would easily recognize the integral on the left hand side as a natural log. We can make it look like a natural log integral by making a change of variables.

Let u=m0btu=m_0-bt, then du=bdtdt=1bdudu=-bdt\Rightarrow dt=\frac{-1}{b}du.

Fa(c+d)cbu0u(t)duu=v(t)v0\frac{-F_{a(c+d)}^c}{b}\int\limits_{u_0}^{u(t)}\frac{du}{u}=v(t)-v_0

Fa(c+d)cbln(u(t)u0)=v(t)v0-\frac{F_{a(c+d)}^c}{b}\ln\left (\frac{u(t)}{u_0}\right )=v(t)-v_0

Fa(c+d)cbln(m0btm0)=v(t)v0-\frac{F_{a(c+d)}^c}{b}\ln\left (\frac{m_0-bt}{m_0}\right )=v(t)-v_0

v(t)=v0Fa(c+d)cbln(m0btm0)=v0Fa(c+d)cbln(1btm0)v(t)=v_0-\frac{F_{a(c+d)}^c}{b}\ln\left (\frac{m_0-bt}{m_0}\right )=v_0-\frac{F_{a(c+d)}^c}{b}\ln\left (1-\frac{bt}{m_0}\right )

Check

In order for m(t)=m0btm(t)=m_0-bt to have units of [kg][kg], btbt must have units of [kg][kg] as well. This means that bb has units of [kg][s]\frac{[kg]}{[s]}. Fa(c+d)cb\frac{F_{a(c+d)}^c}{b} then has units of [N][kg]/[s]=[kg][m]/[s]2[kg]/[s]=[m][s]\frac{[N]}{[kg]/[s]}=\frac{[kg][m]/[s]^2}{[kg]/[s]}=\frac{[m]}{[s]}, which is what we expect since the natural log function has no units.

Let's check limits, starting with t=0t=0.

ParseError: KaTeX parse error: Undefined control sequence: \cancelto at position 32: …_{a(c+d)^c}}{b}\̲c̲a̲n̲c̲e̲l̲t̲o̲{0}{\ln (1)}=v_…

As time goes on, the argument of the natural log function becomes closer and closer to zero, which means that the natural log function itself evaluates to larger and larger negative numbers. Combined with the negative sign in front of the coefficient, this makes the velocity increase.

We could also check what happens when b=0b=0. In this case we would expect that the velocity would increase linearly with time, since a constant force is applied to a constant mass. The problem is that there is a bb in the denominator. One way around this is to take the limit as bb approaches zero.

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{b\to 0}…

How do we evaluate this limit? My preferred method to to perform a Taylor Expansion for the natural log function. In a Taylor Series table, I find that

ln(1+x)=xx22+x33x44+\ln(1+x)=x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+\ldots.

Therefore

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{b\to 0}…

ParseError: KaTeX parse error: Expected group after '_' at position 5: \lim_̲\limits{b\to 0}…,

which is exactly what we expected.

Interpretation

This shows a non-linearly increase velocity. In reality, the mass would not keep decreasing forever. Once the water runs out, the mass would stop decreasing. To make this more realistic, we would have to turn this into a piecewise problem where the mass becomes constant again after a while.

from __future__ import division, print_function from vpython import * import matplotlib.pyplot as plt %matplotlib inline #initial conditions x0=0 #x-coordinate v0=0 #initial speed F=vec(1,0,0) #force from fan m0=1 #starting mass (used for exact solution) m=m0 #starting mass (used for numerical solution) v=vec(v0,0,0) #initial vector velocity mcart=0.5 #mass of cart without water b=0.05 #how fast is it leaking? t=0 dt=0.01 #time step #draw cart scene=canvas(title="leaking cart",range=20) cart=box(pos=vec(x0,0,0),length=1,width=0.5, height=0.5) #set up arrays for plotting tdata=[] numericaldata=[] exactdata=[] while m>=mcart: #continue looping until water runs out rate(1/dt) #makes sure that looping rate does not exceed real time a=F/m #calculate acceleration v=v+a*dt #update velocity cart.pos=cart.pos+v*dt #update position #append data for plotting tdata.append(t) numericaldata.append(v.x) exactdata.append(v0-F.x/b*log(1-b*t/m0)) t=t+dt #increment time m=m0-b*t #decrement mass #plot all the things plt.title("velocity vs. time") plt.xlabel("t (s)") plt.ylabel("v (m/s)") plt.plot(tdata,numericaldata,"ro",tdata,exactdata,"b.") plt.legend(["numerical","exact"])
<IPython.core.display.Javascript object>
<matplotlib.legend.Legend at 0x10b966b50>
Image in a Jupyter notebook