Separable ODEs

Solve: y’ = y, y(0) = 1, note the use of y[x] and y’[x] and ==

DSolve[y'[x]==y[x], y[x], x]

DSolve[{y'[x]==y[x], y[0]==2}, y[x], x]

Solve: y’ = -2xy, y(0) = 1 and 1.8, note the use of y at the end , the solution obtained is a list of functions

DSolve[{y'[x]==-2 x y[x],y[0]==1.8},y,x]

Store the solution to a list (sol)

sol=DSolve[{y'[x]==-2 x y[x],y[0]==1.8},y,x]

Use the Replace operator /. to assign the solution  to y[x]

y[x]/. sol

y[1]/.sol

y[0] /. sol

Plot the solution from x = -2 to +2

Plot[y[x] /. sol, {x,-2,2}]

f[x_]:=y[x]/. sol

f[1]

f[0]

Plot[f[x], {x,-2,2}]

Solve the system: A --> B (kf is the forward rate constant)

Clear[A,A0,kf]

DSolve[A'[t]==-kf A[t],A[t],t]

sol=DSolve[{A'[t]==-kf A[t],A[0]==A0},A[t],t]

Clear[a]

a[t_]:=A[t] /. sol

a[t]

A0 = 1.0; kf =1.0 ;

Plot[a[t], {t,0,5}]

Clear[A,A0,kf,kr]

Solve the system: A <--> B (kf and kr are forward and reverse rate constants)

DSolve[A'[t]+(kf + kr)A[t]-kr A0 ==0,A[t],t]

with the initial condition (Subscript[[A], t=0]) = (Subscript[A, 0])

sol=DSolve[{A'[t]+(kf + kr)A[t]-kr A0 ==0,A[0]==A0},A[t],t]

a[t_]:=A[t] /. sol

Setting the constants

A0 = 1.0; kf = 2.0; kr =1.0;

Plot the concentrations of A and B as functions of time

Plot[{a[t],A0-a[t]} /.sol, {t,0,3},PlotRange->{{0,2},{0,1}},AxesLabel->{time,concentration}]

Solve[a[t]==0.5,t]

FindRoot[a[t]==0.5,{t,0.5}]