Paper Code: MATH703

Numerical Analysis

Assignment Task1

Due: 4:00 pm, Thursday 7 May 2020

Name ........................................

ID number..........................

Question 1 2 3 4 Total

Fullmark 25 25 25 25 100

Mark

Instructions:

Please attach this sheet to the front of your assignment.

The assignment needs to be submitted online via Blackboard before the due date.

Answer all questions and show your working. No working = no marks.

This is an individual assignment. The point of this assignment is for you to go through the process of

discovery for yourself. Copying someone else’s work will not achieve this. Plagiarism has occurred where a

person effectively and without acknowledgement presents as their own work the work of others. That may

include published material, such as books, newspapers, lecture notes or handouts, material from the internet

or other students’ written work. It also includes computer output.

The Department of Mathematical Sciences regards any act of cheating including plagiarism, unauthorised

collaboration and theft of another student’s work most seriously. Any such act will result in a mark of zero

being given for this part of the assessment and may lead to disciplinary action.

Please sign to signify that you understand what this means, and that the assignment is your own work.

Signature: ........................................

1. Matlab Fundamentals

(a) [6 points] Use the linspace function to create vectors identical to the following created with colon

notation:

(i) t = 2:5:32

(ii) x = -2:8

(b) [6 points] Use the colon notation to create vectors identical to

(i) v = linspace(-0.5,1.5,5)

(ii) r = linspace(10,5.5,10)

(c) [6 points] The following matrix is entered in Matlab

>> A=[3 2 1;2:0.5:3;linspace(10, 8, 3)]

Write out the resulting matrix. Then, use colon notation to write a single-line MATLAB command

to multiply the first row by the third column and assign the result to the variable C.

(d) [7 points] The standard normal probability density function is given by f(z) = 1

Use Matlab to generate a plot of this function from z = ?5 to z = 5. Label the horizontal axis

as z and the vertical axis as frequency.

2. Programming with Matlab

(a) [10 points] The sine function can be evaluated by the following infinite series:

Create an M-file to implement this formula so that it computes and displays the values of sin x as

each term in the series is added. In other words, compute and display in sequence the values for.

up to the order term of your choosing. For each of the preceding, compute and display the percent

relative error as

% error =

true - series approximation

true

× 100%

As a test case, employ the program to compute sin(0.9) for up to and including eight terms, that

is, up to the term x

15/15!. Display the approximation of sin(0.9) and the percent relative error.

(b) [15 points] Two distances are required to specify the location of a point relative to an origin in

two-dimensional space (see figure):

? The horizontal and vertical distances (x, y) in Cartesian coordinates.

? The radius and angle (r, θ) in polar coordinates

It is relatively straightforward to compute Cartesian coordinates (x, y) on the basis of polar

coordinates (r, θ). The reverse process is not so simple. The radius can be computed by the

following formula

If the coordinates lie within the first and fourth coordinates (i.e., x > 0), then a simple formula

can be used to compute

The difficulty arises for the other cases. The following table summarizes the possibilities:

Write a well-structured M-file using if...elseif structures to calculate r and θ as a function of x

and y. Express the coordinates for θ in degrees. Test your program by evaluating the following

cases and finding the values of r and θ:

3. Root finding

(a) [15 points] Use fixed-point iteration to locate the root of

f(x) = cos (√x) ? x

Use an initial guess of x0 = 0.5 and iterate until εa ≤ 0.01%. Display graphically the approximate

solutions and relative errors in each iteration steps.

(b) [10 points] Use the Newton-Raphson method to determine a root of

f(x) = ?0.9x

2 + 1.6x + 2.6

using x0 = 5. Perform the computation until εa is less than 0.01%.

4. Linear systems

Consider the sixth-degree polynomial y = a0 + a1x + a2x

2 + a3x

3 + a4x

4 + a5x

5 + a6x

6

that passes

through the points (0, 1),(1, 3),(2, 2),(3, 1),(4, 3),(5, 2) and (6, 1).

(a) [10 points] Find a0. Then, set up the system of six equations to find the polynomial coefficients

of a1, a2, ...a6.

(b) [15 points] Wrie a M-file function to solve the system of equations, based on Gauss Elimination

method with pivoting strategy. Use the plot command to display the polynomial and the given

points on the same graph.

2

版权所有：留学生编程辅导网 2018 All Rights Reserved 联系方式：QQ:99515681 电子信箱：99515681@qq.com

免责声明：本站部分内容从网络整理而来，只供参考！如有版权问题可联系本站删除。