In[]:=
ClearAll["Global'*"](*RandomCoefficients*)a2=(Power[-1,RandomInteger[{1,2}]])RandomInteger[{1,10}];a1=(Power[-1,RandomInteger[{1,2}]])RandomInteger[{1,10}];a0=(Power[-1,RandomInteger[{1,2}]])RandomInteger[{1,10}];(*RandomInitialConditions*)t0=0;x0=(Power[-1,RandomInteger[{1,2}]])RandomInteger[{1,5}];xd0=(Power[-1,RandomInteger[{1,2}]])RandomInteger[{1,5}];(*DifferentialEquationSecondOrderHomogenous*)df1[x_[t_]]=a2*D[x[t],{t,2}]+a1*D[x[t],{t,1}]+a0*D[x[t],{t,0}];Text["The homogenous linear Second Order differential equation to solve is: "<>ToString[df1[x[t]],TraditionalForm]<>" = 0, with initial conditions x(0) = "<>ToString[x0]<>" and x'(0) = "<>ToString[xd0]](*CharachteristicPolynomial*)p1[x_]=x^2+(a1/a2)x+(a0/a2);sp1:=Solve[p1[x]==0,x]s1=x/.sp1[[1]];s2=x/.sp1[[2]];Text["The corresponding characteristic polynomial is : "<>ToString[p1[λ],TraditionalForm]]Text["The roots of the characteristic polynomial are λ = "<>ToString[s1,TraditionalForm]<>" and λ = "<>ToString[s2,TraditionalForm]](*ExponentialAnsatz*)e1[t_]=Exp[s1*t];e2[t_]=If[s1==s2,t*Exp[s2*t],Exp[s2*t]];Text["(t) = "<>ToString[e1[t],TraditionalForm]<>" and (t) = "<>ToString[e2[t],TraditionalForm]<>" are two solutions to the original differential equation."](*Wrosnkianregularitycheck*)w[x_,y_,t_]:={{x,y},{D[x,t],D[y,t]}}w1=w[e1[t],e2[t],t];MatrixForm[w1];dw1=Det[w1];Solve[dw1==0,t];Text["The wronskian of and is the determinant of the matrix W[ , ] = "<>ToString[w1,TraditionalForm]]Text[" and are linearly independent on any Interval I ⊂ "<>ToString[Reals,TraditionalForm]" where W[ () , () ], ∈ I, is regular det[W] ≠ 0. "]Text["Two linearly independent solutions and to the original differential equation build a fundamental system of solutions."]Text["The general solution to the homogenous equation is of the form = (t) = × (t) + × (t) = × "<>ToString[e1[t],TraditionalForm]<>" + × "<>ToString[e2[t],TraditionalForm]<>", , ∈ "](*CoefficientSolutionforinitialconditions*)MatrixForm[w1/.t->t0];ls1=LinearSolve[w1/.t->t0,{x0,xd0}];Text["A particular solution to the Initial Value Problem can be found by solving the linear system of equations W[ (0) , (0)] "<>ToString[MatrixForm[{,}],TraditionalForm]<>" = "<>ToString[MatrixForm[{x0,xd0}],TraditionalForm]]Text["The solution to the original Initial Value Problem is "<>ToString[MatrixForm[{,}],TraditionalForm]<>" = "<>ToString[MatrixForm[{ls1[[1]],ls1[[2]]}],TraditionalForm]](*Solvedifferentialequationwithinitalconditions*)df1s=DSolve[{df1[x[t]]==0,x[t0]==x0,x'[t0]==xd0},x,t];df1e=Evaluate[x[t]/.df1s];Text["The particular solution to the original differential equation with given initial conditions is = (t) = "<>ToString[df1e[[1]],TraditionalForm]](*PlotResults*)Plot[Evaluate[x[t]/.df1s],{t,-8,8}]
e
1
e
2
e
1
e
2
e
1
e
2
e
1
e
2
e
1
t
0
e
2
t
0
t
0
e
1
e
2
x
g
x
g
c
1
e
1
c
2
e
2
c
1
c
2
c
1
c
2
e
1
e
2
c
1
c
2
c
1
c
2
x
p
x
p
Out[]=
The homogenous linear Second Order differential equation to solve is: -8(t)-3(t)-8x(t) = 0, with initial conditions x(0) = 3 and x'(0) = 3
′′
x
′
x
Out[]=
The corresponding characteristic polynomial is : ++1
2
λ
3λ
8
Out[]=
The roots of the characteristic polynomial are λ = -3--3+
1
16
247
and λ = 1
16
247
Out[]=
e
1
1
16
247
t
e
2
1
16
247
t
Out[]=
The wronskian of and is the determinant of the matrix W[ , ] =
e
1
e
2
e
1
e
2
1 16 247 t | 1 16 247 t |
1 16 247 1 16 247 t | 1 16 247 1 16 247 t |
Out[]=
e
1
e
2
e
1
t
0
e
2
t
0
t
0
Out[]=
Two linearly independent solutions and to the original differential equation build a fundamental system of solutions.
e
1
e
2
Out[]=
The general solution to the homogenous equation is of the form = (t) = × (t) + × (t) = × -3- + × -3+, , ∈
x
g
x
g
c
1
e
1
c
2
e
2
c
1
1
16
247
t
c
2
1
16
247
t
c
1
c
2
Out[]=
A particular solution to the Initial Value Problem can be found by solving the linear system of equations W[ (0) , (0)]
=
e
1
e
2
c 1 |
c 2 |
3 |
3 |
Out[]=
The solution to the original Initial Value Problem is
=
c 1 |
c 2 |
3 26 247 |
3 26 247 |
Out[]=
The particular solution to the original differential equation with given initial conditions is = (t) = +13cos
x
p
x
p
3
13
-3t/16
247
sin247
t16
247
t16
Out[]=