ian Persamaan Differensial Biasa Menggunakan Metode Runge

23
PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0 Z, Rahmawati (2011) PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0. Other thesis, Fakultas MIPA. PDF (PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0) - Supplemental Material Available under License Creative Commons Public Domain Dedication . Download (252Kb) | Preview Abstract Persoalan yang melibatkan model matematika banyak muncul dalam berbagai disiplin ilmu pengetahuan. Seringkali model matematika tersebut muncul dalam bentuk yang rumit. Salah satu persamaan pemodelan matematika mengambil bentuk Persamaan Differensial Biasa (PDB). Metode numerik digunakan untuk menyelesaikan PDB tersebut, terutama kasus PDB yang tidak bisa diselesaikan secara analitik. Metode yang digunakan adalah metode Runge-Kutta dengan orde 2,3 dan 4. Metode ini menghasilkan penyelesaian PDB dengan tingkat ketelitian yang tinggi. Metode Runge-Kutta orde 2,3 dan 4 dapat diaplikasikan ke dalam bahasa pemrograman. Program yang digunakan adalah Matlab 7.0. Tujuan aplikasi ini adalah untuk mempermudah perhitungan dari metode Runge-Kutta orde 2,3 dan 4 sehingga didapatkan nilai pendekatan (aproksimasi) dengan kesalahan (error) yang kecil. Kata kunci : Persamaan diferensial biasa, deret Taylor, eksak, aproksimasi, error, metode Euler, Rungge-Kutta orde 2,3 dan 4, Matlab 7.0

Transcript of ian Persamaan Differensial Biasa Menggunakan Metode Runge

Page 1: ian Persamaan Differensial Biasa Menggunakan Metode Runge

PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0Z, Rahmawati (2011) PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0. Other thesis, Fakultas MIPA.

PDF (PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA MENGGUNAKAN METODE RUNGE-KUTTA DENGAN MATLAB 7.0) - Supplemental Material Available under License Creative Commons Public Domain Dedication. Download (252Kb) | Preview

Abstract

Persoalan yang melibatkan model matematika banyak muncul dalam berbagai disiplin ilmu pengetahuan. Seringkali model matematika tersebut muncul dalam bentuk yang rumit. Salah satu persamaan pemodelan matematika mengambil bentuk Persamaan Differensial Biasa (PDB). Metode numerik digunakan untuk menyelesaikan PDB tersebut, terutama kasus PDB yang tidak bisa diselesaikan secara analitik. Metode yang digunakan adalah metode Runge-Kutta dengan orde 2,3 dan 4. Metode ini menghasilkan penyelesaian PDB dengan tingkat ketelitian yang tinggi. Metode Runge-Kutta orde 2,3 dan 4 dapat diaplikasikan ke dalam bahasa pemrograman. Program yang digunakan adalah Matlab 7.0. Tujuan aplikasi ini adalah untuk mempermudah perhitungan dari metode Runge-Kutta orde 2,3 dan 4 sehingga didapatkan nilai pendekatan (aproksimasi) dengan kesalahan (error) yang kecil. Kata kunci : Persamaan diferensial biasa, deret Taylor, eksak, aproksimasi, error, metode Euler, Rungge-Kutta orde 2,3 dan 4, Matlab 7.0

Item Type: Thesis (Other)

Subjects: Q Science > QA Mathematics

Unit atau Lembaga:Fakultas MIPA > MatematikaPaca Sarjana > Doktor > Fakultas MIPA > Matematika

Depositing User: Haryoshi Utami

Page 2: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Date Deposited: 28 Mar 2011 15:29

Last Modified: 28 Mar 2011 15:29

URI: http://repository.unand.ac.id/id/eprint/9459

KOMBINASI KESTABILAN METODE RUNGE KUTTA DAN METODE PREDIKTOR KOREKTOR ADAMS PADA PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASADAFIA FIRDAUS

DOI: FIRDAUS, DAFIA (2006) KOMBINASI KESTABILAN METODE RUNGE KUTTA DAN METODE PREDIKTOR KOREKTOR ADAMS PADA PENYELESAIAN PERSAMAAN DIFFERENSIAL BIASA. Undergraduate thesis, University of Muhammadiyah Malang.

Abstract

