Solve the following ordinary differential equation over the interval from x = 0 to 1 using a
step size of 0.25 where y(0) = 1.
π π
π π = (π + ππ)π
π
(1) Analytically.
(2) Using Eulerβs method.
(3) Using Heunβs method without iteration.
(4) Using the fourth-order RK method.
Since, the given differential equation is unclear, we assume it as follows:
"\\dfrac{dy}{dx}=yx^2-1.2y"
(1) Analytically:
"\\\\ \\Rightarrow \\dfrac{dy}{dx}=y(x^2-1.2)\n\\\\ \\Rightarrow \\dfrac{dy}{y}=(x^2-1.2)dx\n\\\\\\Rightarrow \\log y=\\dfrac{x^3}3-1.2x+C"
y(0)=1
When x=0,y=1
Then,
"\\log 1=0+C\n\\\\\\Rightarrow C=0"
So, "\\log y=\\dfrac{x^3}3-1.2x"
Or, "y=e^{\\frac{x^3}3-1.2x}"
(2) Using Eulerβs method.
"\\begin{aligned}&\\text { (a) } \\mathrm{h}=0.5 . \\quad \\mathrm{y}_{\\mathrm{i}+1}=\\mathrm{y}_{\\mathrm{i}}+\\mathrm{f}\\left(\\mathrm{x}_{\\mathrm{i}}, \\mathrm{y}_{\\mathrm{i}}\\right) \\mathrm{h} \\quad \\text { where } \\mathrm{f}(\\mathrm{x})=\\mathrm{yx}^{2}-1.2 \\mathrm{y} \\\\&\\mathrm{i}=0 \\quad \\mathrm{y}_{1}=\\mathrm{y}_{0}+\\mathrm{f}\\left(\\mathrm{x}_{0}, \\mathrm{y}_{0}\\right) \\mathrm{h} \\rightarrow \\quad \\mathrm{y}_{1}=\\mathrm{y}(0.5)=1+\\left(1 * 0^{2}-1.2 * 1\\right) 0.5=0.4 \\\\&\\mathrm{i}=1 & \\mathrm{y}_{2}=\\mathrm{y}_{1}+\\mathrm{f}\\left(\\mathrm{x}_{1}, \\mathrm{y}_{1}\\right) \\mathrm{h} \\rightarrow \\mathrm{y}_{2}=\\mathrm{y}(1.0)=0.4+\\left(0.4 * 0.5^{2}-1.2 * 0.4\\right) 0.5=0.21 \\\\&\\mathrm{i}=2 & \\mathrm{y}_{3}=\\mathrm{y}_{2}+\\mathrm{f}(\\mathrm{x}_{2}, \\mathrm{y}_{2}) \\mathrm{h} \\rightarrow \\mathrm{y}_{3}=\\mathrm{y}(1.5)=0.21+(0.21 * 1^{2}-1.2 * 0.21) 0.5=0.189 \\\\&\\mathrm{i}=3 & \\mathrm{y}_{4}=\\mathrm{y}_{3}+\\mathrm{f}(\\mathrm{x}_{3}, \\mathrm{y}_{3} \\mathrm{h} \\rightarrow \\mathrm{y}_{4}=\\mathrm{y}(2.0)=0.189+\\left(0.189 * 1.5^{2}-1.2 * 0.189\\right) 0.5=0.2882\\end{aligned} -"
Analytical solution is shown with blue.
Solution for h=0.5 is shown with red.
(3) Using Heunβs method without iteration.
h = 0.5 , f(x) = yx2 β 1.2y , y0 i+1 = yi + f(xi , yi ) h , yk i+1 = yi + [f(xi , yi ) + f(xi+1, yk-1 i+1)]/2 * h
i = 0 Predictor: y0 1 = 1 + (1*02 β 1.2*1) 0.5 = 0.4
Corrector:
k=1 y 1 1 = 1 + [(1*02 β 1.2*1) + (0.4*0.52 β 1.2*0.4) ]/2 * 0.5 = 0.605 ea= 33.9 %
k=2 y 2 1 = 1 + [(1*02 β 1.2*1) + (0.605*0.52 β 1.2*0.605) ]/2 * 0.5 = 0.5563125 ea= 8.75 %
k=3 y 3 1 = 1 + [(1*02 β 1.2*1) + (0.5563*0.52 β 1.2*0.5563) ]/2 * 0.5 = 0.5678757 ea= 2.04 %
k=4 y 4 1 = 1 + [(1*02 β 1.2*1) + (0.5679*0.52 β 1.2*0.5679) ]/2 * 0.5 = 0.5651295 ea= 0.49 %
y1 = y(0.5) = 0.5651295
i = 1 Predictor: y0 2 = 0.5651295 + (0.5651295*0.52 β 1.2*0.5651295) 0.5 = 0.2966930
Corrector:
k=1 y 1 2 = 0.5651295 + [(05651295*0.52 β 1.2*05651295) + (0.296693*12 β 1.2*0.296693)]/2*0.5
= 0.4160766 ea= 28.7 %
. . . . .
Continue like this to find y(1)=0.4104059, y(1.5)=0.5279021, y(2)=2.181574
(4) Using the fourth-order RK method.
"\\begin{aligned}\n&\\mathrm{y}_{\\mathrm{i}+1}=\\mathrm{y}_{\\mathrm{i}}+\\mathrm{h}\\left(\\mathrm{k}_{\\mathbf{1}}+2 \\mathrm{k}_{\\mathbf{2}}+2 \\mathrm{k}_{\\mathbf{3}}+\\mathrm{k}_{\\mathbf{4}}\\right) \/ 6 \\\\\n&\\mathrm{k}_{\\mathbf{1}}=\\mathrm{f}\\left(\\mathrm{x}_{\\mathrm{i}}, \\mathrm{y}_{\\mathrm{i}}\\right) \\quad \\mathrm{k}_{\\mathbf{2}}=\\mathrm{f}\\left(\\mathrm{x}_{\\mathrm{i}}+\\mathrm{h} \/ 2, \\mathrm{y}_{\\mathrm{i}}+\\mathrm{k}_{\\mathbf{1}} \\mathrm{h} \/ 2\\right) \\quad \\mathrm{k}_{\\mathbf{3}}=\\mathrm{f}\\left(\\mathrm{x}_{\\mathrm{i}}+\\mathrm{h} \/ 2, \\mathrm{y}_{\\mathrm{i}}+\\mathrm{k}_{\\mathbf{2}} \\mathrm{h} \/ 2\\right) \\quad \\mathrm{k}_{\\mathbf{4}}=\\mathrm{f}\\left(\\mathrm{x}_{\\mathrm{i}}+\\mathrm{h}, \\mathrm{y}_{\\mathrm{i}}+\\mathrm{k}_{\\mathbf{3}} \\mathrm{h}\\right) \\\\\n&\\mathrm{i}=0, \\mathrm{k}_{\\mathbf{1}}=\\mathrm{f}(0,1)=-1.2, \\mathrm{k}_{\\mathbf{2}}=\\mathrm{f}(0.25,0.7)=-0.79625 \\\\\n&\\mathrm{k}_{\\mathbf{3}}=\\mathrm{f}(0.25,0.800938)=-0.91107, \\quad \\mathrm{k}_{\\mathbf{4}}=\\mathrm{f}(0.5,0.544467)=-0.51724 \\\\\n&\\mathrm{y}_{\\mathbf{1}}=\\mathrm{y}(0.5)=\\mathbf{0 . 5 7 2 3 4 4} \\quad \\varepsilon_{\\mathrm{t}}=\\mathbf{0 . 0 3 2} \\% \\\\\n&\\mathrm{i}=1, \\quad \\mathrm{k}_{\\mathbf{1}}=\\mathrm{f}(0.5,0.572344)=-0.54373, \\mathrm{k}_{\\mathbf{2}}=\\mathrm{f}(0.75,0.436412)=-0.27821 \\\\\n&\\mathrm{k}_{\\mathbf{3}}=\\mathrm{f}(0.75,0.50279)=-0.32053, \\mathrm{k}_{\\mathbf{4}}=\\mathrm{f}(1,0.412079)=-0.08242 \\\\\n&\\mathrm{y}_{\\mathbf{2}}=\\mathrm{y}(1)=\\mathbf{0 . 4 2 0 3 7 5} \\quad \\varepsilon_{\\mathrm{t}}=\\mathbf{0 . 0 0 6} \\% \\\\\n&\\mathrm{i}=2, \\quad \\mathrm{k}_{\\mathbf{1}}=\\mathrm{f}(1,0.420375)=-0.08407, \\mathrm{k}_{\\mathbf{2}}=\\mathrm{f}(1.25,0.399356)=0.144767 \\\\\n&\\mathrm{k}_{\\mathbf{3}}=\\mathrm{f}(1.25,0.456567)=0.165505, \\mathrm{k}_{\\mathbf{4}}=\\mathrm{f}(1.5,0.503128)=0.528284 \\\\\n&\\mathrm{i}_{\\mathbf{3}}=\\mathrm{y}(1.5)=\\mathbf{0 . 5 0 9 1 0 4} \\quad \\varepsilon_{\\mathrm{t}}=\\mathbf{0 . 0 1} \\% \\\\\n&\\mathrm{k}_{\\mathbf{1}}=\\mathrm{f}(1.5,0.509104)=0.534559, \\mathrm{k}_{\\mathbf{2}}=\\mathrm{f}(1.75,0.642744)=1.197111 \\\\\n&\\mathrm{k}_{\\mathbf{3}}=\\mathrm{f}(1.75,0.808382)=0.505611, \\mathrm{k}_{\\mathbf{4}}=\\mathrm{f}(2,1.26191)=3.533348 \\\\\n&\\mathrm{y}_{\\mathbf{4}}=\\mathrm{y}(2)=\\mathbf{1} .29855 \\quad \\varepsilon_{\\mathrm{t}}=\\mathbf{0 . 5 4} \\%\n\\end{aligned}"
Comments
Leave a comment