Mechanics
Mathematica Documentation
Mathematica Source Code
Page 2
(Hammer.ma)
The force imparted by a hammer to a steel bar is given by 50 N (1 -
(t/to)^3) , where t runs from 0 to to. [The force is assumed to have suddenly
reached 50 N as the hammer initially struck the bar.] Take to=20 ms and
determine the impulse graphically which is associated with the collision,
and also use maple or mathematica to find the impulse.
Solution
Clear["Global`*"]
Equation for force on steel ball
f = 50*(1-(t/t0)^3)
Substitute in values into above equation
F = f/.{t0 -> 2/100}
Find where force equals 0
sol = Solve[F == 0,t]
Assign the solution
tf = 1/50
Plot the equation
Plot[F, {t,0,tf}, PlotLabel -> "Force on
steel ball vs. time", PlotRange -> {0,50}]
Find the pulse
impulse = Integrate[F,{t,0,tf}]
Jim throws a baseball at an angle theta1 with a speed v1. Phil, who
is standing in the vertical plane of motion, also throws a baseball in
the same forward direction at an angle theta2 with a speed v2. Phil throws
his ball at the exact moment Jim's ball is directly overhead. At that moment,
Phil notices that Jim's ball is neither rising nor falling, being at its
maximum height.
a) With what speed (as a function of the intial launch angles and v1) must
Phil's ball be thrown to collide with Jim's?
b) Determine where the collision takes place.
c) After the first ball is thrown, how long does it take the two balls
to collide? Assume Jim and Phil are at the same height on a level field.
Solution
DETERMINATION OF SPEED FOR A COLLISION (PART A)
Enter in the initial equations given.
x1 := v0x1*t1
x2 := x02 + v0x2*t2
t1 := t2 + dt
where dt is Delta*t
Start eliminating variables; realize what x02 equals
x02 := v0x1*dt
Solving when x1 must equal x2 in terms of v0x1 gives:
equ1 = Solve[x1==x2, v0x1]
Now generalize the problem; use v*cos(theta) instead of vx
equ2 = v01*Cos[theta1]== v02*Cos[theta2]
Solving for v02 gives:
equ3 = Solve[equ2, v02]
DETERMINATION OF LOCATION OF COLLISION (PART B)
In order for a collision to occur, both y1 = y2 and x1 = x2 must be true.
Start with the y-components.
ClearAll[x1,x2,t1,x02]
equ4 = y1==y2
Write the standard kinematic expression for y1 and y2
equ5 = y01 + v0y1*t1 - (g/2)*(t1)^2 == y02 + v0y2*t2
- (g/2)*(t2)^2
Since both balls were thrown form the same height, y01 and y02 can
be cancelled out by setting them equal to 0.
y01 := 0
y02 := 0
Define what t1 is again (Mathematica doesn't remember due to the
'ClearAll' command)
t1 := t2 + dt
Dt can be determined by thinking about the relationship between
x02 and the velocity of the ball at that point.
dt := v0y1/g
Now substitute these terms in to the general kinematic equation
entered above
equ6 = equ5
Solving for the term t2 yields:
equ7 = Solve[equ6,t2]
Now the location of the collision can be determined (Find when x1
= x2 and y1 = y2)
equ8 = x2 == x02 + v0x2*t2
Redefine what x02 and v0x2 are (Look at the solution to part A)
x02 := v0x1*dt
v0x2 := v0x1
Substituting in these values, along with t2, gives:
t2 := v0y1^2/(2*g*v0y2)
equ9 = equ8
'simplify' will help make the equation look better
equ10 = Simplify[equ9]
Now for the y-components:
Erase the definition of t2 (for now)
ClearAll[t2]
equ11 = y2 == y0 + v0y2*t2 - (g/2)*(t2)^2
Redefine t2:
t2 := v0y1^2/(2*g*v0y2)
Plugging in t2 gives:
equ12 = equ11
where y0 must be specified
TIME FOR PROJECTILES TO COLLIDE (PART C)
Clear the values for t1, dt and t2.
ClearAll[t1,dt,t2]
equ13 = t1 == t2 + dt
Defining what t2 and dt are gives:
t2 := v0y1^2/(2*g*v0y2)
dt := v0y1/g
equ14 = equ13
A ball is launched with an initial velocity of 130 m/s at ground level.
It strikes a wall 150 m away, at a height of 10m.
a) Find the parametric equations y(t) and x(t) in terms of t and launch
angle theta.
b) Find the launch angle and time of flight. [Note: There are two solutions.]
c) Determine the path y(x) from the parametric equations.
d) Do a 'parametric plot' of x(t) and y(t). Plot y(x) and compare to the
parametric plot.
Solution
Kinematic projectile motion equations.
f1 = x == v0*Cos[theta]*t
f2 = y == v0*Sin[theta]*t-49/10*t^2
Assign specific values.
v0 := 130
x := 150
y := 10
xcomp = f1
ycomp = f2
Solve xcomp and ycomp for t and theta.
sol = Solve[{xcomp, ycomp},{t,1}, {theta,.5}]
Mathematica is saying that it can't find a solution because there is no systematic procedure for finding all solutions, even numerically. Thus, the command 'FindRoot' must be used, where the numbers after t & theta are starting points , followed by the allowable range for solutions, for solving the system by using Newton's method or similar procedure. The starting points need to be determined by trial and error.
sol = FindRoot[{xcomp, ycomp},{t,1,0,100},
{theta,.5}] {t -> 1.16089, theta -> 0.110242}
sol = FindRoot[{xcomp, ycomp},{t,20,2,100}, {theta,1.5}] {t -> 26.4281,
theta -> 1.52712}
Assign the solutions.
t1 := 1.16089
theta1 := 0.110242
t2 := 26.4281
theta2 := 1.52712
Substitute values of theta into the rihgt-hand side of the kinematic
equations. rhsxcomp := 130*t*Cos[theta]
rhsycomp := (-49*t^2)/10 + 130*t*Sin[theta]
x1 = rhsxcomp/.theta -> theta1
y1 = rhsycomp/.theta -> theta1
x2 = rhsxcomp/.theta -> theta2
y2 = rhsycomp/.theta -> theta2
Plot {x1,y1} and {x2,y2}
ParametricPlot[{{x1,y1},{x2,y2}},{t,0,30}, PlotRange
-> {{0,150},{0,900}},PlotLabel -> "Parametric plot of projectile
motion"]
Before proceding, clear all of the variable names.
ClearAll[v0,x,y,xcomp,ycomp]
Solve first kinematic equation for time.
time = Solve[f1,t]
Assign the solution.
time = (x*Sec[theta])/v0
Substitute into the the second kinematic equation.
path = f2/.t -> time
Substitute in theta1, theta2 and v0 = 130.
path1 = path/.{theta -> theta1, v0 -> 130}
paht2 = path/.{theta -> theta2, v0 -> 130}
Assign the solutions.
rhspath1 := 0.110691*x - 0.000293493*x^2
rhspath2 := 22.8825*x - 0.152106*x^2
Now plot rhspath1 and rhspath2; the plot generated should be the
same plot generated earlier.
Plot[{rhspath1,rhspath2},{x,0,150},PlotLabel ->
"Paths of projectile as a function of x"]

Mass M is released from rest as shown in the figure and moves down the
plane.
a) Assuming no friction anywhere in the system, how far down the incline
will M move before coming momentarily to rest? [This can be done just using
conservation of energy.]
b) Write down Newton's second law for the mass M on the incline.
c) Solve this equation using 'dsolve' for the general equation of displacement
of the mass vs. time.
For parts d) and e), let M=2.5 kg, k=175 N/m, and g=9.8 m/s^2.
d) Plot the displacement vs time for theta = 30 degrees.
e) Plot the displacement vs. time for various angles values of theta from
0 to 90 degrees in increments of 15 degrees. [Hint: A loop would be helpful.]
Solution
Conservation of Energy
energy = m*g*x*Sin[theta] == 1/2*k*x^2
Solve the above equation for x to find the maximum displacement
of the mass.
sol = Solve[energy,x]
Assign the second solution (the non-trivial one).
maxdist = 2*g*m*Sin[theta]/k
Maximum displacement of mass at 30 deg.
maxdist30deg = maxdist/.{m -> 5/2, k -> 175,
g -> 98/10, theta -> Pi/6}//N
Differential equation describing the motion of the mass.
ClearAll[g,m,k,theta]
f = m*g*Sin[theta] - k*x[t] == m*D[x[t],{t,2}]
Solve the differential equation.
ans = DSolve[{f == 0,x[0] == 0, x'[0] == 0},x[t],t]
Convert the answer by use of Euler's Identity
Needs["Algebra`Trigonometry`"]
ans/.{Rule->Equal}//ComplexToTrig//ExpandAll
Assign the solution.
xt = (g*m*Sin[theta])/k - (g*m*Cos[(k^(1/2)*t)/m^(1/2)]*Sin[theta])/k
Substitute in values given in the problem.
xt = xt/.{m -> 5/2, k -> 175, g -> 98/10}
xt = Simplify[xt]
Generate graphs for the motion of the mass for theta = 0,15,30,45,60,75,
& 90 degrees.
Plot[Evaluate[Table[xt//N,{theta,0,Pi/2,Pi/12}]],
{t,0,5},AxesLabel -> {"Time","Displacement"},PlotLabel
-> "Path of mass vs time for angle = 0 to 90 deg"]
Find maximum displacement of mass when theta = 30 deg.
motion30 = xt/.theta -> Pi/6
Maximum displacement occurs when the sine term of the motion is
1.
maxdisp = motion30/.t -> Sqrt[2/35]*Pi/2//N
The above answer agrees with the one generated using conservation
of energy.
Now for a 3D plot of the path of the mass verses time. Plot3D[xt,{t,0,2},{theta,0,Pi/2},PlotLabel
-> "Path of mass vs. time for angles 0 to 90 deg.", AxesLabel
-> {"t","theta",""}, PlotPoints ->
25]
This is the previous problem (MASSINC.MA) with static and kinetic friction
coefficients given, and with the same static and kinetic coefficients.
Solution
DE for motion of the mass if there is friction on the plane
NOTE: The 'Sign' function used returns either 1 or -1 based on the value
of the argument inside the Sign function, either positive or negative.
In this case, the 'Sign' function ensures that the friction will oppose
the motion of the mass regardless of whether the mass is moving up or down
the incline.
F = m*g*Sin[theta] - k*x[t] - mu*g*Cos[theta]*Sign[D[x[t] ,t]] == m*D[x[t], {t,2}]
Ft = F/.{m -> 5/2, k -> 175, g -> 98/10, theta -> 60*Pi/180, mu -> 1/4}
NDSolve[{Ft,x[0] == 0, x'[0] == 0},x, {t,0,10}]
Plot[Evaluate[x[t] /. %],{t,0,10}, DisplayFunction -> $DisplayFunction, PlotRange -> {{0,4}, {0,3/10}}, PlotLabel -> "Position of block vs. time with friction on the plane" ]
A mass M hangs from the ceiling by a massless spring of constant k and
unstretched length Lo. The length of the spring as a function of time is
h(t), and the extension of the spring is h(t) - Lo.
a) Show that when the mass is hanging at rest, the spring length is Lo
+Mg/k. The mass is thus at a distance from the ceiling of h(0) = Lo + Mg/k.
This is the 'equilibrium' position of the mass. When the mass is moving,
h(t) = Lo + Mg/k +x(t), where x(t) is the distance from the equilibrium
position.
b) Let M = 1.55 kg, k = 350 N/m, and Lo = 0.37 m, and let the mass be released
at t=0 when the spring is unstretched. (Note that x(t) will be negative
when this happens.) Solve Newton's second law applied to the mass M (using
dsolve, or a Runge-Kutta integration) and plot the motion of the mass.
c) Compare the frequency of the motion to the theoretical value of (k/M)^(1/2)
/ (2 pi). (You should also be able to notice that the amplitude of the
motion is Mg/k.)
Solution
Part A: Equilibrum Position
Intital length of the spring
equ1 = Lo
Stretch of spring due to mass (F = kx)
F := M*g
Solve[F == k*x, x]
Assign the solution.
equ2 = g*M/k
Total equilibrum position
h[0] = equ1 + equ2
Value of h when mass is moving:
h[t] = h[0] + x[t]
where x[t] is the distance from the equilibrum position
Part B: Motion of mass
Sum up the forces acting on the mass
F = M*g - k(h[t] - Lo)
Now set up the equation of F = ma (a is the second derivative of
x[t])
newton2 = F == M*x''[t]
Define the constants given.
M := 155/100
k := 350
g := 98/10
Lo := 37/100
Now solve the equation.
motion = DSolve[{newton2,x[0] == -M*g/k,x'[0] ==
0}, x[t],t]
Convert the answer into an answer that contains sines and cosines.
Needs["Algebra`Trigonometry`"]
motion/.{Rule->Equal}//ComplexToTrig//ExpandAll
Assign the solution.
motion = (-217*Cos[10*(70/31)^(1/2)*t])/5000
Plot the motion of the mass.
Plot[motion//N,{t,0,2}, PlotLabel ->"Motion
of the mass", AxesLabel -> {"Time","Distance From
Ceiling"},PlotRange -> {-.05,.05}]
Part C: Comparison to theoretical value
theoreticalfreq = (k/M)^(1/2)/(2*Pi)//N
The calculated frequency is the coefficient in front of the t in the cosine term of the mass's motion divided by 2 Pi. calculatedfreq = 10*Sqrt[70/31]/(2*Pi)//N
The frequency of motion from the derived D.E. is the same as the
theroretical value.
Find the value of M*g/k.
theroreticalamp = M*g/k
The value of M*g/k is the same as the coefficient in front of the cosine term of the equation motion, which is the amplitude of the oscillation.
A very narrow rod has length L = 0.09 m, and mass M = 1.75 kg. Determine
the total gravitational force that this rod exerts on a tiny sphere of
mass m = 0.01 kg, located at a distance h = 0.55 m from the center of the
rod along a perpendicular bisector. Do this by finding the force exerted
on the sphere by a small segment of the rod Dx = 0.01 m, and then adding
all forces from small segments to get the total force.
Solution
Define constants:
L = .9
M = 1.75
m = .01
h = .55
G = 6.67*10^(-11)
Mass of one segment of the bar.
Ms = M/9
Distance from bar segment to sphere mass.
r = Sqrt[x^2+.55^2]
Force between segment of bar and sphere mass.
F = G*m*Ms/(r^2)
Force between segment of bar and sphere mass in the y direction.
Fy = F*h/r
Add up the force in the y direction due to the nine segments of
the rod.
Set the total to zero.
Ftot = 0
Add the forces from each segment to the total.
Ftotal = Do[Print[Ftot = Ftot + Fy],{x,-.4,.4,.1}]
The total force on the sphere mass is:
Ftot