Maclaurin Expansion of Tan and Arc-Tangent Functions: Computation and Comparison - Prof. E, Assignments of Engineering

The solution to problem 2 of homework set 4 in a college-level calculus course. It explains how to compute the derivatives of the tangent function using the maclaurin series and compares it with the arc-tangent function. The document also includes sample diaries from running the matlab code for both methods.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-nuk
koofers-user-nuk 🇺🇸

9 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AOE/ESM 2074
H.W. Set 4 - Solution
2. This problem is hard because it is not easy to see any obvious pattern in the values of
the various derivatives of tan(x) evaluated at x= 0. As noted in class, we have that
f(x)=tan(x), so that f(0) = 0. Additionally, f(x)=sec
2(x), so that f(0) = 1. For
the second derivative we get f(x)=2tan(x)sec
2(x)=2f(x)f(x). Note that we can
express the second derivative in terms of the function and its first derivative and that
f(0) = 0. It follows that we can express the nth derivative in terms of the first n1
derivatives, and that all the even derivatives will be zero. The first five (non-zero)
terms in the Maclaurin expansion are
tan(x)=x+x3
3+2x5
15 +17x7
315 +62x9
2835 +...
We can use this procedure to compute (with some effort and pain) all the derivatives to
some order. For example, using the expression above the first five non-zero coefficients
in the power series are
c=[1 1
3
2
15
17
315
62
2835]
These can be used to compute the partial sum through the fifth non-zero term. With
additional work we can extend this to more terms. A Matlab code that uses this
approach is available as hw 42a.m.
We should be aware that power series typically have a finite radius of convergence -
this means there is a finite value rsuch that the sequence of partial sums converges iff
|x|<r. For the tangent the radius of convergence is |x|/4.
Here is a sample diary from running this code:
hw_4_2a
Supply an argument (| x |<= pi/4) for the tan function : .2
Supply a tolerance (positive): .0001
After 4 terms the Maclaurin sum is 0.202709 .
The relative error is : 3.46393970e-06
diary off
1
pf3
pf4
pf5

Partial preview of the text

Download Maclaurin Expansion of Tan and Arc-Tangent Functions: Computation and Comparison - Prof. E and more Assignments Engineering in PDF only on Docsity!

AOE/ESM 2074

H.W. Set 4 - Solution

  1. This problem is hard because it is not easy to see any obvious pattern in the values of the various derivatives of tan(x) evaluated at x = 0. As noted in class, we have that f (x) = tan(x), so that f (0) = 0. Additionally, f ′(x) = sec^2 (x), so that f ′(0) = 1. For the second derivative we get f ′′(x) = 2 tan(x) sec^2 (x) = 2f (x)f ′(x). Note that we can express the second derivative in terms of the function and its first derivative and that f ′′(0) = 0. It follows that we can express the nth^ derivative in terms of the first n − 1 derivatives, and that all the even derivatives will be zero. The first five (non-zero) terms in the Maclaurin expansion are

tan(x) = x +

x^3 3

2 x^5 15

17 x^7 315

62 x^9 2835

We can use this procedure to compute (with some effort and pain) all the derivatives to some order. For example, usingthe expression above the first five non-zero coefficients in the power series are

c = [

]

These can be used to compute the partial sum through the fifth non-zero term. With additional work we can extend this to more terms. A Matlab code that uses this approach is available as hw 4 2a.m. We should be aware that power series typically have a finite radius of convergence - this means there is a finite value r such that the sequence of partial sums converges iff |x| < r. For the tangent the radius of convergence is |x| < π/4. Here is a sample diary from runningthis code:

hw_4_2a Supply an argument (| x |<= pi/4) for the tan function :. Supply a tolerance (positive):. After 4 termsthe Maclaurin sum is0.. The relative error is: 3.46393970e- diary off

As an alternative, we can use the Maple symbollic toolbox and the diff command to form the symbollic deivative of tan(x). Note that Matlab uses an overloading feature to permit the use of the same command (here diff) to perform different functions. Earlier, we had used diff with a matrix argument, and now we use it with a symbollic argument. A code that uses this approach is available as hw 4 2b.m.

Here is a sample diary from runningthis code:

hw4_2b Supply an argument (| x |<= pi/4) for the tan function :. Supply a tolerance (positive):. The sum through the term n = 5 is 0. The relative error at x = 0.2 is3.46394e- diary off

Note that in this course we do not discuss the Maple symbollic toolbox. The hw 4 2b.m code is for your amusement. Fortunately, it produces the same result as the earlier version of the code.

Finally, it was suggested that we consider the Maclaurin expansion of the arc-tangent atan. The first few terms in the Maclaurin expansion are

tan−^1 (x) = x −

x^3 3

x^5 5

x^7 7

x^9 9

Here, we can see the pattern:

  1. a typical term is x nn
  2. only the odd terms appear
  3. the signs alternate

For the arc-tangent the radius of convergence is |x| < 1.

Here is a sample diary from runningthis code:

hw_4_2c Please enter a value to be evaluated :. Please enter a tolerance for the Maclaurin series :. After 7 termsthe Maclaurin sum is0.. The relative error is: 8.98441411e- diary off

  1. The basic analytic geometry is

r =

(x^2 + y^2 ) and θ = tan−^1 (y/x).

There is an issue of quadrant resolution since tan(x + π) = tan(x). Fortunately, Mat- lab (and most other scientific computing languages) provide us with a two argument arc tangent (atan2) to resolve the quandrant. A function.m file that uses this approach is available as cart2polar.m. Here is a sample diary from runningthis code:

[radius, angle] = cart2polar(1,2)

radius=

angle =

diary off

One subtle feature is to use Matlab’s dot or array arithmetic, so that we can provide an array of x and y values. Of course, the arrays must be the same size and we get back comaptibly sized arrays of radius and theta values.

  1. The basic analytic geometry is

r =

(x^2 + y^2 + z^2 ) , θ = tan−^1 (y/x) , andφ = cos−^1 (z/r).

Note that r ≥ 0 , −π < θ ≤ π, and0 ≤ φ ≤ pi Here again, we use the two argument arc tangent to resolve the quandrant for θ and employ dot or array arithmetic. A function.m file that uses this approach is available as cart2spherical.m. Here is a sample diary from runningthis code:

[radius, theta, phi] = cart2spherical(1,2,2) radius = 3 theta =

phi =

diary off