The tangent function takes the parameter theta and returns the value of opposite divided by adjacent. The arctangent function takes the ratio of opposite over adjacent and returns the angle theta.
Here is a power series for calculating the arctangent:
NOTE: For this power series, it is required that
Notice the difference between this power series and the power series for the sine function.
Try writing a function called arctangent that uses the power series shown to calculate the arctangent. Name this function arctangent1(). Try using it to calculate the arctangent of 1. What happens?
In looking at the cosine function, we saw that we could get pretty close to the cosine of 1 with just four terms. Write a function that calculates the sum of the first four terms in the power series for arctangent with an input parameter of 1. How close is it to the value you get when you import the math module and run math.atan(1)?
Try summing 100 terms. Try the first 1000 terms. Are the sums getting closer to the true value of the arctangent of 1? Why is this function behaving differently than the sine or cosine functions you wrote?
1 2 3 4 5 6 7 8 9 10 11 12