0% found this document useful (0 votes)
51 views1 page

(M-Files) To The Course Assistant.:) LN (4 / Log Cos) 3 2 / (6 3 1 - 0 2 / 6) 1 (1 1

1. Summarize the key details of Homework 1 for the Numerical Methods course, which is due on November 4th. Students should show results to double precision and can omit introduction and discussion sections. Programs for questions 2-4 should be emailed to the TA. 2. Question 2 involves computing values of z using arrays x=[1 2 3] and y=[3 4 5] in various ways, and should yield the answer z=[1.939199229068378 2.333117895415630 5.581219543558071]. 3. Question 3 involves plotting the natural log function and its Taylor polynomials from 0.1 to 8.1, marking points
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

(M-Files) To The Course Assistant.:) LN (4 / Log Cos) 3 2 / (6 3 1 - 0 2 / 6) 1 (1 1

1. Summarize the key details of Homework 1 for the Numerical Methods course, which is due on November 4th. Students should show results to double precision and can omit introduction and discussion sections. Programs for questions 2-4 should be emailed to the TA. 2. Question 2 involves computing values of z using arrays x=[1 2 3] and y=[3 4 5] in various ways, and should yield the answer z=[1.939199229068378 2.333117895415630 5.581219543558071]. 3. Question 3 involves plotting the natural log function and its Taylor polynomials from 0.1 to 8.1, marking points
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MMÜ 602 - NUMERICAL METHODS - FALL 2019 - HOMEWORK 1

Due: 4 November 2019, Monday


*Display your results in double-precision.
*For this homework only, you can omit the Introduction and Discussion sections in your report.
*Print-out your homework reports. For the 2nd , 3rd and 4th questions only, e-mail your Matlab programs
(m-files) to the course assistant.
1) Type the following commands in the same order as given below. Explain very shortly the results by
describing the functions of the given commands and operators. The commas separate the commands only.
C=[4 6 6; 2 1 8; 4 4 3], C^2, disp(C*C), C.^2, C/2, C./2, 1/C, 1./C,
C(:, [3 1]), C(end,:), C(1:3, [2 3])=9, C([1 3], :)=[ ]
B=[1 3 5;2 4 6;1 7 9], D=[4 6 6; 2 1 8; 4 4 3], B*D, B.*D, B./D, 2.^B
a=[2 4 6], d=[1 3 5]', 5-a, d^3, d.^3, a+d, a.*d, (a.*d')', a./d, a'./d, F=[B D; a d']

2) For this question, reviewing operator precedence rules is helpful. Consider the expression given below.
y i /5 ( x  1) / y
1 e 3 i
zi 
3
 6 / 2  0. 1 
6 /(2  3)
i
 cos 2  3
  2

x i y i  log 2 x i / 4  ln( xi  y i )
1  (1  yi ) 2 / 3

The independent variables x and y are arrays (or vectors) given as x  1 2 3 and y  3 4 5 . Note that
in Matlab, ln ( ) is given by log(x).
Compute the values of z using the following methods described in parts (a), (b), (c) and (d).
a) Apply for loop.
b) Define z in a single line using array multiplication and division operations of Matlab.
c) Use the inline command or use function handles with the operator @.
d) Write a function m-file which accepts x and y as input arguments and returns z as the output argument.
Note: You must find the same answer for parts (a), (b), (c) and (d). The correct answer is:
z=
1.939199229068378 2.333117895415630 5.581219543558071

3) Consider the function ( ) = ln ( ).


→ For ∈ [0.1, 8.1], plot ( ) and the Taylor polynomials ( ), ( ), ( ), ( ) of about the base
point = = 1.2 . Plot these five functions in the same figure. Use an increment (i.e. step size) of 0.01 to
plot these functions. Draw ( ) using black solid line; draw ( ) using red solid line; draw ( ) using
green dash-dot line; draw ( ) using blue dashed line; draw ( ) using magenta dotted line. (Typing the
keyword “linespec” in Matlab help would be useful to you). The limits for the axes of the figure must be
= 0, = 10, = −3, = 3 . Label the x and y axes, and put the title Homework 1 -
Question 3 on the figure. Use the command axis equal for your figure in your program.

→ For = 2, approximate ( ) using Taylor polynomials of order 0 to 3. Then, find the corresponding
true percent relative error for each case. In your figure, mark the base point ( , ( )) with a red circle and
mark the true-value point ( , ) with a black circle.

4) Write a program to determine the number of terms required to approximate sin ( /4) to 7 significant
digits using the infinite series given below. Hence, the program should terminate automatically when the
criterion = (0.5 × 10 )% is met (i.e. when | | < ). Display your results in tabulated form in which
the 1st column shows the number of terms used in the series, the 2nd column lists the corresponding
approximation for sin ( /4), the 3rd column shows the true value of sin ( /4), and the 4th and the 5th
columns indicate the corresponding values of | | and | | respectively. In your program, you can use the
built-in Matlab function factorial.
(−1)
sin( ) =
(2 + 1)!

You might also like