CMPSC/MATH 451 Homework Assignment #1 Solution
We can evaluate ln2 by
• using the Maclaurin series expansion (i.e., neighborhood of x = 0) of ln(1 + x) and setting the step size to 1, or
• using the Maclaurin series expansion of ln( ), and setting the step size to .
Give the Maclaurin series expansions of both these formulas. You will find a pattern emerging once evaluate the first 2-3 terms.
Which approximation would you use? Why?
Write an Octave program to approximate ln2 using the first six terms of the series expansion of each formula. List your code in the submission. You do not need to write a general function that takes the number of terms as an argument. Instead, just use the first six terms in each formula as they appear. What is the relative error in each case, considering the Octave-generated value of ln2 as the true value.
Chapter 1, problem 4 (page 15) from the text book.
Chapter 2, problem 4 (pages 32 and 33) from the text book.
Chapter 2, problem 5 (page 33) from the text book.
Write a program to compute the mathematical constant e, the base of natural logarithms, from the
for n = 10k, k = 1,2,3,...,20. Determine the error in your successive approximations by comparing them with the value of exp(1). Does the error always decrease as n increases? Explain your results, plotting the absolute and relative error.
You'll get 1 file (672.4KB)