Eng2113 numerical methods assignment write a program in


Numerical Methods Assignment

Answer ALL QUESTIONS.

Question 1 - Consider the polynomial f(x) = x5 - 16.5x4 + 102.85x3 - 299.475x2 + 401.1634x - 193.5612 - 0.a, where a is the digit taken from your URN (so if your a is 1, the constant term in your polynomial would be -193.5612 - 0.1 = -193.6612)

i) Using the graphical method with Matlab to estimate the subinterval(s) in which the roots of f(x) lie over the initial interval -10 + b ≤ x ≤ 10 where b is the digit taken from your URN. You need to include the matlab script and the graph you plotted with the matlab script in your submission.

ii) By hand/using calculator, starting at x = -1 and continuing up to x = 9 carry out an interval searching procedure with intervals of 1 to establish in which subintervals the roots of the polynomial lie. Tabulate your results and explain the basis of the method.

iii) Use the bisection method and a calculator to find the smallest root from the subintervals you identified in (ii), working to 4 decimal places at every stage of the calculation and performing no more than 5 iterations of the method. Present your results in the tabulated form.

iv) Explain the basis of the Newton-Raphson method, using a sketch if helpful, and indicate what the formulae and process would be for the function above.

v) Write a Matlab program (a script .m file, NOT a function .m file) to use the following Newton-Raphson algorithm to calculate a root estimate for f(x) above, with initial guess x1 taking the 2 different values with x1 = 3.9 + 0.0b and x1 = 3.8 - 0.0b where the . is a decimal point and the is the digit from your URN. (Name your matlab program using "yoursurname_nr.m", e.g. wu_nr.m)

2327_figure.png

1) Iterate until the approximate relative percentage error in your estimate(s) is less than 10-6, and the maximum iteration is no more than 106.

2) You should probably test your programme on a simple example with known roots first.

3) A very basic program might set the start value and various other parameters, and define the function and its derivative, within the program.

4) A more sophisticated program will allow user input from the keyboard, and would seek to 'trap' division by zero with consequent output of a message before program termination.

5) Your final output should include final root estimate, the final approximate percentage error in each case and the number of iterations taken, in each case, with suitable annotation.

6) What intermediate results you output in the final version of the code are up to you, but whereas while testing the code, it might be useful to see the results of all calculations, once you know it is working properly, you should output only those calculated vales that you really think are necessary.

7) As always your program should be adequately, but not excessively, commented to guide the user.

vi) Perform a critical analysis of the four methods for finding the roots of equations: 1) the graphical method; 2) the bisection method; 3) the simple (one-point) iteration method, and 4) the Newton Raphson method. i.e. the strength and limitation of these methods. You can use graphs or example to enhance your explanation/discussion.

Question 2 - Consider the set of linear equations

12x1 - 3x2 + 5x3 - x4 = 37

-2x1 + x2 - x3 + 11x4 = -51

4x1 - 10x2 + x3 - x4 = 31

4x1 + 6x2 - 12x3 + x4 = -48

i) Write a program in Matlab which will solve any set of n linear equations in n unknowns, of the form AX = B in matrix notation, by the Gauss Seidel method, provided the matrix A is diagonally dominant. Your program should

1) Use a coefficient matrix A and a right hand matrix B and these should be requested by the program as input.

2) Ideally determine the number of equations from the size of the matrix/matrices input

3) Ideally request the user to input starting guesses for the variables x1, . . . . . , xn in a matrix X.

4) Iterate until the approximate percentage error in each of the n variables is less than Es% but also do no more than a maximum number of iterations to prevent inadvertent infinite looping; Es and nmax ideally should be input from the keyboard on request.

5) As usual be suitably (but not excessively) commented to guide the user.

6) Output the final results for all the variables and all the approximate relative % errors , with suitable annotations, and also the number of iterations taken.

7) Name your matlab program as "yoursurname_gs.m", e.g. wu_gs.m

ii) Use your program to solve the above set of equations if and when they are in a form where Gauss-Seidel is guaranteed to converge. Use starting guesses of x1 = -(100 + a), x2 = 100 + b, x3 = -100, x4 = 100 where, as before, the a, b are the relevant digits from your URN.

iii) Repeat the calculation with starting guess of x1 = x2 = x3 = x4 = 0 and also with x1 = 100, x2 = -100, x3 = 100, x4 = -100 and comment on the apparent sensitivity or otherwise of the results to the starting guesses.

iv) Discuss the strength and limitation of 1) naïve Gauss elimination; 2) Gauss elimination with partial pivoting, 3) Jacobi iteration and 4) Gauss-Seidel method in solving the set of linear equations, in terms of error and convergence.


Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Eng2113 numerical methods assignment write a program in
Reference No:- TGS02702023

Expected delivery within 24 Hours