Write program which will solve any set of n linear equations

Assignment Help MATLAB Programming
Reference no: EM131906537

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

Reference no: EM131906537

Questions Cloud

What circumstances should be present before removing a child : What circumstances should be present (or what considerations should be made) before removing a child from the guardianship of the parent?
What is the annual dividend on txs preferred stock : What is the annual dividend on TXS preferred stock?
Calculate the npv and irr of the project : The DoD just asked for a request for proposal (RFP) to deliver 10 armored vehicles over the course of 5 years. Calculate the NPV and IRR of the project.
What was your total real return on investment : If the inflation rate was 3.7 percent over the past year, what was your total real return on investment?
Write program which will solve any set of n linear equations : ENG2113 Numerical Methods Assignment. Write a program in Matlab which will solve any set of n linear equations in n unknowns
Identify ways that medicaid discounting can cause hardships : Identify ways that Medicaid discounting can cause hardships on the type of facility that you selected.
What specific features and benefits your product provides : What specific features and benefits your product or service provides to the intended target market. A description of the aesthetics, packaging, labeling.
Compute percentage total return : Suppose a stock had an initial price of $59 per share, Compute the percentage total return. What rate per year are you being offered?
Percent composition of the air mixture in the scuba tank : what is the percent composition of the air mixture in the scuba tank

Reviews

len1906537

3/19/2018 5:04:28 AM

Submission date/time: 4 p.m. Tuesday day 20 (week 7). Submission requirements: You will need to submit your coursework electronically on SurreyLearn. Your submissions should include, a) a copy of the third page of this assignment, completed as indicated (a separate word document is available on SurreyLearn) then in logical order i.e. by question and question part b) any ‘theory’ and/or hand calculation’ answers (and any discussion associated with these) c) the Matlab codes that you used to get your answers (copy-paste the Matlab code from the Matlab Editor; Please do NOT use screen shots – these are usually too small to read with comfort!). The same Matlab code must also be submitted as a separate m-file (or separate m-files in case you’re using user defined functions). Double-, triple-, quadruple-check that the code in the coursework documents matches the code you submit as m-file. If there are differences, the submitted m-file will take priority over the code in the word/pdf file.

len1906537

3/19/2018 5:04:22 AM

For the above requirement it is extremely important that you test your code with a clear workspace (for example, using clear all; close all commands in the first line of your matlab codes, as I have demonstrated through all my examples). If some of your code relies on variables and values that are in your workspace but are not defined within your script, your m-file won’t run successfully in my computer. Submit your coursework paper by uploading it (as either a word, openoffice or pdf document), along with all the associated Matlab files, in your “Numerical Methods Coursework” assignment folder on SurreyLearn. The set up for the two problems require the use of digits from your URN. You can find more information in the following pages. Do check that your numerical values are correct before submission!

len1906537

3/19/2018 5:04:17 AM

On each of the programming elements of the questions, marks will be awarded for: a) a basic functioning program that satisfies the minimum requirements and produces correct answers, with output of the key final results (60% of each program element); b) good program layout and well-commented programs (i.e. sufficient comments to guide the user but not excessive and cluttering) so that the ‘reader’ can identify variables, and understand the processes. (20% of each program element) c) Advanced programming: Sensible output displays to show more features of the results (e.g. intermediate results, errors etc), sensible use of function subprograms called by a main program, use of input of variables (and even math function definitions) from the keyboard, sensible error traps (e,g. to avoid division by 0) and other more sophisticated programming to improve the ‘basic’ program level (20%).

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd