You are on page 1of 3

Hong Vit Cng USTH-BST2-013

NUMERICAL METHOD MODELING


1. Question: Solve this equation by the finite different method (Euler method) ( ) With:{ After, compare the solution with the exact solution which is solved by ODE. 2. Formula: Solution by the Euler method:

With: {

3. Code: function [result1,result2] = euler (t,dt) result1 = zeros ([1,t]); result2 = zeros ([1,t]); T = 0; tetra = pi/4; V = 0; counter = 1; while T <= t + 0.024

te = tetra; tetra = tetra + dt * V; V = V - dt * 16.1 * sin (te); result1(1,counter) = T; result2(1,counter) = tetra; T = T + dt; counter = counter + 1; end 4. Result: For >> [a,b] = euler (5,0.05); >> [c,d] = euler (5,0.025); >>plot (a,b,'g'); >> hold on; >>plot (c,d,'.'); >> r = [0:0.025:5]; >> R = pi * cos (sqrt (16.1) .* r)/4; >>plot (r, R,'o') ; (o line) (dote line) (green line)

-1

-2

-3 0

You might also like