Linear First Order Template

Math 3280  B. Peckham

Goal: Find an analytic solution to a linear first order DE: y' + p(x) y = g(x)

Example: y'-2y = 3, y(0)=1.

Clear variables

y=.
x=.

Specify the coefficients p(x) and g(x):

p=-2

g=3

Set the initial Conditions:

x0=0
y0=1

Determine the integrating factor mu:

mu =Exp[Integrate[p,x]]

gensln = 1/mu (Integrate[mu*g, x] + C)

IC = Solve [y==gensln, C]/.{y->y0, x->x0}

sln = gensln/.IC{{1}}

Simplify[sln]