0% found this document useful (0 votes)
21 views9 pages

SCILAB Numerical Methods Tutorial

The document provides tutorials on various numerical methods for solving transcendental and linear equations using SCILAB. It includes examples and programs for the Regula Falsi Method, Newton-Raphson Method, Jacobi Iterative Method, and Gauss-Seidel Iterative Method, detailing input, calculations, and outputs for each method. Each section concludes with the approximate roots or solutions obtained through the respective methods.

Uploaded by

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

SCILAB Numerical Methods Tutorial

The document provides tutorials on various numerical methods for solving transcendental and linear equations using SCILAB. It includes examples and programs for the Regula Falsi Method, Newton-Raphson Method, Jacobi Iterative Method, and Gauss-Seidel Iterative Method, detailing input, calculations, and outputs for each method. Each section concludes with the approximate roots or solutions obtained through the respective methods.

Uploaded by

yewepeb271
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SCILAB TUTORIALS

Name of student:
Division:
Roll no.:

Numerical Methods for Solving Transcendental and Linear Equations:

(1) Regula Falsi Method

4 3 2
Ex. Find approximate values of roots of equation 𝑥 + 𝑥 − 7𝑥 − 𝑥 + 5 = 0,
by Regula Falsi Method

Program
Input:
x=0:1:5; //randomly selected interval of integers
function f=f(x) // define function
f = x^4+x^3-7*x^2-x+5
endfunction
[x
f(x)] // get the values of f(x) for all values of x
a=2; // choose the value of x for which f(x)is maximum
negative
b=3; // choose the value of x for which f(x)is minimum
positive
// we get the interval (a, b) in which f(x) = 0 i. e. the
root of f(x) lies
n=4; // iteration level
for i=1:n
c=(a*f(b)-b*f(a)) / (f(b)-f(a)) //Regula Falsi Formula
disp([i,c])
if f(a)*f(c)<0 then
b=c
end
if f(b)*f(c)<0 then
a=c
end
c1=(a*f(b)-b*f(a))/(f(b)-f(a))
if abs(c1-c)<0.000001 then
disp("We get accurate roots")
break
end
end
Output:
1. 2.0208333

2. 2.034746

3. 2.0439135

4. 2.0499007

//Approximate Root = 2.0499007 after four iteration


SCILAB TUTORIALS

Name of student:
Division:
Roll no.:

(2) Newton-Raphson method.

Ex : Find a root of 3𝑥 − cos 𝑐𝑜𝑠 𝑥 − 1 = 0 by Newton-Raphson method.

Program:-

Input:

function [f, df]=fun7(x)


f=3*x-cos(x)-1;
df=3+sin(x);
endfunction
xold=5;
maxit=5;
iter=1;
while(1)
[fx,dfx]=fun7(xold);
xnew=xold-fx/dfx;
if iter==maxit then
break
end
xold=xnew;
iter=iter+1;
end
root=round(xnew*10^4)/10^4;
disp(root,"root=")

Output:

root=

0.6071
SCILAB TUTORIALS

Name of student:
Division:
Roll no.:

(3) Jacobi 'S Iterative Method

Ex. Solve
12x+2y+z=27 𝐴(1)𝑋 + 𝐴(4)𝑌 + 𝐴(7)𝑍 = 𝐵(1)
2x+15y-3z=16 ≅ 𝐴(2)𝑋 + 𝐴(5)𝑌 + 𝐴(8)𝑍 = 𝐵(2)
2x-3y+25z=26 𝐴(3)𝑋 + 𝐴(6)𝑌 + 𝐴(9)𝑍 = 𝐵(3)

Program:
Input:

A=[12 2 1;2 15 -3;2 -3 25]//coefficient matrix//


disp('[A]=')
disp(A)
B=[27 16 26]' // colum matrix of B(1),B(2),B(3)
disp('[B]=')
disp(B)
disp('[A B]=') // display augumented matrix
disp([A B])
n=6 //no. of iterations//
xold=0 //x_0=0
yold=0 //y_0=0
zold=0 //z_0=0
for i=0:n-1
x(i+1)=((B(1)-A(4)*yold-A(7)*zold))/A(1)
y(i+1)=((B(2)-A(2)*xold-A(8)*zold))/A(5)
z(i+1)= ((B(3)-A(3)*xold-A(6)*yold))/A(9)
xold=x(i+1) // revised value of x
yold=y(i+1) // revised value of y
zold=z(i+1) // revised value of z
end // end process
disp('x='); //display of x
disp(x)
disp('y='); //display of y
disp(y)
disp('z='); //display of z
disp(z)
Output:

[A]=

12. 2. 1.

2. 15. - 3.

2. - 3. 25.

[B]=

27.

16.

26.

[A B]=

12. 2. 1. 27.

2. 15. - 3. 16.

2. - 3. 25. 26.

x=

2.25

1.9855556

2.0052222

2.000236

2.0002184

2.0000334

y=

1.0666667

0.9746667

0.9995259

0.9989268

0.9998736

0.9999413
z=

1.04

0.988

0.9981156

0.9995253

0.9998523

0.9999674

[Note: for more accurate values of unknowns increase the number of


iterations]
SCILAB TUTORIALS

Name of student:
Division:
Roll no.:
(4) Gauss Seidel Iterative Method

Ex. Solve 20x+y-2z=17


3x+20y-z=-18
2x-3y+20z=25
Program:

Input:

A=[20 1 -2;3 20 -1; 2 -3 20]//coefficient matrix//