Persamaan yang mengandung turunan fungsi satu peubah dapat ditemukan disetiap cabang ilmu yang menggunakan matematika. Model matematika dapat digunakan berbagai fenomena fisik maupun non fisik, salah satunya seperti laju pertumbuhan populasi. Ada dua cara menyelesaikan persamaan differensial yaitu secara analitis dan secara numeris. Penyelesaian secara analitis diperoleh solusi yang dihasilkan bersifat eksak, sedangkan penyelesaian secara numeris menghasilkan solusi berupa hampiran yang diperoleh dengan menggunakan numerik tertentu. Penyelesaian secara numeris menggunakan metode-metode numerik tertentu yaitu metode Runge Kutta , Metode Prediktor Korektor Adams dan kombinasi kedua metode tersebut. Masing- masing metode mempunyai kelebihan dan kekurangan yaitu untuk metode Runge Kutta dalam mencari nilai pada dan hanya menggunakan titik tetapi pencarian galat sulit dilakukan, sedangkan untuk metode Prediktor Korektor Adams galat dapat ditentukan dengan mudah tetapi untuk mencari nilai pada dan memerlukan titik sebelumya , sehingga dengan melakukan kombinasi kekurangan dari masing-masing metode dapat saling melengkapi. Dari metode-metode yang digunakan dan kombinasi kedua metode merupakan metode yang stabil dan lebih baik karena nilai yang didapat lebih teliti dan galat yang diperoleh lebih kecil sehingga menuju

Page 3: ian Persamaan Differensial Biasa Menggunakan Metode Runge

konstan. Adapun langkah-langkah kombinasinya sebagai berikut: a. Mulailah jawaban dengan metode Runge Kutta orde empat, seperti untuk mendapatkan . b. Gunakan pasangan prediktor korektor dan untuk menghitung . c. Jika diperlukan lebih dari dua iterasi dari korektor untuk mendapatkan ketelitian yang diinginkan atau jika kesalahan pemotongan yang diberikan terlalu besar, kurangi langkah (lihat d di bawah). Jika sebaliknya galat pemotongan sangat kecil, maka ukuran langkah dapat diperbesar. d. Untuk mengubah ukuran langkah, pandang nilai terakhir dari y yang cukup teliti untuk dijadikan titik awal. Mulai kembali jawaban dari titik tersebut, dengan menggunakan metode Runge Kutta seperti pada (a) diatas. e. Jika telah diperoleh dari korektor, maka gunakan.

Share

Comments on this publication

ResearchGate members can add comments. Sign up now and post your comment!

Similar publications

METODE SUCCESSIVE APPROXIMATION PADA PENYELESAIAN PERSAMAAN DIFFERENSIAL

Authors: Baitatul Syah Akbar Pahlevi

Aggregation-enhanced fluorescence in PEGylated phospholipid nanomicelles for in vivo imaging

Authors: Dan Wang, Jun Qian, Sailing He, Jin Sun Park, Kwang-Sup Lee, Sihai Han, Ying Mu

Biomaterials. 09/2011; 32(25):5880-8.

Degradation of m-xylene solution using ultrasonic irradiation

Authors: Weiping Xie, Yan Qin, Dingmin Liang, Dan Song, Dewen He

Ultrasonics sonochemistry. 09/2011; 18(5):1077-81.

Increased Frequency of CD4(+)CD25 (high)FoxP3 (+) Regulatory T Cells in Patients with Hepatocellular Carcinoma

Authors: Xi Feng, Bo Li, Hui Ye, Dan Long

Archivum immunologiae et therapiae experimentalis. 08/2011; 59(4):309-14.

Examination of microbial fuel cell start-up times with domestic wastewater and additional amendments

Page 4: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Authors: Guangli Liu, Matthew D Yates, Shaoan Cheng, Douglas F Call, Dan Sun, Bruce E Logan

Bioresource technology. 08/2011; 102(15):7301-6.

Data provided are for informational purposes only. Although carefully collected, accuracy cannot be guaranteed. The impact factor represents a rough estimation of the journal's impact factor and does not reflect the actual current impact factor. Publisher conditions are provided by RoMEO. Differing provisions from the publisher's actual policy or licence agreement may be applicable.

Download Full Text

The full text version has yet to be made available for download by the author.

Science & Research Jobs

Senior Researcher Visual Communications

Position: Researcher

Employer: Alcatel-Lucent Bell Labs

Dental Officer Job

