MATH 156 LAB 14Topic 1: Taylor polynomials.We have seen in Calculus 1 that the tangent line is the best linear approximation to the graph of a function. Let us take the function NiMvLUkiZkc2IjYjSSJ4R0YmLUkjbG5HRiZGJw== and look at the tangent line and the graph close to the point (1,0).f:=x->ln(x);D(f)(1);Since the slope of the tangent line is 1 and the point of contact is (1,0) the equation of the tangent line is NiMvJSJ5RywmJSJ4RyIiIkYnISIi.g:=x->x-1;plot({f(x), g(x)}, x=0..2);We zoom further by choosing the x-range to be smaller.plot({f(x), g(x)}, x=0.5..1.5);plot({f(x), g(x)}, x=0.75..1.25);plot({f(x), g(x)}, x=0.875..1.125);We see that the closer we look at (1,0), the closer the tangent line is to the graph. Moreover, we notice the following. At every step we halved the size of the NiNJInhHNiI=-interval. The distance between the graph of NiMvLSUiZkc2IyUieEctJSNsbkdGJg== and the tangent line is not only halved but gets smaller more rapidly than that. This is the meaning of the tangent line approximation. We can see the numerics as well. The closer we are to 1, the closer the value of the tangent line to the actual value of the function:for k from 1 to 10 do; x:= 1+2^(-k); actualvalue:=evalf(f(x)); tangentapprox:=evalf(x-1); od;We can measure the error in the tangent line approximation by computing NiMsJi0lI2xuRzYjJSJ4RyIiIiwmRidGKEYoISIiRio=.for k from 1 to 10 do; x:= 1+2^(-k); evalf(f(x)-(x-1)); od;The errors get smaller the closer we are to NiMvJSJ4RyIiIg==. The errors are negative, because the tangent line overestimates the function. The tangent line lies above the graph of the function, since the function is concave downwards. Make similar tables for values of NiMyJSJ4RyIiIg==.On the other hand, if we are far away from (1,0), the tangent line approximation is not very good:evalf(f(2)); g(2);evalf(f(3)); g(3);evalf(f(4));g(4);The reason is that the function NiMtJSNsbkc2IyUieEc= bends, as a concave downwards function, while the tangent line does not. Somehow we have to take into account the concavity. In Calculus 1 we saw that the concavity is measured by the second derivative.D(D(f))(1);The function NiMvLSUiaEc2IyUieEcsKEYnIiIiRikhIiIqJiwmRidGKUYpRioiIiNGLUYqRio= has the following properties: h(1)=f(1), h'(1)=f'(1) and h''(1)=f''(1):h:=x->(x-1)-(x-1)^2/2;h(1);f(1);D(h)(1); D(f)(1);D(D(h))(1);D(D(f))(1);We now graph all the three functions.plot([f,g,h], 0..2, color=[red, blue, green]);We painted the logarithmic function with red, the tangent line with blue and the function h(x) with green. We see that the quadratic function NiMtJSJoRzYjJSJ4Rw== seems to be closer to the graph of the logarithm than the tangent line. We zoom in by adjusting the range.plot([f,g,h], 0.5..1.5, color=[red, blue, green]);plot([f,g,h], 0.75..1.25, color=[red, blue, green]);plot([f,g,h], 0.875..1.125, color=[red, blue, green]);At this moment we can hardly distinguish the quadratic function, which is a parabola, from the logarithm. We make also a table of values of all 3 functions.Digits:=15; for k from 1 to 10 do; x:= 1+2^(-k); actual:=evalf(f(x)); tangent:=evalf(g(x));parab:=evalf(h(x)) od;We see that the values of NiMtJSJoRzYjJSJ4Rw== are closer to the logarithm than the corresponding values of the tangent line (NiMtJSJnRzYjJSJ4Rw==). To measure the closeness we make a table of the errors: NiMsJi0lI2xuRzYjJSJ4RyIiIiwmRidGKEYoISIiRio= and NiMsJi0lI2xuRzYjJSJ4RyIiIiwoRidGKEYoISIiKiYsJkYnRihGKEYqIiIjRi1GKkYqRio=:for k from 1 to 10 do; x:= 1+2^(-k); errorfortangent:=evalf(f(x)-g(x));errorforparab:=evalf(f(x)-h(x)); od;We see that the errors are smaller for the quadratic polynomial. The errors are positive for NiMtJSJoRzYjJSJ4Rw== because for NiMyIiIiJSJ4Rw== the parabola was below the graph of the logarithm. Make a table of f, g, h and the errors for values of NiMyJSJ4RyIiIg==.The errors are negative because the tangent line and the parabola are above the logarithm. The errors with the parabola are smaller than the tangent line approximation. The approximation is not very good far away from 1.plot([f,g,h], 0..3, color=[red, blue, green]);We see that the parabola starts decreasing at NiMvJSJ4RyIiIw==, while the logarithm keeps increasing. So there is no hope further away from 2. If one wants a better approximation, one has to use higher degree polynomials. We would like to find a 3rd degree polynomial NiMtJiUiUEc2IyIiJDYjJSJ4Rw==, such that: NiMvLSYlIlBHNiMiIiQ2IyIiIi0lImZHRik=, NiMmJSJQRzYjIiIk'(1)=f'(1),NiMmJSJQRzYjIiIk''(1)=f''(1) and NiMmJSJQRzYjIiIk'''(1)=f'''(1). Luckily Maple can gives us this polynomial, called the third degree Taylor polynomial for NiMtJSNsbkc2IyUieEc= at NiMvJSJ4RyIiIg==. The command is:x:='x'; taylor( f(x), x=1, 4 );We can plot NiMtJSNsbkc2IyUieEc= and the polynomial NiMtJiUiUEc2IyIiJDYjJSJ4Rw==. However, first we must define a function out of it. We have the following convenient commands:taylor3:=taylor(f(x), x=1, 4);lntaylor3:=convert(taylor3, polynom);tay3:=unapply(lntaylor3, x);plot([ln, g, h, tay3], 0..2, color=[red, blue, green, orange]);We see that NiMtJiUiUEc2IyIiJDYjJSJ4Rw== (brown, orange curve) is closer to the logarithm (red curve) than the tangent line (blue) and the second degree polynomial h(x) (green).Find the 4th, 5th, 6th degree Taylor polynomials of NiMtJSNsbkc2IyUieEc= at x=1. Plot them and make a table of values for NiMvJSJ4Ry0lJkZsb2F0RzYkIiM2ISIi and another for NiMvJSJ4Ry0lJkZsb2F0RzYkIiM3ISIi and another for NiMvJSJ4Ry0lJkZsb2F0RzYkIiIqISIi.