Assignment 1 Outline

# Compute and print t the time spent in the cannon from

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: or a calculator) comes up with a value for such a function, correct to many decimal places? In this question you will evaluate the arctan function from the previous question again using a power series computation. You will use the same computation to estimate π. Then you will use Machin’s formula to evaluate π to more decimal places than the computer can easily represent as a decimal fraction. Theory The following infinite series evaluates the inverse tangent or arctan(x) function for any tangent value x between - 1 and 1 inclusive. The series diverges (goes to infinity) for any x with a larger magnitude, although tan(θ) can be any value between - ∞ and ∞. (1) arctan( ) = + + ... Since tan(π/4) = 1 (that is, for a 45° angle) we have arctan( ) = (2) = = + + + + ... ... This equation is mathematically correct, but it is not computationally practical as a way of generating π. It requires thousands or millions of operations to get just a few decimal places of accuracy. An 18th century English mathematician, John Machin, found a way of speeding up this calculation (http://en.wikipedia.org/wiki/John_Machin): = arctan arctan (3) = arctan arctan Both arctan functions in this formula have series that converge quickly because powers of x get very small very quickly in Equation (1) above. Nevertheless we cannot get more than 16 digits of π using this formula using floats in Python because floats have limited precision. Integers in Python, however, have unlimited precision. If the evaluation of the series could be done with only integer operations, we could get as many digits of π as we wanted. Suppose we wanted 50 COMP 1012 Winter 2014...
View Full Document

Ask a homework question - tutors are online