Chap 27 Exercises

WebR Status

🟡 Loading...

Loading webR...

Exercise 1 The Taylor polynomial T(x)96(x5)9(x5)2 is used to approximate the function f(x).

  1. At what value x0 is the Taylor polynomial centered?

x0=9

x0=6

x0=5

x0=0

question id: csfj-1

  1. What do we know about x(x0)?

x(x0) is negative

x(x0) is zero

x(x0) is positive

It cannot be determined from the polynomial

question id: csfj-2

  1. What is the value of xx(x0)?

xx(x0) is negative, but we cannot determine its magnitude

xx(x0)=9

xx(x0)=4.5

xx(x0)=18

question id: csfj-3

Exercise 2 Here’s the Taylor polynomial expansion of sin(x) about a center x0: p(x)=1/23/22!(xx0)2+1/24!(xx0)4+ Which of the following is the numerical value of x0? (Hint: Remember that the coefficients involve the function and its derivatives evaluated at x0 as described in [Faulty cross reference: high-order-approx].

π/6       π/3       π/2       π      

question id: calf-tear-fridge-1

Exercise 3 Consider the function f(x)(x3)2.

Using ordinary algebra, f(x) can be expanded as (x26x9). Consider p(x)=96x+x2. Is p() a Taylor polynomial expansion of f(x)?

Yes, with a center at x0=0

Yes, with a center at x0=3

No, because there are no factorials involved

question id: QGSi6C

Exercise 4 At x=0, the value of xln(x) is indeterminate, having the form 0.

Using , plot out xln(x) over the domain 0<x<12.

Active R chunk 1
  1. From the graph, determine limx0xln(x(). Choose the closest answer.
-0.2       0       0.1       0.5       not well behaved      

question id: dolphin-mean-linen-1

Now to check the existence of limx0xln(x) using the traditional calculus techniques of l’Hopital’s Rule.

Recall that l’Hopital’s Rule covers situations like 0/0 or /. But with limx0xln(x) we have a situation of 0×. However, xln(x)=ln(x)1/x which makes it clearer that limx0xln(x) is a matter of comparing the two functions ln(x) and 1/x. The limit x0 is of ln(x) is while for 1/x it is . Thus we have a indeterminate form problem of . This can be handled by l’Hopital’s Rule.

Here, the rule has the form:

(1)limx0[ln(x)1/x]=limx0[xln(x)x1/x]

Compute the derivatives on the right-hand side of and simplify the algebra.

  1. What does [xln(x)x1/x] simplify to?
x       x       1/x       1/x      

question id: dolphin-mean-linen-2

Take the limit as x0 of the simplifed form. That will be the result from l’Hopital’s Rule.

  1. Does the application of l’Hopital’s rule confirm the result from graphing the function on the computer?
Yes       No      

question id: dolphin-mean-linen-3

Exercise 13 We are all busy people these days and nobody has the time to compute an infinite number of coefficients define a function using a Taylor series. Instead, we will have to use just a few coefficients. But how many is enough?

The function make_poly() defined in can create a function given a fiducial point x0 and a few coefficients at the start of the Taylor polynomial.

For example, the coefficients for ex (around x0=0) are 1,1,1/2,1/6,1/24,1/120,1/720,1/5040,1/40320,1/362880,... Factorials get big fast!

The sandbox shows a simple comparison of the polynomial approximation to the actual exponential function. it plots the magnitude of the error |exp(x)| on a log-log scale.

Active R chunk 2

Read the graph carefully to make sure you understand what is being displayed.

  • It is easy to think about the “absolute error” scale as indicating the number of zeros after the decimal point in the size of the error. For example 1e-6 is 0.000001. The approximation has that much error or less for |x|<0.3.
  • We are using log-log scales because we anticipated that the error would be something like a power law. (Why? Because the first term omitted from the approximation will produce a function an+1xn+1, a power law. And when a power-law function is plotted on log-log axes, it appears as a straight line.) But we cannot graph negative values of x on a log scale. So we are plotting both p(x) and p(x) together. The error for negative x values are plotted in red.

For x2.0, the magnitude of the error is, to judge from the graph, 1e-1. When written as a decimal number, how many leading zeros are after the decimal point?

-2       -1       0       1       2      

question id: fawn-hear-kayak-1

For x10.0, the magnitude of the error is, to judge from the graph, 1e4. What is this when written as a decimal number?

10       100       1000       10000      

question id: fawn-hear-kayak-2

Exercise 5 In the next Blocks of the textbook, we will be using four of our basic modeling functions very heavily:

  1. exponential function
  2. sine function (which it turns out is related to the exponential function)
  3. cosine function (just like the sin if you shifted it backward in time by 1/4 period)
  4. logarithm function (the inverse of the exponential)

These functions are all very intricately related to one another. It will help to see the relationships if we write each of them in a common form. To that end, we will write each as a linear combination of power-law functions with integer exponents. Each of these linear series involves an infinite number of power-law functions.

  1. exponential functionex=1+x1+x22!+x33!+x44!+x55!+

  2. sine function sin(x)=0+x1!+0x33!+0+x55!+

  3. cosine function cos(x)=1+0x22!+0+x44!+0+

  4. “natural” logarithmln(1+x)=0+x1x22+x33x44+x55+

We ask you to memorize each of these four infinite series. Since it is impractical to memorize an ionfinite number of things, we will give you a system so that there are only a small number of facts needed.

  1. Each term in each series will be given an index $n = 0, 1, 2, 3, 4, 5,
  2. Every term involves multiplying the power law function xn by a number. Except for the ln(1+x) function, that number is always 1/n! multiplied by a sign, which can be 1,0, or 1.

Here are the patterns of the signs:

function x0 x1 x2 x3 x4 x5 x6
ex + + + + + + +
cos(x) + 0 - 0 + 0 -
sin(x) 0 + 0 - 0 + 0
ln(1+x) 0 + - + - + -

Notice that the signs of the cos(x) function cycle with a period of 4, so the sign of term n+4 equals the sign of term n. Same with the sin(x), but the signs are shifted one slot.

The series all extend to n. Consequently, it is not practical to use these polynomial expansions for exact calculations. Mathematicians call them transcendental functions.

  1. Which of these functions has a 0 for the x0 term of the series? Choose the most complete correct answer.

ex

sin(x)

cos(x)

sin(x) and cos(x)

sin(x) and ex

cos(x) and ln(x+1)

question id: fox-dig-room-1

  1. Which of these functions has a 1 for the x0 term of the series? (Choose the most complete correct answer.

ex

sin(x)

cos(x)

sin(x) and cos(x)

sin(x) and ex

cos(x) and ex

question id: fox-dig-room-2

  1. What’s the first zero term in the expansion of ex+cos(x)?
x0 term       x1 term       x2 term       x3 term       x4 term       x5 term      

question id: fox-dig-room-3

  1. What’s the first negative term in the expansion of sin(x)+cos(x)?
x0 term       x1 term       x2 term       x3 term       x4 term       x5 term       there are none      

question id: fox-dig-room-4

  1. What’s the second negative term in the expansion of sin(x)+cos(x)?
x0 term       x1 term       x2 term       x3 term       x4 term       x5 term       there are none      

question id: fox-dig-room-5

  1. What’s the first zero term in the expansion of sin(x)+cos(x)?
x0 term       x1 term       x2 term       x3 term       x4 term       x5 term       there are none      

question id: fox-dig-room-6

Exercise 6 Here is a Taylor polynomial: p(x)=e+e1!(x1)+e2!(x1)2+

  1. Where is the center x0 of this polynomial?
x0=2       x0=1       x0=0       x0=1       x0=2 pig-iron-closet      

question id: pig-iron-closet-1

  1. Your roommate suggests that p(x) is a Taylor expansion of ex around x=1. Is he right?

No, a polynomial does not have functions like e.

Yes. The center is x0=1.

Not really. The formula suggests that the center is x0=1 but the coefficients are wrong. [ hint: The coefficients are right. ]pig-iron-closet

question id: pig-iron-closet-2

Exercise 7 With very high-order derivatives, it can be awkward to use a notation with repeated subscripts, like xxxxxf(x). Another notation often encountered is f(5), where the integer in the superscript tells the order of the derivative. We will use that notation in this problem.

For a function f(x) and its derivatives f(1)(x), f(2)(x), … the Taylor polynomial p(x) centered on x0 is

p(x)f(x0)+f(1)(x0)1!(xx0)1+f(2)(x0)2!(xx0)2+

A Taylor polynomial, like all polynomials, is a linear combination of basic functions.

Which of these are the basic functions being linearly combined in a Taylor polynomial?

f(x),f(1)(x),f(2)(x),

f(x0),f(1)(x0),f(2)(x0),

f(x0),f(1)(x0)1!,f(2)(x0)2!,

(xx0),(xx0)2,

question id: frog-throw-screen-1

Exercise 8 Recall the formula for the coefficients an to approximate a function f(x):

an=f(n)(x0)n! where f(n) means the “nth derivative. For simplicity, we will look at examples where x0=0, so that the polynomial itself will be

p(x)=a0x0+a1x1+a2x2+a3x3+ Of course, x0 equals 1.

Let’s construct the polynomial coefficients for the function f(x)=ex around x0=1. Start with the sequence of derivatives f(n)(0).

  1. Which of these gives the sequence f(n)(0) (where f(x)=ex) for n=0,1,2,3,... ?

0, 0, 0, 0, 0, …

1, 1, 1, 1, 1, …

1, 2, 3, 4, 5, …

0, 1, 2, 3, 4, …

question id: bc1-1

  1. Which of these gives the sequence n! for n=0,1,2,3,... ?

0, 0, 0, 0, 0, …

1, 2, 3, 4, 5, …

0, 1, 2, 3, 4, …

1, 1, 2, 6, 24, …

question id: bc1-2

  1. One of these is not the polynomial expansion for ex. Which one?

1+x+x22+x36+x424+

1+x+x22+x33+x44+

1+x+x22!+x33!+x44!+

question id: bc1-3

Now let’s construct the polynomial expansion of sin(x) using the same technique: Find the sequence of derivatives f(n), then divide each of them by n! to construct the an coefficients.

  1. Which of these gives the sequence f(n)(0) (where f(x)=sin(x)) for n=0,1,2,3,... ? (Remember, x0 will be set to zero.)

0, 1, -1, 1, -1, …

1, 0, -1, 0, 1, …

0, 1, 0, -1, 0, …

1, 0, 0, -1, 1, …

question id: bc1-4

  1. One of these is the polynomial expansion for sin(x). Which one?

1+x+x22+x36+x424+

xx33x55+

xx36x5120+

1+xx36x524+

question id: bc1-5

  1. Take the correct polynomial expansion for sin(x) from the previous question and differentiate it term by term to get the polynomial expansion for cos(x). Which one of these is right

1x22+x36x424+

1x22x44+

1x26+x424

1x22+x4120+

question id: bc1-6

Finally, let’s construct the polynomial expansion of the function f(x)11x at x0=0.

  1. Which of these gives the sequence f(n)(0) (where f(x)=1/(1x)) for n=0,1,2,3,... ? (Remember, x0 will be set to zero.)

1, 1, 1, 1, 1 …

1, -1, 1, -1, 1, …

0, 1, 0, 1, 0, …

1, 0, 1, 0, 1, …

question id: bc1-7

  1. What are the coefficients an in the polynomial expansion of 1/(1x), for n=0,1,2,3,4,...

1, 1, 1, 1, 1, …

1, 1/2, 1/6, 1/24, 1/120, …

1, 1, 1/2, 1/6, 1/24, …

1, 1, 2!, 3!, 4!

question id: bc1-8

Exercise 9 Consider the function f(x)sin(xπ6) and its 3rd order Taylor polynomial approximation, T(x). Both are implemented in ?lst-seahorse-pay-plant, which you should run before continuing.

Active R chunk 3: Function definitions for this exercise.

In this exercise, we want to figure out the extent of the interval in which T(x) is within 0.05 of f(x). We can do this by plotting T(x) and also the two functions f(x)+0.05 and f(x)0.05.

Active R chunk 4

Find the full interval of the domain of x for which f(x)0.05<T(x)<f(x)+0.05. (Hint: you may need to modify the plotting commands in .)

x(1.1,1,1)

x(1.1,1.5)

x(1.5,1.1)

x(1.5,1.5)

question id: seahorse-pay-plant

Exercise 12  

In draft

Need to integrate this with the Chapter 27 text.

The polynomial computer does not have any problem with overflow or underflow. The key to success is to write the Taylor polynomial for functions such as sin(x) or x or x2 near x0=0. Such polynomials will always look like:

f(x)=a1x1+a2x2+a3x3+

What’s special here is that the a_0 term does not need to be included in the polynomial, since f(0)=0.

  1. One of these functions has a Taylor polynomial at x0=0 the does need a non-zero a0 term. The other’s don’t. Which function needs the non-zero a0 term?

sin()

tan()

atan()

acos()

question id: rhinosaurus-toss-gloves-4

These zero divided by zero problems (like sin(x)/x) always involve a ratio of two functions (sin(x) and x here) that don’t need the a0 term in their Taylor series around x0=0. That makes them just a little bit simpler.

What’s more important than simpler is that, for the expansion of such functions to study the limit at x0, we only need the first term with a non-zero coefficient ak to represent the function with complete accuracy.

Why? Consider the 2nd-order Taylor polynomial a1x+a2x2. If we are to be able to safely disregard the a2 term it is because that term, for small x is much, much smaller than the a1x term. And we can always choose non-zero x to make this so.

For instance, suppose our polynomial were x+100x2. For x=0.1, the first and second terms are the same size; we need them both for accuracy. For x=0.01, the second term is 1/100 the size of the first term, maybe we don’t need the second term so much. You can always make x so small that anyone will be satisfied that the second term is utterly negligible compared to the first.

Here’s the method:

Suppose you have a function f(x)u(x)/v(x) where limx0u(x)=0   and   limx0v(x)=0 Given this, f(0) is not defined. But we can ask whether there is a sensible value that can be plugged in in place of f(0) that will cause the modified f() to be continuous at x=0.

Step 1: Write the Taylor polynomial expansion around x0=0 for both u(x) and v(x). If both expansions have a non-zero first coefficient, you can stop there. Now we have:

u(x)a1x v(x)b1x where a1=xu(0) and b1=xv(0).

Step 2: Divide the polynomial (really just linear!) expansion of u() by the expansion of v() to get

limx0u(x)v(x)=limx0a1xb1x=a1b1

that is the answer, a1/b1, at least when b10. We will come back to that case later.

  1. For limx0sin(x)/x, what are a1 and b1?

a1=1 and b1=1

a1=π and b1=π

a1=1 and b1=1

a1=0 and b1=1

question id: rhinosaurus-toss-gloves-5

Sometimes the singularity is at some non-zero x. For instance, h(x)x216x4 The divide-by-zero comes into play when x=4. So is there a sensible value to plug in for h(4) to replace the singularity.

Here, write your Taylor polynomials around x0=4, the location of the singularity. We will get:

x216=a1(x4)+a2(x4)2+ x4=b1(x4) Using Taylor’s formula for coefficients we will get a1=x(x216)|x=4=2x|x=4=8 b1=x(x4)=1

Consequently, limx4x216x4=8

We’ve been discussing ratios of functions where the ratio cannot be calculated at the singularity using simply the limits of the functions approaching that singularity. (For instance limx0sin(x)=0 and limx0x=0, but knowing this does not tell us what limx0sin(x)x will be. These are called “indeterminate forms.” As you’ve seen, if we know more about the functions than merely their individual limits, we can sometimes resolve the indeterminacy. Here we are doing that by writing each function as a low-order polynomial.

The indeterminate form limx0sin(x)x might be said to have the “shape” 0/0. But 0/0 is just a notation about the limits of the two individual functions. There are indeterminate forms with other shapes: 00            0     00      0      1       Keep in mind that something like 0 is not a multiplication problem but rather shorthand for u(x)v(x) where limxx0u(x)=0 and limxx0v(x).

There is a variety of algebraic tricks to try to transform these different shapes of indeterminate forms into a ratio of functions, each of which goes to zero at the relevant x0. Once that is done, you can apply the method described above.

Indeterminate forms have been a bonanza for the author of calculus book exercises, who can write an large number of examples, many of which have never been seen in the wild.

One shortcut that works in practice is to make a graph of the indeterminate form near the singularity. If the limit as x approaches the singularity is a finite number, you can read off the result from the graph.

In , the function g(x)xln(x) is set up. This function has a singularity at x=0. Examine the plot and determine where the function value is going as you walk along the graph to the singularity.

Active R chunk 5

Activities

Exercise 10 In this exercise, you’re going to approximate a sinusoid sin(x) with polynomials of order 3, 5, and 7. The approximation should go exactly through the coordinate pair (x0=0,y=0) shown as a bright dot on the graph. Notice that the approximation is exacty tangent to the sinusoid at x0=0: the approximating line goes straight through the dot and continues pretty much through the center of the thick line marking the sinusoid, until the sinusoid curves away from the straight line.

Warning: All aesthetics have length 1, but the data has 101 rows.
ℹ Please consider using `annotate()` or provide this layer with data containing
  a single row.

  1. Draw your own graph of a sinusoid so that you can sketch on top of it the polynomial approximations you will design.

  2. Start with sketching in a third-order polynomial that approximates the sinusoid near x0=0. The general formula for a third order polynomial is third(x)b0+b1x1first-order polynomial+b2x2second-order polynomial+b3x3 To turn the first-order approximation into a third-order approximation algebraically, you would need to choose the coefficients b2 and b3. You want to choose the best possible b2 and b3 to stay close to the sinusoid. Of course, you could take the lazy person’s approach and choose b2=b3=0. If you did that, you would have the first-order polynomial. Here’s the important point: the best third-order polynomial will not be any worse than the first-order polynomial, but it can be better!

    Remember what you know about the shape of third-order polynomials:

    1. One tail will go up, the other down.
    2. There can be both an argmin and an argmax.
  3. Repeat (1), sketching out a 5th-order polynomial. Again, one tail will go up and the other down. But now there can be two argmaxes and two argmins that alternate along the x axis: min, max, min, max.

  4. One more time, sketching now a 7th-order polynomial. Just like the first-, third-, and fifth-order polynomial, for the 7th one tail will go up and the other down. There can be as many as three argmaxes and three argmins. They will alternate: between any two argmaxes, there will be one argmin.

Exercise 11 We would like to write a Taylor-series polynomial for dnorm(x). To do this, we will need the folling numbers dnorm(x0),  xdnorm(x0),  xxdnorm(x0),  xxxdnorm(x0),...

  1. (To warm up.) Why did I call the forms like xxxdnorm(x0) a number rather than a function?

Because partial derivatives are numbers.

Because the notation x0 is used to refer to a number, not the name of an input.

It was a mistake.

question id: birch-dig-radio-1

Here are the functions for the derivatives

Order formula for derivative
0th dnorm(x)
1st (x)dnorm(x)
2nd (x21)dnorm(x)
3rd (3xx3)dnorm(x)
4th (3x2x4)dnorm(x)
5th (36x3+x5)dnorm(x)
6th (15x2+10x4x6)dnorm(x)
7th (15+45x315x5+x7)dnorm(x)
8th (105x2105x4+21x6x8)dnorm(x)
  1. Write a Taylor polynomial function for dnorm(x) around x0=0). To do this, you will have to evaluate each of the 9 formulas above at x=0, producing a number. For example, the first five formulas will give 0.3989, 0, -0.3989, 0, 1.1968. This would expand into the Taylor function defined in :
Active R chunk 6

You will need to add in the 6th, 7th, and 8th terms.

  1. Plot T_at_0(x) ~ x over the domain 0x2, and pipe the result to a slice-plot of dnorm(x) ~ x so that you can compare the two plots.

  2. Define another function T_at_1() which will be much like T_at_zero() but with x0=1 and the coefficients changed to be the formulas evaluated at x=1.

  3. Add a layer showing T_at_1() to your previous plot.

Say over what domain T_at_0() is a good approximation to dnorm() and over what domain T_at_1() is a good approximation to dnorm(). Do the two domains overlap?

  1. Write a piecewise function T() as defined in :
Active R chunk 7

Plot T() out on top of dnorm() to show whether T() is a good approximation to dnorm().

You could continue on to define T_at_2() and incorporate that into the piecewise T(), and so on, to construct an approximation to dnorm() that is accurate over a larger domain.

No answers yet collected
×

R History Command Contents

Download R History File