0% found this document useful (0 votes)
30 views2 pages

Euler Method Practical

questions for practice of euler method
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Euler Method Practical

questions for practice of euler method
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL -9

Euler’s Method
dy
Ques.1;Approximate the solution of = x + 2 y, with 0£x£1, y(0)=0 using four steps.
dx

In[17]:= euler@f_, 8x_, x0_, xn_<, 8y_, y0_<, steps_D :=


Block@8xold = x0, yold = y0, sollist = 88x0, y0<<, x, y, h<, h = N@Hxn - x0L  stepsD;

Do@xnew = xold + h;
ynew = yold + h * Hf . 8x ® xold, y ® yold<L;
sollist = Append@sollist, 8xnew, ynew<D;
xold = xnew;
yold = ynew, 8steps<D;
Return@sollistDD

euler@x + 2 y, 8x, 0, 1<, 8y, 0<, 4D

Out[18]= 880, 0<, 80.25, 0.<, 80.5, 0.0625<, 80.75, 0.21875<, 81., 0.515625<<

dy y
Ques.2;Approximate the solution of = 1 + , with 1£x£6, y(1)=1 using 10 steps.
dx x

In[19]:= euler@f_, 8x_, x0_, xn_<, 8y_, y0_<, steps_D :=


Block@8xold = x0, yold = y0, sollist = 88x0, y0<<, x, y, h<, h = N@Hxn - x0L  stepsD;

Do@xnew = xold + h;
ynew = yold + h * Hf . 8x ® xold, y ® yold<L;
sollist = Append@sollist, 8xnew, ynew<D;
xold = xnew;
yold = ynew, 8steps<D;
Return@sollistDD

, 8x, 1, 6<, 8y, 1<, 10F


y
eulerB1 +
x
Out[20]= 881, 1<, 81.5, 2.<, 82., 3.16667<, 82.5, 4.45833<, 83., 5.85<, 83.5, 7.325<,
84., 8.87143<, 84.5, 10.4804<, 85., 12.1448<, 85.5, 13.8593<, 86., 15.6193<<

dy y
Ques.3;Approximate the solution of = , with 0£x£5, y(0)=1 using 10 steps.
dx x
2 Untitled-1

In[25]:= euler@f_, 8x_, x0_, xn_<, 8y_, y0_<, steps_D :=


Block@8xold = x0, yold = y0, sollist = 88x0, y0<<, x, y, h<, h = N@Hxn - x0L  stepsD;

Do@xnew = xold + h;
ynew = yold + h * Hf . 8x ® xold, y ® yold<L;
sollist = Append@sollist, 8xnew, ynew<D;
xold = xnew;
yold = ynew, 8steps<D;
Return@sollistDD

eulerB , 8x, 1, 5<, 8y, 1<, 10F


y
x
Out[26]= 881, 1<, 81.4, 1.4<, 81.8, 1.8<, 82.2, 2.2<, 82.6, 2.6<,
83., 3.<, 83.4, 3.4<, 83.8, 3.8<, 84.2, 4.2<, 84.6, 4.6<, 85., 5.<<

dy
Ques.4;Approximate the solution of = xy3 - y, with 0£x£1, y(0)=1 using 4 steps.
dx

In[27]:= euler@f_, 8x_, x0_, xn_<, 8y_, y0_<, steps_D :=


Block@8xold = x0, yold = y0, sollist = 88x0, y0<<, x, y, h<, h = N@Hxn - x0L  stepsD;

Do@xnew = xold + h;
ynew = yold + h * Hf . 8x ® xold, y ® yold<L;
sollist = Append@sollist, 8xnew, ynew<D;
xold = xnew;
yold = ynew, 8steps<D;
Return@sollistDD

eulerAxy3 - y , 8x, 0, 1<, 8y, 1<, 4E

Out[28]= 980, 1<, 90.25, 1 + 0.25 I- 1 + xy3 M=,


90.5, 1 + 0.25 I- 1 + xy3 M + 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MM=,
90.75, 1 + 0.25 I- 1 + xy3 M + 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MM +
0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 M - 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MMM=,
91., 1 + 0.25 I- 1 + xy3 M + 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MM +
0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 M - 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MMM +
0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 M - 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MM -
0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 M - 0.25 I- 1 + xy3 - 0.25 I- 1 + xy3 MMMM==

You might also like