Sunteți pe pagina 1din 12

BISECTION METHOD

Variables

F: the given equation, real function with real arguments

ls, ld: interval limits, real;

er: computational precision, real;

rad: root, real;

if F(ls)*F(ld)>0 then { we have no solution, stop}

else

if F(ls) = 0 then {the root is rad=ls; stop}

if F(ld) = 0 then {the root is rad=ld; stop}

xm = (ls+ld)/2;

while (absolute(ld-ls)>er) and (F(xm)!=0)

xm = (ls+ld)/2;

if F(xm)F(ls)<0 then ld = xm;

else ls = xm;

The root is rad=xm;

root
NEWTON RAPHSON METHOD

Variables

F the given equation, real function with real arguments)

x(0: starting-point value, real;

der: the derivative in xn_1, real;

prec: differentiation neighborhood and desired precision, real;

xn: root's current value, real;

xn_1: root's preceding value, real;

rad: the equation's root, real;

xn = x0;

repeat

xn_1=xn;

xn=xn_1-F(xn_1)/der;

} until(fabs(xn-xn_1)<er)

rad = xn

root

ITERATION METHOD
Variables

F: the given equation, real function with real arguments)

x0: starting point, real;

er: precision

xn = x0;

repeat {

xn_1 = xn;

xn = F(xn_1);

} until fabs(xn-xn_1)<er;

rad = xn;

print "The solution is rad";

root

LOWER TRIANGLE

Variables

for i=marimea lui a la 1 // 1 la marimea lui a

b(i)=b(i)/a(i,i)

for j=i-1 la 1 // -i+1 la marimea lui a

b(j)=b(j)-b(i)*a(j,i)
a(j,:)=a(j,:)-a(i,:)a(j,i)

al=a // au=a

bl=b // bu=b

GAUSS ELIMINATION

Variables

[a,b] = lower/upper a si b

x=matrice de zerouri de marimea lui a si 1 // marimea lui b

x(1)=b(1)/a(1,1)

for i=2 la marimea lui a

