0% found this document useful (0 votes)
16 views1 page

'Dfun' 'Fun': %initialiasasi Jacobian

The document describes a Brodyen method algorithm to find the root of a function F(x)=0. It initializes the Jacobian B0 and function value f0 at the initial point p0. It then iteratively calculates new points p1, p2 etc. by taking steps s0, s1 etc. that minimize the function using the current Jacobian. The Jacobian and function values are updated at each step. It returns the root values akar and number of iterations langkah when the change in p is below a tolerance tol.

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)
16 views1 page

'Dfun' 'Fun': %initialiasasi Jacobian

The document describes a Brodyen method algorithm to find the root of a function F(x)=0. It initializes the Jacobian B0 and function value f0 at the initial point p0. It then iteratively calculates new points p1, p2 etc. by taking steps s0, s1 etc. that minimize the function using the current Jacobian. The Jacobian and function values are updated at each step. It returns the root values akar and number of iterations langkah when the change in p is below a tolerance tol.

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/ 1

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)=x(1)^3+x(1)^2*x(2)-x(1)*x(3)+6;
F(2)=exp(x(1))+exp(x(2))-x(3);
F(3)=x(2)^2-2*x(1)*x(3)-4;
%Jacobiannya
function JF=dfun(x)
n=length(x);
JF(1,1)=3*x(1)^2+2*(x(1)*x(2))-x(3);JF(1,2)=x(1)^2;JF(1,3)=-x(1);
JF(2,1)=exp(x(1));JF(2,2)=exp(x(2));JF(2,3)=-1;
JF(3,1)=-2*x(3);JF(3,2)=2*x(2);JF(3,3)=-2*x(1);

OUTPUT
>> p0=[-1 -2 1]';
>> [akar,langkah]=broyden(p0,1e-6)

akar =

-1.0000 -1.6367 -1.4036 -1.4577 -1.4574 -1.4559 -1.4560


-1.4560
-2.0000 -1.5143 -1.6799 -1.6575 -1.6619 -1.6644 -1.6642
-1.6642
1.0000 0.3347 0.4552 0.4248 0.4227 0.4225 0.4225
0.4225

langkah =

You might also like