Numerical Analysis Lab Ece

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

ELECTRONICS AND COMMUNICATION ENGINEERING DISCIPLINE

LAB EVALUATION

PROBLEM # 01
Write a program using user defined function that takes input of x and n and evaluates the difference
between the expansion-derived result (say p) and library function generated result(say l) of exponential
series. The exponential series is like this one…

x2 x3 x4 xn
p = 1+ x + + + + .................+
2! 3! 4! n!
You are to calculate the difference between l and p.

PROBLEM # 02
Write a user defined function that evaluates geographical distance between two points (x1, y1) and (x2,

y2) ( x1 − x2 )2 + ( y1 − y 2 )2

You are to calculate the maximum distance for input of four couple of points.

PROBLEM # 03
Design a user defined function that takes input of a m x n matrix. Use the function to input two
matrices and output the summation of two matrices.

1 2 3 5 4 3 7 6 6
4 5 6 + 4 3 2 = 8 8 8
7 8 9 2 1 0 9 9 9

PROBLEM # 04
Design a recursive function that takes n as parameter and calculate the factorial of n. In the main
function, simply generate three random numbers and output factorial of those values.

PROBLEM # 05
Design a function that takes an integer n as parameter and generates the sum of Fibonacci series up to
nth term . The series is like this one-[First two numbers are 1 and 1]
1+ 1 + 2 + 3 + 5 + 8 + 13 + ………
PROBLEM # 06

Given that f(x) = 0.2 x + 25 x − 200 x 2 + 675 x 3 − 900 x 4 + 400 x 5 Also provided that, a = 0 and b =

0.8
For given input of a and b 0 ≤a ≤ 1 and 0 ≤ b ≤1 , What you are to do, is to calculate the
f(a) + f(b)
following: trapezoidal rule tr =(b −a)
2
Sample input: a = 0, b = 0.8,
Sample Output tr = 0.1728

PROBLEM # 07

Given that f(x) = 0.2 x + 25 x − 200 x 2 + 675 x 3 − 900 x 4 + 400 x 5 Also provided that, a = 0 and b =

0.8
For given input of a and b 0 ≤a ≤ 1 and 0 ≤ b ≤1 , What you are to do, is to calculate the
f(x 0 ) +4 f(x 1 ) + f(x 2 )
following: Simpson’s 1/3 Rule s13 =(b − a) Where x0 = a, x1 = (a+b)/2
6
and x2=b.
Sample input: a = 0, b = 0.8,
Sample Output s13 = 1.367467

PROBLEM # 08
667.38
Given that f(x) = (1 − e −0.146843 . x ) − 40
x
You will be given input of two floating point numbers (lower and upper) xl and xu . You have to use
bisection method to determine the root.
x + xu
Assume that, xr = l
2
Now, (a) if f(x l ) * f(x r ) <0 set xu = xr
(b) if f(x l ) * f(x r ) >0 set xl = xr
(c) if f(x l ) * f(x r ) =0 xr is the root.
Output xr if you get the result and if even after 7th iteration the result doesn’t come, terminate the
program.
PROBLEM # 09
Consider the following equations.
a11 x1 +a12 x2 + a13 x3 = b1
a 21 x1 +a 22 x2 + a 23 x3 = b2
a31 x1 +a32 x2 + a33 x3 = b3
You will be given input of the coefficients that is,
a11 , a12 , a13 , b1 , a21 , a 22 , a23 , b2 , a31 , a32 , a33 , b3 etc.
You are to Apply Gauss Seidel method to obtain the solution.
(b1 − a12 x2 − a13 x3 )
x1 =
a11
(b2 − a 21 x1 − a 23 x3 )
x2 =
a 22
(b3 − a31 x1 − a32 x2 )
x3 =
a33
For the first iteration, consider x2 = 0 ,and x3 = 0 and calculate x1
x1 = 0 ,and x3 = 0 and calculate x2 and x1 = 0 ,and x2 = 0 and calculate x3
For next iterations, use the evaluated values of x1 , x2 and x3 in necessary cases.
Repeat this process three times and determine whether it is converging or diverging using the error
evaluation strategy. Error= (present-previous) / (present)

PROBLEM # 10
False Position Method is a very simple method where you are given input of two initial values xl and xu
that is lower and upper. What you are to do is to calculate
f(x u )(x l − xu )
xr = xu −
f(x l ) − f(x u )
if, xl . xr > 0 then xl = xr ,
if, xl . x r < 0 then xu = xr ,
if, xl . xr = 0 then xr be the root.
You would evaluate the error [( ( new_root – previous_root ) / ( new_root) ) * 100 ] up to seventh
iteration for necessary cases. Output errors for all corresponding cases.

You might also like