Position: Other

Employer: Royal Australian Air Force

View jobs

© 2011 researchgate.net. All rights reserved. About Us · Research Blog · News · Privacy · Terms

Page 5: ian Persamaan Differensial Biasa Menggunakan Metode Runge

PERBANDINGAN KESALAHAN ANTARA METODE RUNGE-KUTTA DAN METODE MILNE PADA PENYELESAIAN PERSAMAAN DIFERENSIAL BIASADyah Setyo P

Abstract

Banyak permasalahan dalam bidang ilmu pengetahuan dan teknik yang dapat diformulasikan ke dalam persamaan diferensial. Penyelesaian persamaan diferensial adalah suatu fungsi yang memenuhi persamaan diferensial dan juga memenuhi kondisi awal yang diberikan pada persaman tersebut. Di dalam penyelesaiaan persamaan diferensial secara analitis, biasanya dicari penyelesaian umum yang mengandung konstanta sebarang dan kemudian mengevaluasi konstanta tersebut sedemikian sehingga hasilnya sesuai dengan kondisi awal.Penggunaan metode numerik dalam penyelesaian masalah matematika salah satunya adalah untuk mencari penyelesaian nilai awal persamaan diferensial biasa. Dalam menyelesaikan masalah nilai awal persamaan diferensial biasa yang akan digunakan adalah Metode Runge-Kutta orde dua dan Metode Milne. Bentuk umum metode Runge-Kutta sedangkan metode Milne sebagai prediktor dan sebagai korektor. Penulisan ini akan membahas masalah perbandingan kesalahan dari penggunaan kedua metode tersebut. Dalam menentukan prediksi yang baik dilihat dari kesalahan pemotongan global terkecil dari tiap metode. Ternyata metode yang menghasilkan kesalahan pemotongan global lebih kecil adalah metode Milne.

TRANSLATION

Many problem of science area and technique able to abbreviation into equation of differential. Solving of equation of differential is a function fulfilling equation of differential as well as fulfilling the condition of early passed to the equation. In solution of equation of differential analytically, [is] usually searched [by] the solving of pregnant public goods constant and later; then evaluate the constant in such a way that its result as according to condition of early.Usage of method of numeric in solving of the problem of mathematics one of them is to look for the solving of value early equation of ordinary differential. In finishing the problem of value early equation of ordinary differential to be used is Method of Runge-Kutta order two and Method of Milne. Common form method of Runge-Kutta while method of Milne as predictor and as proofreader.This writing will study the problem of comparison of mistake of usage both [of] method. In

Page 6: ian Persamaan Differensial Biasa Menggunakan Metode Runge

determining predicts which is good to be seen from mistake of smallest global amputation of each method. In the reality method yielding mistake of smaller global amputation method of Milne.

 

Keyword : persamaan diferensial biasa, metode runge-kutta, metode milne

Related Links :  http://skripsi.umm.ac.id/files/disk1/20/jiptummpp-gdl-s1-2004-dyahsetyop-976-PENDAHUL-N.pdf

Abstract: PDF , PS , DOC

+

+

=

∑= −

1

1

)

(

2

)

(

)

(

Page 7: ian Persamaan Differensial Biasa Menggunakan Metode Runge

2

ni

i

x

f

b

f

a

f

h

I

(2.4)

Dengan selang a ke b dipecah menjadi n sub interval dengan lebar yang

sama h=(b-a)/n dan

k

k

h

a

x

+

=

untuk k=1,2,3,……..n dan k=123....n dan a=x0

<…<x

1

xn

< xn =b.

2.6

Metode Simpson

Page 8: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Metode Simpson merupakan metode yang lebih teliti dibanding luas

trepesium. Bila proses diulang pada interval (a,b) menjadi 2n subinterval yang

berlebar sama h=(b-a)/2n dan dan

k

k

h

a

x

+

=

untuk k=1,2,3,……..n dan

k=123...2n dan a=x0 <…<x

1

xn

< x n

2

=b.

Rumus Simpson untuk f(x) dengan 2n subinterval berlebar h:

+

+

+

=

Page 9: ian Persamaan Differensial Biasa Menggunakan Metode Runge

==

=

11

1

1

2

2

)

(

3

4

)

(

3

2

)

(

)

(

3

)

