0% found this document useful (0 votes)
125 views

%secant Method% % Fungsi Yang Dicari Akarnya % Tebakan Awal xn-1 % Tebakan Awal XN % Jumlah Iterasi Tas Toleransi

The document describes using the secant method to find the root of a polynomial function. It initializes starting values for a and b, defines the tolerance and maximum number of iterations, and then iteratively calculates new values for a, b and the error until the error is below the tolerance or the maximum iterations is reached. It outputs the results in a table and plots the error at each iteration.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

%secant Method% % Fungsi Yang Dicari Akarnya % Tebakan Awal xn-1 % Tebakan Awal XN % Jumlah Iterasi Tas Toleransi

The document describes using the secant method to find the root of a polynomial function. It initializes starting values for a and b, defines the tolerance and maximum number of iterations, and then iteratively calculates new values for a, b and the error until the error is below the tolerance or the maximum iterations is reached. It outputs the results in a table and plots the error at each iteration.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

%Secant Method%

syms x
f= x^5-(16.05*x^4)+(88.75*x^3)-(192.0375*x^2)+(116.35*x)+(31.6875);% fungsi
yang dicari akarnya
a= 0.05;
% tebakan awal xn-1
b= 0.5825;
% tebakan awal xn
n=100;
% jumlah iterasi
es= 0.0001;
%batas toleransi
N= [];
for i = 1:n
fa= subs(f,x,a);
fb= subs (f,x,b);
c = b-((b-a)*fb/(fb-fa));
ea= abs ((c-b)/c);
if ea<=es
break
end
N=[N; i a b c ea]
a = b;
b = c;
end
plot(N(:,1),N(:,5),'--mx','LineWidth',5,...
'MarkerEdgeColor','c',...
'MarkerEdgeColor','k',...
'MarkerSize',5)
title ('Secant Method')
xlabel('Iterasi')
ylabel('Akar')
grid

a=

0.0500

N=

1.0000

0.0500

0.5825 -1.4640

1.3979

0.0500

0.5825 -1.4640

1.3979

N=

1.0000

2.0000

0.5825 -1.4640

0.4757

4.0776

0.5825 -1.4640

1.3979

N=

1.0000

0.0500

2.0000

0.5825 -1.4640

3.0000 -1.4640

0.4757

4.0776

0.3701

0.2853

0.5825 -1.4640

1.3979

0.4757

N=

1.0000

0.0500

2.0000

0.5825 -1.4640

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

1.0000

0.0500

0.5825 -1.4640

1.3979

2.0000

0.5825 -1.4640

N=

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

0.3687 47.9555

N=

1.0000

0.0500

0.5825 -1.4640

1.3979

2.0000

0.5825 -1.4640

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3687 47.9555
0.3674

0.0038

0.5825 -1.4640

1.3979

N=

1.0000

0.0500

2.0000

0.5825 -1.4640

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3674

0.0038

0.3687

0.3674 -6.2523

1.0588

1.0000

0.0500

0.5825 -1.4640

1.3979

2.0000

0.5825 -1.4640

7.0000

0.3687

0.3687 47.9555

N=

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3687 47.9555
0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

0.3619 18.2757

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

0.3619 18.2757
0.3565

0.0152

0.5825 -1.4640

1.3979

N=

1.0000

0.0500

2.0000

0.5825 -1.4640

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523
10.0000

0.3619

0.3687 47.9555

0.3619

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

N=

1.0000

0.0500

0.5825 -1.4640

1.3979

2.0000

0.5825 -1.4640

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

12.0000 -4.9748

N=

0.3687 47.9555

0.3619 18.2757
0.3565

0.3565 -4.9748

0.3469

0.0152
1.0717

0.3469 15.3419
0.3373

0.0284

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3373 -3.5018

1.0963

0.3469

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3373 -3.5018

1.0963

0.3469

14.0000

0.3373 -3.5018

0.3163 12.0727

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

15.0000 -3.5018

0.3163

0.3163 12.0727
0.2955

0.0704

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3687 47.9555
0.3674

0.0038

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3674 -6.2523

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

1.0588

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.2955 -2.0440

1.1445

0.3163

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.2955 -2.0440

1.1445

0.3163

17.0000

0.2955 -2.0440

0.2390

9.5515

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

18.0000 -2.0440

0.2390

0.2390

9.5515

0.1858

0.2864

N=

1.0000

0.0500

2.0000

0.5825 -1.4640

3.0000 -1.4640

0.5825 -1.4640

0.4757

1.3979

0.4757

4.0776

0.3701

0.2853

4.0000

0.4757

5.0000

0.3701 18.0515

6.0000 18.0515

0.3701 18.0515

0.3687

0.3687 47.9555
0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.9795

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.1858 -0.8358

1.2223

0.2390

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523
10.0000

0.3619

0.3687 47.9555

0.3619

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

11.0000

0.3565 -4.9748

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

0.0287 30.1666

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.2955 -2.0440

1.1445

0.3163

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

21.0000 -0.8358

0.0287 30.1666

0.0287 -0.0736

1.3892

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

21.0000 -0.8358

0.0287 30.1666

0.0287 -0.0736

1.3892

22.0000

0.0287 -0.0736 -0.2495

0.7048

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

21.0000 -0.8358

0.0287 30.1666

0.0287 -0.0736

1.3892

0.0287 -0.0736 -0.2495

0.7048

23.0000 -0.0736 -0.2495 -0.1919

0.3000

22.0000

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

21.0000 -0.8358

0.0287 30.1666

0.0287 -0.0736

1.3892

0.0287 -0.0736 -0.2495

0.7048

23.0000 -0.0736 -0.2495 -0.1919

0.3000

24.0000 -0.2495 -0.1919 -0.1995

0.0382

22.0000

N=

1.0000

0.0500

0.5825 -1.4640

2.0000

0.5825 -1.4640

1.3979

0.4757

4.0776

3.0000 -1.4640

0.4757

0.3701

0.2853

4.0000

0.4757

0.3701 18.0515

0.9795

5.0000

0.3701 18.0515

6.0000 18.0515

0.3687

0.3674

0.0038

0.3674 -6.2523

1.0588

7.0000

0.3687

8.0000

0.3674 -6.2523

9.0000 -6.2523

0.3687 47.9555

0.3619

10.0000

0.3619

11.0000

0.3565 -4.9748

0.3619 18.2757
0.3565

0.3565 -4.9748

0.0152
1.0717

0.3469 15.3419

12.0000 -4.9748

0.3469

0.3373

0.0284

13.0000

0.3469

0.3373 -3.5018

1.0963

14.0000

0.3373 -3.5018

0.3163 12.0727

15.0000 -3.5018

0.3163

0.2955

0.0704

16.0000

0.3163

0.2955 -2.0440

1.1445

17.0000

0.2955 -2.0440

0.2390

9.5515

18.0000 -2.0440

0.2390

0.1858

0.2864

19.0000

0.2390

0.1858 -0.8358

1.2223

20.0000

0.1858 -0.8358

21.0000 -0.8358

0.0287 30.1666

0.0287 -0.0736

1.3892

0.0287 -0.0736 -0.2495

0.7048

23.0000 -0.0736 -0.2495 -0.1919

0.3000

24.0000 -0.2495 -0.1919 -0.1995

0.0382

25.0000 -0.1919 -0.1995 -0.2000

0.0024

22.0000

You might also like