x(i)=(b(i)-a(i,1:i-1)x(1:i-1)/a(i,i)

CROUT METHOD

Arguments ( MAT: matrix of the unknonwns' coefficients, real;

TL: the constant terms' array, real;

X: the array of the system's solutions, real;

U: upper triangular matrix having the main diagonal set to 1;

L: lower triangular matrix, real; n: system's order, integer;

i,j: line and column indexes, respectively, integer;

for i from 1 to n{

l(i,1)=a(i,1);
}

For i from 2 to n{

u(1,i)=a(1,i)/a(1,1);
}

For i from 2 to n{

For j from 2 to i{

l(i,j)=a(i,j)-l(i,1:j-1)*u(1:j-1,j);
}

For j from i+1 to n{

u(i,j)=(a(i,j)-l(i,1:i-1)*u(1:i-1,j))/l(i,i);
}}

d(1)=b(1,1)/l(1,1)
for I from 2 to n{

d(i)=(b(i)-l(i,1:i-1)*d(1:i-1))/l(i,i);
}

X(n)=d(n)

From I from n to 1{

x(i)=(d(i)-u(i,i+1:n)*x(i+1:n))/u(i,i);
}

JACOBI METHOD

Variables

prec

x0 = matrice de zerouri de marimea lui b

for i = 1 la marimea lui a

{
b(i)=b(i)/a(i,i)

a(i,:)=a(i,:)/a(i,i)

a=a-matrice cu diagonala princ 1 si restul 0 de marimea lui a

x=b-ax0

cat timp maximul |x-x0|>prec

x0=x

x=b-ax0

GAUSS SeIDEL

/* Function for checking if a given matrix is

* dominant-diagonal.

* This function returns:

* ~> 0, for success;

* ~> 1, for failure.

*/

int DD ( int or_mat,

double MAT[][NrMax]

int i,j;

double sum;

for(i=1; i<=or_mat; i++)

sum = 0;

for(j=1; j<=or_mat; j++) sum += fabs(MAT[i][j]);


if ( 2*fabs(MAT[i][i]) <=sum ) return 1;

return 0;

/* Function that implements the iterative GAUSS-SEIDEL

* method for solving linear systems of equations.

* This function returns:

* ~> 0, for success;

* ~> 1, if we cannot solve the system because the

* input matrix hasn't a dominant-diagonal shape.

2 POINT DIFFERENCIATION

Variables

x0

der=(f(x0+h/2)-f(x0-h/2))/h

der

3 POINT DIFFERENCIATION

Variables

x0

h
h2

der = ((h1 la puterea 2)(f(x0+h2)) + (h2 la puterea 2 - h1 la puterea 2)f(x0) - (h2 la puterea 2)f(x0-
h1))/(h1h2(h1+h2))

der

5 POINT DIFFERENCIATION

Variables

x0

der = (f(x0-2h)-8f(x0-h)+8f(x0+h)-f(x0+2h))/(12h)

der
Rectangular METHOD
Variables
(
f
ls: left limit of the integration interval, real;
ld: right limit of the integration interval, real;
n: number of subintervals, integer;
)
{
sum=0;
h=(ld-ls)/n
for i=1 la n-1
{
sum=sum+hf(a+ih)
}
aria=sum
}
aria
THE TRAPEZ MEHOD
Variables
(
ls: left limit of the integration interval, real;
F: function for the area to be calculated
ld: right limit of the integration interval, real;
n: number of subintervals, integer;
h
{
compute h = (b-a)/n;
compute sum = (f(ls)+f(ld))*h/2 ;
for i=1 la n-1
{
compute sum = sum + h*f(ls+i*h);
}
}
[I,h]
RICHARDSON METHOD
Variables
f
ls:left limit of the integration interval, real;
ld: right limit of the integration interval, real;
m: number of subintervals, integer;
n: number of subintervals, integer;

)
{
apleam trapeze pentru Ih si h de f,ls,ld,m
apelam trapeze pentru Ik si k de f,ls,ld,n
I=Ih+(Ih-Ik)/(((k/h) la puterea 2)-1);
}
I
THE SIMPSONS METHOD
Variables
(
f
ls: left limit of the integration interval, real;
ld: right limit of the integration interval, real;
n: number of subintervals, integer;
)
{
h=(ld-ls)/n
I=(h/3)(f(a)+f(b))
for i de la 1 la n-1
{
daca i%2=0
{
I=I+(2h/3)f(a+ih)
altfel
I=I+(4h/3)f(a+ih)
}
}
I
INTERPOLATION 1
(
x: abscissa for the first known point, real; )
y: the ordinates for known points, array;
xp: abscissa of the interpolation point;
)
{
sum = y1
prod = 1
h=x(2)-x(1)
for i=1 la lungimea lui x
{ for j=1 la lungimea lui x -1
compute yj = yj+1 – yj
}
Prod = prod( xp – (x(1)+(i-1)h ))/(hi)
Sum =sum+y(1)prod
}
Yp = sum
}
Yp

INTERPOLATION 2
Arguments (
x
y: the known ordinates, array;
xp: the abscissa for the interpolation point;
{
n= lungimea lui x
sum = yn;
prod = 1;
for i = 1 to n
{ for j = n downto 2
compute yj = yj - yj-1
}
Prod = prod(xp – (x(length(x)) – (i-1)h))/(hi)
Sum = sum + yn prod
}yp =sum
}
Yp

LINEAR OPTIMIZATION

Y0 = y,x,x0
b<-(x*x’*sum of yi – sum of xi *x*y’)/(m*x*x ’- (sum of xi) ^2)
a<-(m*x*y’ – (sum of xi * sum of yi))/(m*x*x’ – m*(sum of xi) ^2)
y0=1/(a*x0+b)
HYPERBOLIC OPTIMIZATION
A<- (x*1/y’ – m* sum of xi/yi)/(sum of xi ^2 – m*x*x’) b
B<-(sum of 1/yi * x*x’ – sum of xi/yi * sum of xi)/(m*x*x’ – (sum of xi) ^2)
y0=a*x0+b

EXPONENTIAL OPTIMIZATION

a<- exp( sum of ln(yi) * x*x’ – sum of xi * sum( ln(xi) + ln(yi)))/(m*x*x’ – (sum of xi)^2)
b<-exp( sum of xi * sum of ln(yi)*(m-1))/m*x*x’ – (sum of xi)^2)
y0=a*(b^x0)

S-ar putea să vă placă și