Mathematica Labs | Denis Shubleka

Subject: Calculus

Topic: Differential Equations

Goal: Use Mathematica to solve differential equations.

Task 1

Consider the differential equation (dy/dt)=ky, where k is constant. By separation of
variables, we know that the general solution is y(t) = A (e^kt).
Mathematica solves differential equations such as (dy/dt)=0.2y, using the DSolve command:

DSolve[{y'[t]==0.2y[t]},y[t],t]

The result represents the set of solutions, a family of curves where each member is 
uniquely defined by the constant C[1]. Below we define some of these solutions, for
C[1] values between -1 to 5 in increments of 0.5.

solutions=Table[y[t]/.%[[1]]/.C[1]->n,{n,-1,5,0.5}]

To obtain a plot of these thirteen solutions, enter and execute the following:

Plot[solutions,{t,0,20}]

Next, we use the DSolve command to solve an initial value problem, and then plot the 
solution curve. The differential equation is  (dy/dx)=x+y  with initial condition (0,1).

initialvalue={0,1};
DSolve[{y'[x]==x+y[x],y[0]==1},y[x],x]

Plot[y[x]/.%,{x,-1,3},Epilog->{PointSize[0.02],Blue,Point[initialvalue]}]

Related Exercises/Notes:

ap-calc.github.io