(

nk

n

k

k

k

x

Page 10: ian Persamaan Differensial Biasa Menggunakan Metode Runge

f

h

x

f

h

b

f

a

f

h

x

f

(2.5)

2.7

Algoritma Metode Luas Trapesium dan Metode Simpson

Algoritma adalah sebuah alir program yang menunjukkan langkah demi

langkah dalam menyelesaikan sebuah persoalan.

Adapun algoritma Metode Luas Trapesium adalah :

1.Menentukan fungsi y=f(x) yang akan dihitung.

2.Masukkan masukan a,b dan n.

3. Lebar subinterval dapat dihitung dengan:

h=(b-a)/n

9

4. Jumlah awal=0

5.Hitung luas trapesium setiap subinterval dari k=1 sampai n-1 dengan

Selama k<n-1:

Page 11: ian Persamaan Differensial Biasa Menggunakan Metode Runge

- x=a+h*k

-

Jumlah=Jumlah+fungsi(x);

6.Jumlahkan luas trapesium dari setiap subinterval pertama sampai

dengan luas trapesium subinterval yang ke n dengan:

Jumlah=h*fungsi(a)+fungsi(b)+2*Jumlah)/2

Sedangkan untuk Metode Simpson algoritmanya adalah :

1.Menentukan fungsi y=f(x) yang akan dihitung.

2. Masukkan masukan a,b dan n.

3. Lebar subinterval dapat dihitung dengan:

h=(b-a)/2n

4.JumlahGenap=0

5.Hitung luas setiap subinterval dari k=1 sampai n-1 dengan

Selama k<n-1:

-

x=a+h*2*k

-

JumlahGenap=JumlahGenap+fungsi(x);

7. JumalahGanjil=0

8.Hitung luas setiap subinterval dari k=1 sampai n dengan

Selama k<n:

- x=a+h*(2*k-1));

-

JumlahGanjil=JumlahGanjil+Fungsi(x);

10

9.Jumlahkan luas dari setiap subinterval pertama sampai dengan luas

subinterval yang ke n dengan:

Page 12: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Milne-Simpson's Method for O.D.E.'s

   

    The methods of Euler, Heun, Taylor and Runge-Kutta are called single-step methods because they use only the information from one previous point to compute the successive point, that is, only the initial point     is used to compute     and in general     is needed to compute   .  After several points have been found it is feasible to use several prior points in the calculation.  The Milne-Simpson method uses   in the calculation of

.  This method is not self-starting;  four initial points   , , ,  and must be given in advance in order to generate the points .  

    A desirable feature of a multistep method is that the local truncation error (L. T. E.) can be determined and a correction term can be included, which improves the accuracy of the answer at each step.  Also, it is possible to determine if the step size is small enough to obtain an accurate value for   , yet large enough so that unnecessary and time-consuming calculations are eliminated.  If the code for the subroutine is fine-tuned, then the combination of a  predictor and corrector requires only two function evaluations of  f(t,y)  per step.  

 

Milne-Simpson Metode O.D.E. 's

   

     Metode Euler, Heun, Taylor dan Runge-Kutta yang disebut single-langkah metode karena mereka menggunakan hanya informasi dari satu titik sebelumnya untuk menghitung titik yang berurutan, yaitu, hanya titik awal [Grafis: Images/MilneSimpsonMod_gr_1.gif] digunakan untuk menghitung [Grafis: Images/MilneSimpsonMod_gr_2.gif] dan secara umum [Grafis: Images/MilneSimpsonMod_gr_3.gif] diperlukan untuk menghitung [Grafis: Images/MilneSimpsonMod_gr_4.gif]. Setelah beberapa poin telah ditemukan itu layak untuk menggunakan beberapa poin sebelumnya dalam perhitungan. Metode Milne-Simpson menggunakan [Grafis: Images/MilneSimpsonMod_gr_5.gif] dalam perhitungan [Grafis: Images/MilneSimpsonMod_gr_6.gif]. Metode ini bukan diri-mulai; titik awal empat [Grafis: Images/MilneSimpsonMod_gr_7.gif], [Grafis: Images/MilneSimpsonMod_gr_8.gif], [Grafis: Images/MilneSimpsonMod_gr_9.gif], dan [Grafis: Images/MilneSimpsonMod_gr_10.gif ] harus diberikan di muka untuk menghasilkan poin [Grafis: Images/MilneSimpsonMod_gr_11.gif].

     Sebuah fitur yang diinginkan dari sebuah metode tahapan adalah bahwa kesalahan

