Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
161 views

COMSATS University, Islamabad: Islamabad Campus Department of Computer Science

This document contains an assignment on numerical computing techniques with 9 questions. It introduces concepts like error analysis, root finding algorithms, and solving non-linear equations. Students are asked to write programs to apply methods like bisection, Regula Falsi, Newton-Raphson, and Secant to find roots within given intervals and tolerances. They must also analyze new hybrid root finding algorithms that blend existing techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

COMSATS University, Islamabad: Islamabad Campus Department of Computer Science

This document contains an assignment on numerical computing techniques with 9 questions. It introduces concepts like error analysis, root finding algorithms, and solving non-linear equations. Students are asked to write programs to apply methods like bisection, Regula Falsi, Newton-Raphson, and Secant to find roots within given intervals and tolerances. They must also analyze new hybrid root finding algorithms that blend existing techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

COMSATS University, Islamabad

Islamabad Campus
Department of Computer Science

Read before Attempt


Assignment No. 1
Course code and Title: CSC475: Numerical Computing
Instructor: Tanveer Ahmed
Assigned Date: March 9, 2021 Due Date: March 18,2021
Total Marks: -- CLO-1, CLO-2:
Instructions:
1. This is an individual assignment. You will submit your work individually.
2. Try to get the concepts, consolidate your concepts and ideas from these questions
3. You should concern recommended books for clarify your concepts as handouts are not
sufficient.
4. Try to make solution by yourself and protect your work from other
students. If I found the solution files of some students are same, then I will
reward zero marks to all those students.
5. Deadline for this assignment is March 18, 2021. This deadline will not be extended.

Unit 01:
Topic: Error
CLO – 1 ( Questions 1-3)
Question # 1
The following infinite series converges on a value of f (n) = π4/90 as n approaches infinity.

Write a program in single precision to calculate f (n) for n = 10,000 by computing the sum from i = 1 to
10,000. Then repeat the calculation but in reverse order—that is, from i = 10,000 to 1 using increments of −1.
In each case, compute the true percent relative error. Explain the results.
Question # 2
a) Determine the number of terms necessary to approximate cos x

to 8 significant figures using the Maclaurin series approximation


b) Calculate the approximation using a value of x = 0.3π.
c) Write a program to determine your result.
Question # 3

SP21 Page 1
Evaluate e−5 using two approaches

and

and compare with the true value of 6.737947 × 10−3. Use 20 terms to evaluate each series and compute true
and approximate relative errors as terms are added.
Unit 02:
Topic: Solution of Non- Linear Equations
CLO – 2 ( Questions 4-9)
Question # 4
Determine the root of f (x) = x – 2e-x by:
a) Using the Bisection method. Start with a = 0 and b = 1 and carry out the first four iterations.
b) Using the Regula Falsi method. Start with a = 0 and b = 1 and carry out the first four iterations.
c) Using Newton's method. Start at x1 = 1 and carry out the first four iterations.
d) Using the Secant method. Start with the two points, x1 = 0 and x2 = 1, and carry out the first four
iterations.
e) Evaluate your results by plotting graph. Which method gives better solution and why?
Question # 5
The equation x3 -x -ex - 2 = 0 has a root between x = 2 and x = 3.
(a) Write four different iteration functions for solving the equation using the fixed-point iteration method.
(b) Determine which g(x) from part (a) could be used according to the condition in following Eq.
|g'(x)| < 1
(c) Carry out the first five iterations using the g(x) determined in part (b), starting with x = 2.
Question # 6
A new method for solving a nonlinear equation f(x) = 0 is proposed. The method is similar to the bisection
method. The solution starts by finding an interval [a, b] that brackets the solution. The first estimate of the
solution is the midpoint between x = a and x = b. Then the interval [a, b] is divided into four equal sections.
The section that contains the root is taken as the new interval for the next iteration.
Write a user-defined function(program) that solves a nonlinear equation with the proposed new method. Name
the function Xs = QuadSecRoot(Fun, a, b), where the output argument Xs is the solution. The input argument
Fun is a name for the function that calculates f(x) for a given x (it is a dummy name for the function that is
imported into QuadSecRoot), a and bare two points that bracket the root.
The iterations should stop when the tolerance, is smaller than 10-6 xNs (xNs is the current estimate of the
solution).
Use the user-defined QuadSecRoot function to solve the equation sinx -5x +2 = 0
Question # 7
Bisection algorithm and Newton-Raphson algorithm are discussed in class. Mr. Tanveer design a new
algorithm to compute the roots of nonlinear equations f(x)=0 by combining Bisection algorithm and Newton-
Raphson algorithm. Here is the Pseudocode:
Given f , f’, a , b , and δ=10-6 (tolerance)
Step 1 : for i=1 to 2
Step 2 : xi = (a+b) / 2
Step 3 : if f (xi ) = 0 or f (xi ) < δ , then step 10
Step 4 : if f (a) * f (xi) < 0 , then b= xi

SP21 Page 2
Step 5 : else a = xi
Step 6 : end for
Step 7 : x = xi - [ f ( xi ) / f’(xi) ]
Step 8 : if f (x) < δ , then go to step 10
Step 9 : xi = x , and go to step 7
Step 10 : stop iteration .
Find the real root of quartic function f(x) = x4 +3x3 – 15x2 -2x + 9 with tolerance ε =10-6 using
a) Bisection Method
b) Newton Raphson Methods
c) Hybrid Algorithm
d) Compute the approximate percent relative errors for your solutions in part a, b, and c.
e) Use the graphical method to explain your results.
Intervals are:
Interval = [-6, -4] , Interval=[-2,0], Interval =[0,2] , Interval =[2,4]
Question # 8
A new method for solving a nonlinear equation f(x) = 0 is proposed. The method is a combination of the
bisection and the regula falsi methods. The solution starts by defining an interval [a, b] that brackets the
solution. Then estimated numerical solutions are determined once with the bisection method and once with the
regula falsi method. (The first iteration uses the bisection method.) Write a user-defined function(program)
that solves a nonlinear equation f(x) = 0 with this new method. Name the function Xs = BiRegRoot(Fun, a, b,
ErrMax), where the output argument Xs is the solution. The input argument Fun is a name for the function
that calculates f(x) for a given x (it is a dummy name for the function that is imported into BiRegRoot), a and
b are two points that bracket the root, and ErrMax is the maximum error according to Eq. (3.9).
The program should include the following features:
• Check if points a and b are on opposite sides of the solution. If not, the program should stop and display an error
message.
• The number of iterations should be limited to 100 (to avoid an infinite loop). If a solution with the required
accuracy is not obtained in 100 iterations, the program should stop and display an error message.
Use the function RegulaRoot to solve the equation in Problem 3.3 (use a = 0.1, b = 1.4). For ErrMax use
0.00001.
Question # 9
Mr. Tanveer design a new algorithm that is a dynamic blend of the bisection and Regula Falsi algorithms.

SP21 Page 3
SP21 Page 4
Find the real root of f(x) = x2 - x - 2 [1, 4] with Error Tolerance = 0.0000100 using
a) Bisection Method
b) False Position Method
c) Newton Raphson Method
d) Secant Method
e) Blended Bisection and False Position
Discuss your results

SP21 Page 5

You might also like