Physics with Mathematica

Fourth Class

Hannah Trottier
Joey Delmar (?)

Email me with your chosen homework problem!!

Today: Analytic Solutions of Differential Equations

The solutions to differential equations are functions, so first let’s take a moment to learn about functions.

Remove["Global`*"]

f[x_]=x^2+2x;
f[w]

f[Sqrt[z]]

You can also define a “pure” function

f=Function[x,x^2+2x];
f[w]

Now solve a simple first order differential equation

Remove["Global`*"]

You can use DSolve in one of two ways, depending on how flexible you want the solution to be

DSolve[f'[x]==a f[x],f[x],x]

DSolve[f'[x]==a f[x],f,x]

You can include the boundary (or initial) conditions in the statement

sol=DSolve[{f'[x]==a f[x],f[0]==b},f[x],x];
expFun=f[x]/.sol[[1]]

Physics Example: Flight of a baseball with linear drag

Remove["Global`*"]

sol=DSolve[
{m x''[t]==-b x'[t],x[0]==0,x'[0]==v0 Cos[θ],
m y''[t]==-m g-b y'[t],y[0]==0,y'[0]==v0 Sin[θ]},
{x,y},t];

Examine the solutions

x=x[t]/.sol[[1]]
y=y[t]/.sol[[1]]

x/.b->0

Series[x,{b,0,1}]

Series[y,{b,0,1}]

Make parametric plots of the trajectories for different drag coefficients

vals={g->9.8,m->0.1,v0->50,θ->Pi/6};
traj1=Normal[Series[{x,y}/.vals,{b,0,1}]]/.b->0;
traj2={x,y}/.vals/.b->0.01;
traj3={x,y}/.vals/.b->0.05;

ParametricPlot[{traj1,traj2,traj3},{t,0,7},
PlotRange->{{0,250},{0,40}},
PlotStyle->{Black,Blue,Red},
PlotLegends->{"No drag","Some drag","Big drag"},
AspectRatio->40/250]