Page 13: ian Persamaan Differensial Biasa Menggunakan Metode Runge

pemotongan lokal (LTE) dapat ditentukan dan istilah koreksi dapat dimasukkan, yang meningkatkan keakuratan dari jawaban di setiap langkah. Juga, adalah mungkin untuk menentukan apakah ukuran langkah cukup kecil untuk mendapatkan nilai yang akurat untuk [Grafis: Images/MilneSimpsonMod_gr_12.gif], namun cukup besar sehingga perhitungan tidak perlu dan memakan waktu dieliminasi. Jika kode untuk subrutin ini fine-tuned, maka kombinasi dari prediktor dan korektor membutuhkan evaluasi fungsi hanya dua dari f (t, y) per langkah.

Baru! Klik kata di atas untuk melihat terjemahan alternatif. SingkirkanGoogle Terjemahan untuk:Penelusuran Video Email Ponsel Obro

Theorem  (Milne-Simpson's Method)  Assume that  f(t,y)  is continuous and satisfies a Lipschits condition in the variable  y,  and consider the  I. V. P. (initial value problem)

             with ,  over the interval   .        The Milne-Simpson method uses the formulas ,  and  

the predictor           ,  and

the corrector              for     

as an approximate solution to the differential equation using the discrete set of points   .  

Remark.  The Milne-Simpson method is not a self-starting method.  Three additional starting values   must be given.  They are usually computed using the Runge-Kutta method.

Teorema (Metode Milne-Simpson) Asumsikan bahwa f (t, y) adalah kontinu dan memenuhi kondisi Lipschits dalam variabel y, dan mempertimbangkan IVP (masalah nilai awal)

             [Grafis: Images/MilneSimpsonMod_gr_13.gif] dengan [Grafis: Images/MilneSimpsonMod_gr_14.gif], selama interval [Grafis: Images/MilneSimpsonMod_gr_15.gif].        Metode Milne-Simpson menggunakan rumus [Grafis: Images/MilneSimpsonMod_gr_16.gif], dan

prediktor yang [Grafis: Images/MilneSimpsonMod_gr_17.gif], dan

korektor [Grafis: Images/MilneSimpsonMod_gr_18.gif] untuk [Grafis: Images/MilneSimpsonMod_gr_19.gif]

sebagai solusi perkiraan untuk persamaan diferensial menggunakan set diskrit poin [Grafis: Images/MilneSimpsonMod_gr_20.gif].

Page 14: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Catatan. Metode Milne-Simpson tidak metode self-mulai. Tiga nilai awal tambahan [Grafis: Images/MilneSimpsonMod_gr_21.gif] harus diberikan. Mereka biasanya dihitung dengan menggunakan metode Runge-Kutta.Baru! Klik kata di atas untuk melihat terjemahan alternatif. SingkirkanGoogle Terjemahan untuk:Penelusuran Video Email Ponsel Obro

echo on; clc;%---------------------------------------------------------------------------%A9_7 MATLAB script file for implementing Algorithm 9.7%% NUMERICAL METHODS: MATLAB Programs, (c) John H. Mathews 1995% To accompany the text:% NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992% Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A.% Prentice Hall, Inc.; USA, Canada, Mexico ISBN 0-13-624990-6% Prentice Hall, International Editions: ISBN 0-13-625047-5% This free software is compliments of the author.% E-mail address: in%"[email protected]"%% Algorithm 9.7 (Milne-Simpson Method).% Section 9.6, Predictor-Corrector Method, Page 472%---------------------------------------------------------------------------

clc; clear all; format long;

% - - - - - - - - - - - - - - - - - - - - - - - - - - - -%% This program implements Milne-Simpson method%% for solving the initial value problem%% y' = f(t,y) with y(a) = y0%%%% Define and store the function f(t,y) in the M-file f.m % function z = f(t,y)% z = 30 - 5*y;

pause % Press any key to continue.

clc;%.......................................................................% Begin a section which enters the function(s) necessary for the example% into M-file(s) by executing the diary command in this script file.% The preferred programming method is not to use these steps.% One should enter the function(s) into the M-file(s) with an editor.delete outputdelete f.mdiary f.m; disp('function z = f(t,y)');... disp('z = 30 - 5*y;');...

Page 15: ian Persamaan Differensial Biasa Menggunakan Metode Runge

diary off;f(0,0); % Remark. f.m rk4.m milne.m are used for Algorithm 9.7pause % Press any key to continue.

clc;

% - - - - - - - - - - - - - - - - - - - - - - - - -%% Example for figure 9.13(b), page 471. % Use the Milne-Simpson method% to solve the differential equation y' = 30 - 5y.%% Enter the endpoints a and b of the interval [a,b].% Enter the initial value y(a) in ya.% Enter the number of subintervals in n.

a = 0;b = 10;ya = 1;n = 110;

pause % Press any key to continue.

clc;% Set up the step size, and vectors T and Y.h = (b - a)/n;T = zeros(1,n+1);Y = zeros(1,n+1);

% Generate three starting values using the Runge-Kutta method.[Ts,Ys] = rk4('f',a,a+3*h,ya,6);T(1:4) = Ts(1:2:7);Y(1:4) = Ys(1:2:7);

% Proceed with the Milne-Simpson method.[T,Y] = milne('f',T,Y);points = [T;Y];

pause % Press any key to see the list of solution points.

clc; figure(1); clf;

%~~~~~~~~~~~~~~~~~~~~~~~% Begin graphics section%~~~~~~~~~~~~~~~~~~~~~~~a = 0;b = 10;c = 0;d = 7;whitebg('w');plot([a b],[0 0],'b',[0 0],[c d],'b');axis([a b c d]);axis(axis);hold on;plot(T,Y,'-r');xlabel('t');ylabel('y');

Page 16: ian Persamaan Differensial Biasa Menggunakan Metode Runge

Mx1 = 'Milne-Simpson solution to y` = f(t,y).';title(Mx1);grid;hold off;figure(gcf); pause % Press any key to continue.

clc;%............................................% Begin section to print the results.% Diary commands are included which write all% the results to the Matlab textfile output%............................................Mx2 = ' t(k) y(k)';Mx3 = 'The Milne-Simpson method is stable';Mx4 = ['for n = ',num2str(n),' and h = '];Mx5 = [Mx4,num2str(h),' because'];Mx6 = ' h < 0.45/|f (t,y)|';Mx7 = ' y';clc,echo off,diary output,...disp(''),disp(Mx1),disp(''),disp(Mx2),disp(points'),...disp(Mx3),disp(Mx5),disp(''),disp(Mx6),disp(Mx7),...diary off, echo onpause % Press any key to perform the Milne-Simpson method.

clc;

% - - - - - - - - - - - - - - - - - - - - - - - - -%% Example for figure 9.13(b), page 471. % Use the Milne-Simpson method% to solve the differential equation y' = 30 - 5y.%% Enter the endpoints a and b of the interval [a,b].% Enter the initial value y(a) in ya.% Enter the number of subintervals in n.

a = 0;b = 10;ya = 1;n = 93;

pause % Press any key to continue.

clc;% Set up the step size, and vectors T and Y.h = (b - a)/n;T = zeros(1,n+1);Y = zeros(1,n+1);

% Generate three starting values using the Runge-Kutta method.[Ts,Ys] = rk4('f',a,a+3*h,ya,6);T(1:4) = Ts(1:2:7);Y(1:4) = Ys(1:2:7);

% Proceed with the Milne-Simpson method.[T,Y] = milne('f',T,Y);points = [T;Y];

Page 17: ian Persamaan Differensial Biasa Menggunakan Metode Runge

pause % Press any key to see the list of solution points.

clc; figure(2); clf;

%~~~~~~~~~~~~~~~~~~~~~~~% Begin graphics section%~~~~~~~~~~~~~~~~~~~~~~~a = 0;b = 10;c = 0;d = 7;whitebg('w');plot([a b],[0 0],'b',[0 0],[c d],'b');axis([a b c d]);axis(axis);hold on;plot(T,Y,'-g');xlabel('t');ylabel('y');Mx1 = 'An unstable Milne-Simpson solution to y` = f(t,y).';title(Mx1);grid;hold off;figure(gcf); pause % Press any key to continue.

clc;%............................................% Begin section to print the results.% Diary commands are included which write all% the results to the Matlab textfile output%............................................Mx3 = 'The Milne-Simpson method is unstable';Mx4 = ['for n = ',num2str(n),' and h = '];Mx5 = [Mx4,num2str(h),' because'];Mx6 = ' 0.45/|f (t,y)| < h';Mx7 = ' y';clc,echo off,diary output,...disp(''),disp(Mx1),disp(''),disp(Mx2),disp(points'),...disp(Mx3),disp(Mx5),disp(''),disp(Mx6),disp(Mx7),...diary off, echo on

echo on; clc;%---------------------------------------------------------------------------%A9_7 MATLAB script file for implementing Algorithm 9.7%% NUMERICAL METHODS: MATLAB Programs, (c) John H. Mathews 1995% To accompany the text:% NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992% Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A.% Prentice Hall, Inc.; USA, Canada, Mexico ISBN 0-13-624990-6% Prentice Hall, International Editions: ISBN 0-13-625047-5% This free software is compliments of the author.% E-mail address: in%"[email protected]"%

Page 18: ian Persamaan Differensial Biasa Menggunakan Metode Runge

% Algorithm 9.7 (Milne-Simpson Method).% Section 9.6, Predictor-Corrector Method, Page 472%---------------------------------------------------------------------------

clc; clear all; format long;

% - - - - - - - - - - - - - - - - - - - - - - - - - - - -%% This program implements Milne-Simpson method%% for solving the initial value problem%% y' = f(t,y) with y(a) = y0%%%% Define and store the function f(t,y) in the M-file f.m % function z = f(t,y)% z = 30 - 5*y;

pause % Press any key to continue.

clc;%.......................................................................% Begin a section which enters the function(s) necessary for the example% into M-file(s) by executing the diary command in this script file.% The preferred programming method is not to use these steps.% One should enter the function(s) into the M-file(s) with an editor.delete outputdelete f.mdiary f.m; disp('function z = f(t,y)');... disp('z = 30 - 5*y;');...diary off;f(0,0); % Remark. f.m rk4.m milne.m are used for Algorithm 9.7pause % Press any key to continue.

clc;

% - - - - - - - - - - - - - - - - - - - - - - - - -%% Example for figure 9.13(b), page 471. % Use the Milne-Simpson method% to solve the differential equation y' = 30 - 5y.%% Enter the endpoints a and b of the interval [a,b].% Enter the initial value y(a) in ya.% Enter the number of subintervals in n.

a = 0;b = 10;ya = 1;n = 110;

pause % Press any key to continue.

clc;% Set up the step size, and vectors T and Y.

Page 19: ian Persamaan Differensial Biasa Menggunakan Metode Runge

h = (b - a)/n;T = zeros(1,n+1);Y = zeros(1,n+1);

% Generate three starting values using the Runge-Kutta method.[Ts,Ys] = rk4('f',a,a+3*h,ya,6);T(1:4) = Ts(1:2:7);Y(1:4) = Ys(1:2:7);

% Proceed with the Milne-Simpson method.[T,Y] = milne('f',T,Y);points = [T;Y];

pause % Press any key to see the list of solution points.

clc; figure(1); clf;

%~~~~~~~~~~~~~~~~~~~~~~~% Begin graphics section%~~~~~~~~~~~~~~~~~~~~~~~a = 0;b = 10;c = 0;d = 7;whitebg('w');plot([a b],[0 0],'b',[0 0],[c d],'b');axis([a b c d]);axis(axis);hold on;plot(T,Y,'-r');xlabel('t');ylabel('y');Mx1 = 'Milne-Simpson solution to y` = f(t,y).';title(Mx1);grid;hold off;figure(gcf); pause % Press any key to continue.

clc;%............................................% Begin section to print the results.% Diary commands are included which write all% the results to the Matlab textfile output%............................................Mx2 = ' t(k) y(k)';Mx3 = 'The Milne-Simpson method is stable';Mx4 = ['for n = ',num2str(n),' and h = '];Mx5 = [Mx4,num2str(h),' because'];Mx6 = ' h < 0.45/|f (t,y)|';Mx7 = ' y';clc,echo off,diary output,...disp(''),disp(Mx1),disp(''),disp(Mx2),disp(points'),...disp(Mx3),disp(Mx5),disp(''),disp(Mx6),disp(Mx7),...diary off, echo onpause % Press any key to perform the Milne-Simpson method.

Page 20: ian Persamaan Differensial Biasa Menggunakan Metode Runge