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]==-2 x y[x] /. sol

y[x]/. sol

2y'[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}]

eqn=y''[x]+2y'[x]+y[x]==0

eqn /. {y-> Function[{x},Exp[-x]]}

Solve[eqn /.{y-> Function[{x},Exp[c x]]},c]

Harmonic Oscillator

eqnh = ((-(ℏ^2))/(2 m))ψ''[x]+(1/2)k (x^2)ψ[x]==Ene ψ[x]

Solve[eqnh /.{ψ-> Function[{x},Exp[c (x^2)]]},Ene]

Solve[k m (x^2)==4 (c^2) (x^2) (ℏ^2),c]

c=-(((Sqrt[k]) (Sqrt[m]))/(2 ℏ))

Ene0=((-2 c (ℏ^2))/(2 m))

Ene=.

Solve[eqnh /.{ψ-> Function[{x},x Exp[c (x^2)]]},Ene]

Ene =.

c =.
a=.

Solve[eqnh /.{ψ-> Function[{x},(1  -a (x^2)) Exp[c (x^2)]]},Ene]

Solve[-(Sqrt[k]) (Sqrt[m]) ℏ+-2 a (ℏ^2)==-5(Sqrt[k]) (Sqrt[m]) ℏ, a]

a=((2 (Sqrt[k]) (Sqrt[m]))/ℏ)

Ene2 =((-(Sqrt[k]) (Sqrt[m]) ℏ+5 a (Sqrt[k]) (Sqrt[m]) (x^2) ℏ-2 a (ℏ^2))/(2 m (-1+a (x^2))))

Simplify[%]

Hydrogen Atom

Ene =.; R[r_]=.;

eqnr = R''[r]+(2/r)R'[r]+(((2Ene)/(a (((e'))^2)))+(2/(a r))) R[r]==0

R[r_]:=Exp[-c r]

R[r]

R'[r]

eqnr

Solve[eqnr,Ene]

c=1/a

Solve[eqnr,Ene]