You are on page 1of 2

MATLAB Programming for Numerical Computations

JanMarch 2017

Assignment for Module2


Due on: Wednesday, 8th Feb 2017
INSTRUCTIONS

Submit your work on the course website (https://onlinecourses.nptel.ac.in/noc17_ge02/)

Please follow all the instructions carefully and submit before the deadline

Please use MATLAB templates provided for Problem 2

You do not need to upload your MATLAB files.

1. SMALLEST ERROR FOR DIFFERENTIATION


Use the three-point forward difference formula for finding " for tan'( at = 1
" =

+ 2 + 4 + 3
2

For value of = 1, perform the above for various different values of the step-size
= 10'2

10'3

10'(5 . For each h, compare with the true value " = 1 + 2

'(

to compute error, err, as absolute difference between the true and approximate values.
1, 2.

Report value of h at which error is minimum. Also report this minimum err value

2. MACLAURIN SERIES FOR HYPERBOLIC FUNCTIONS


Download the file maclaurinCosh.m and use it as a template for this problem.
In this problem, you will use MacLaurin Series until the n-th order terms to compute
approximations of cosh (hyperbolic cosine) function, given by:
2 ;
cosh = 1 + + +
2! 4!
In the template file, you will find vector:
vec = 1

2
2!

3
3!

;
4!

>
!

pre-computed for you. Please use the vector vec to compute approximate values of cosh .
Your function should return coshVal, while taking the values of x and n as inputs. Report the
following results:
3.

Results on running: coshVal = maclaurinCosh(1.5,4)

4.

Results on running: coshVal = maclaurinCosh(3,9)

MATLAB Programming for Numerical Computations

JanMarch 2017

3. A NON-CONVERGENT INFINITE SERIES


All the examples in the course videos have been about convergent series. In this example,
you will code a series that does not converge:
1 1
1
= 1 + + + +
2 3

Write a MATLAB code that takes in the value n and computes the above series sum S.
Please report the value S for various cases, n = 500, 1000, 5000 and 10000.
58.

Report the values of S for different values of n: 500, 1000, 5000 and 10000.

4. MULTI-STAGE TAYLORS SERIES FOR LOG


We used infinite Taylors series in Problem 2 to compute cosh(x). In this problem, we
will instead adopt a multi-stage strategy to calculate ln 1 + . Starting with ln 1 = 0, we
will take n steps to calculate ln 1 + . Use step-size h = 0.1.
We will use the property of single-step Taylors series1 for this purpose. Let us represent
( = ln 1 , 2 = ln 1 + , 3 = ln 1 + 2 , , >D( = ln 1 +
At each stage, the next value is:
ED( = E +

1+ 1

Starting with ( = 0, we will compute 2 ; we will use 2 to compute 3 and so on


For example,

2 = ( + ,
1

3 = 2 +

,
1+

This is repeated multiple times until we reach ln 1.5 = ln 1 + 5 and ln 5 =


ln 1 + 40 . Use the above procedure to compute ln 1.5 and ln 5 by taking = 5 and =
40 steps respectively:

9.

Report the approximate value of ln(1.5) computed in 5 stages, using = 0.1

10.

Report the approximate value of ln(5) computed in 40 stages, using = 0.1

For those who are curious about the derivation,


ln 1 + + ln 1 + +

ED( E +
= E +
1+
1+
1+ 1

You might also like