disp('[A]=')
disp(A)
B=[17 -18 25]'
disp('[B]=')
disp(B)
disp('[A B]=')
disp([A B])
n=5//no. of iterations//
xold=0
yold=0
zold=0
for i=0:n-1
x(i+1)=((B(1)-A(4)*yold-A(7)*zold))/A(1)
y(i+1)=((B(2)-A(2)*x(i+1)-A(8)*zold))/A(5)
z(i+1)= ((B(3)-A(3)*x(i+1)-A(6)*y(i+1)))/A(9)
xold=x(i+1)
yold=y(i+1)
zold=z(i+1)
end
disp('x=');
disp(x)
disp('y=');
disp(y)
disp('z=');
disp(z)
Output:

[A]=

20. 1. - 2.

3. 20. - 1.

2. - 3. 20.

[B]=

17.

- 18.

25.

[A B]=

20. 1. - 2. 17.

3. 20. - 1. - 18.

2. - 3. 20. 25.

x=

0.85

1.0024625

0.9999693

1.0000005

1.0000000

y=

- 1.0275

- 0.9998256

- 1.0000064

- 1.0000000

- 1.
z=

1.010875

0.9997799

1.0000021

1.0000000

1.

Common questions

Powered by AI

The Jacobi Iterative Method may fail to converge if the system matrix lacks diagonal dominance, meaning the absolute value of diagonal elements is not greater than the sum of the absolute values of other row elements. To improve convergence, the system can be rearranged or preconditioned to enhance diagonal dominance. Additionally, increasing the number of iterations or choosing a better initial guess can also help achieve convergence. In the discussed example, converting the matrix to a diagonally dominant form aided in observing the convergence through iterative updates to variable estimations .

The Gauss-Seidel method differs from Jacobi's in that it updates the variables during the iteration immediately after computation, rather than simultaneously at each step. This often leads to faster convergence for the Gauss-Seidel method as each update can influence subsequent calculations within the same iteration. The primary advantage of Gauss-Seidel is its typically faster convergence due to using updated information instantly, given that the matrix is suitable (e.g., diagonally dominant). However, Jacobi's method may be easier to implement in parallel computing environments since it independently computes next estimates before updating .

Initial guesses critically affect the performance and outcome of methods like Regula Falsi and Newton-Raphson. An unsuitable initial guess can lead to slow convergence, divergence, or finding different roots than intended. For the Regula Falsi, ensuring the initial interval brackets a root guarantees convergence. In Newton-Raphson, a guess near the root leads to faster convergence, but if it's far, it might not converge at all or could miss the root entirely. For example, starting points close to the root enable the Newton-Raphson method to converge quickly to the root 0.6071 .

The Newton-Raphson method uses a recursive formula to approximate the root of a function, starting from an initial guess. Each iteration refines the approximation by using the tangent of the function at the current point. The formula is x_new = x_old - f(x_old)/f'(x_old), which leverages the slope of the function to adjust the guess towards a root. This method is effective because it typically converges quickly, especially if the initial guess is close to the actual root. In the given example, the method found a root at approximately 0.6071 after five iterations .

Zero-finding problems can be complicated by issues such as method convergence rate, sensitivity to initial guesses, and the presence of multiple roots. Methods like Newton-Raphson may fail if starting points are poorly chosen or in cases with stagnation near inflection points. Regula Falsi can be slow if the function's behavior is not monotonic in the chosen interval. Strategies to mitigate these include hybrid approaches that combine methods or switch from one method to another based on convergence behavior, good initial approximation techniques, and adapting the process if stagnation is detected .

Iterative convergence criteria are conditions that determine when an iterative method should stop, ensuring the solution is sufficiently accurate. Common criteria include maximum iteration counts, a threshold for changes between successive iterations, or the residual's magnitude. In practice, the method should terminate if the change between iterations is below a preset threshold, indicating convergence to a stable value. For instance, the Regula Falsi Method checks if the difference between successive iterations is less than 0.000001, at which point it assumes the root is found with desirable accuracy .

Choosing an appropriate interval is crucial for the convergence of the Regula Falsi Method. The interval should be chosen such that one end has a negative function value and the other a positive function value, indicating that a root exists within. For example, in the equation x^4 + x^3 - 7x^2 - x + 5 = 0, the interval was selected between a=2 and b=3 because f(a) is negative and f(b) is positive . This ensures the method will shrink the interval and converge towards a root.

In cases of multiple or repeated roots, the standard Newton-Raphson approach can struggle because its convergence rate decreases significantly. It is less efficient as the derivative value approached zero, slowing adjustments. To tackle this, modifications such as introducing multiplicity adjustments where the iteration takes into account the number of times the root repeats can be applied. Methods like modified Newton or using derivatives that account for multiplicity can enhance convergence to repeated roots, particularly in complex functions or where roots closely interact .

One might choose the Jacobi method if parallel processing capabilities are a priority since the Jacobi method computes all new estimates without needing updates from each iteration step. This allows parallel computation and storage of results independently until all updates are applied simultaneously, making it ideal for distributed systems. Despite potentially slower convergence, its parallelizability is a significant advantage over Gauss-Seidel, particularly for large systems. Additionally, if the system matrix does not readily allow efficient single-pass updates, Jacobi's symmetrical update step can be beneficial .

The Gauss-Seidel method's main limitation is its dependency on the matrix's properties, such as requiring it to be diagonally dominant or convergent. If these conditions aren't met, the method may not converge or may converge very slowly. To address these, the system matrix can be reorganized to enhance diagonal dominance. Preconditioning techniques or transforming the system into an equivalent form that satisfies these conditions can also bolster convergence. Additionally, iterative relaxations or hybrid methods combining other convergence guaranted methods, can be employed .

You might also like