0% found this document useful (0 votes)
29 views5 pages

'Dfun' 'Fun': %initialiasasi Jacobian

The document describes a Brodyen optimization algorithm for finding the root of a function. It initializes the Jacobian matrix B0 and function value f0 at the initial point p0. It then iteratively updates the point p by taking steps s to minimize the function, updating the Jacobian B at each step, until the change in p between iterations is less than the tolerance. It provides the functions fun and dfun to evaluate the target function and its Jacobian for a 3D test problem.

Uploaded by

Mona Sandelvia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views5 pages

'Dfun' 'Fun': %initialiasasi Jacobian

The document describes a Brodyen optimization algorithm for finding the root of a function. It initializes the Jacobian matrix B0 and function value f0 at the initial point p0. It then iteratively updates the point p by taking steps s to minimize the function, updating the Jacobian B at each step, until the change in p between iterations is less than the tolerance. It provides the functions fun and dfun to evaluate the target function and its Jacobian for a 3D test problem.

Uploaded by

Mona Sandelvia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

function [akar,langkah]=broyden(p0,tol)

%initialiasasi Jacobian
B0=feval('dfun',p0);
f0=feval('fun',p0);
s0=-B0\f0; p1=p0+s0;
akar=[p0]; langkah=0;
while norm(p1-p0)>tol
langkah=langkah+1;
akar=[akar p1];
yk=feval('fun',p1)-feval('fun',p0);
B1=B0+(yk-B0*s0)*s0'/(s0'*s0);
fp1=feval('fun',p1);
s1=-B1\fp1;
p2=p1+s1;
p0=p1;p1=p2;s0=s1;B0=B1;
end
%fungsi F pada F(x)=0
function F=fun(x);
n=length(x);
F=zeros(n,1);
F(1)=6870*(1+x(2)*sin(-30+x(3)))-x(1);
F(2)=6728*(1+x(2)*sin(0+x(3)))-x(1);
F(3)=6615*(1+x(2)*sin(30+x(3)))-x(1);
%Jacobiannya
function JF=dfun(x)
n=length(x);
JF=zeros(n,n);
JF(1,1)=-1;JF(1,2)=6870*sin(-30+x(3));JF(1,3)=6870*x(2)*cos(-30+x(3));
JF(2,1)=-1;JF(2,2)=6728*sin(0+x(3));JF(2,3)=6728*x(2)*cos(0+x(3));
JF(3,1)=-1;JF(3,2)=6615*sin(30+x(3));JF(3,3)=6615*x(2)*cos(30+x(3));

Output:

>> [akar,langkah]=broyden([0.1 0.1 -0.1]',1e-4)

akar =

1.0e+03 *

0.0001 6.7423 6.7423 6.7423

0.0001 -0.0000 -0.0000 -0.0000

-0.0001 -0.0001 -0.0001 -0.0001


langkah =

Ini kalo p0 nya beda yaa gaeesss


>> [akar,langkah]=broyden([1 1 -1]',1e-4)

akar =

1.0e+03 *

Columns 1 through 12

0.0010 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

0.0010 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 0.0001 -0.0001 -0.0003 -0.0003
0.0003

-0.0010 -0.0010 -0.0010 0.0002 0.0007 0.0004 0.0015 -0.0024 0.0020 0.0019 0.0022
0.0018

Columns 13 through 24
6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

-0.0001 -0.0000 -0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0001 0.0014 0.0002
0.0003

0.0018 0.0017 0.0017 -0.0028 -0.0034 -0.0029 -0.0014 -0.0026 -0.0019 0.0033 -0.0020 -
0.0024

Columns 25 through 36

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

0.0003 0.0009 0.0017 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 0.0001 0.0002 0.0001
0.0001

-0.0016 -0.0010 -0.0018 -0.0017 -0.0017 -0.0017 -0.0012 0.0022 -0.0232 -0.0500 -0.0219 -
0.0285

Columns 37 through 48

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

-0.0001 -0.0006 -0.0002 -0.0001 -0.0001 -0.0001 -0.0001 -0.0006 -0.0002 -0.0005 -0.0000 -
0.0000

-0.0052 0.0228 -0.0028 -0.0193 -0.0156 -0.0178 -0.0174 -0.0162 -0.0174 -0.0173 -0.0174 -
0.0175

Columns 49 through 60

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423
-0.0000 -0.0000 -0.0000 -0.0000 -0.0001 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -
0.0000

-0.0176 -0.0116 -0.0127 -0.0118 -0.0247 -0.0147 -0.0182 -0.0179 -0.0182 -0.0259 -0.0249 -
0.0260

Columns 61 through 72

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

-0.0001 -0.0001 -0.0002 0.0006 -0.0002 -0.0003 -0.0004 -0.0010 -0.0013 0.0023 -0.0002
0.0000

-0.0275 -0.0261 -0.0263 -0.0247 -0.0262 -0.0259 -0.0267 -0.0273 -0.0264 -0.0271 -0.0271 -
0.0270

Columns 73 through 84

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

0.0000 0.0000 -0.0001 -0.0000 -0.0000 0.0000 -0.0003 -0.0000 -0.0001 -0.0001 -0.0000 -
0.0001

-0.0270 -0.0305 0.0063 -0.0198 -0.0177 -0.0205 0.0129 -0.0175 -0.0148 -0.0190 -0.0166 -
0.0176

Columns 85 through 96

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423
6.7423

-0.0002 -0.0002 -0.0006 0.0002 -0.0001 -0.0000 -0.0000 -0.0000 0.0000 0.0000 0.0000
0.0000
-0.0179 -0.0176 -0.0175 -0.0175 -0.0177 -0.0177 -0.0177 -0.0180 -0.0224 -0.0210 -0.0220 -
0.0220

Columns 97 through 104

6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423 6.7423

0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

-0.0220 -0.0222 -0.0221 -0.0221 -0.0221 -0.0221 -0.0221 -0.0221

langkah =

103

You might also like