# DESCRIPTION # Problem from Calculus, single variable, Hughes-Hallett et al., 4th ed. # WeBWorK problem written by Gavin LaRose, # ENDDESCRIPTION ## KEYWORDS('calculus','taylor series','error','polynomials') ## Tagged by glr 01/27/09 ## DBsubject('Calculus') ## DBchapter('Infinite Sequences and Series') ## DBsection('Taylor and Maclaurin Series') ## Date('') ## Author('Gavin LaRose') ## Institution('University of Michigan') ## TitleText1('Calculus') ## TitleText2('Calculus') ## TitleText3('Calculus') ## EditionText1('4') ## EditionText2('5') ## EditionText3('6') ## AuthorText1('Hughes-Hallett') ## AuthorText2('Hughes-Hallett') ## AuthorText3('Hughes-Hallett') ## Section1('10.4') ## Section2('10.4') ## Section3('10.4') ## Problem1('11') ## Problem2('10') ## Problem3('13') ## Textbook tags ## HHChapter('Approximating Functions Using Series') ## HHSection('The Error in Taylor Polynomial Approximations') DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGchoicemacros.pl", # "parserNumberWithUnits.pl", # "parserFormulaWithUnits.pl", # "parserFormulaUpToConstant.pl", # "PGcourse.pl", ); Context("Numeric"); Context()->strings->add( none=>{} ); Context()->flags->set( reduceConstants=>0 ); $showPartialCorrectAnswers = 1;$dummy = random(3,4,1); $whichF = random(0,1,1); if ($whichF == 0 ) { ## use sin(x) $f = Compute("sin(x)");$p0 = Compute("x"); $n = random(3,5,2);$p1 = $p0 + (($n == 3) ? Compute("-x^3/3!") : Compute("-x^3/3! + x^5/5!")); $err0 = Compute( "1/(3!)" );$err1 = Compute( "1/(($n+2)!)" ); Context("Interval"); Context()->strings->add( none=>{} ); Context()->flags->set( reduceConstants=>0 ); @i0over = (Compute("(0,1)")); @i0under = (Compute("(-1,0)")); @i1over = (($n == 3) ? Compute("(-1,0)") : Compute("(0,1)")); @i1under = (($n == 3) ? Compute("(0,1)") : Compute("(-1,0)")); } else { ## use e^(-x)$f = Compute("e^(-x)"); $p0 = Compute("1 - x");$n = random(2,3,1); $p1 =$p0 + (($n == 2) ? Compute("x^2/2!") : Compute("x^2/2! - x^3/3!"));$err0 = Compute( "e^1/(2!)" ); $err1 = Compute( "e^1/(($n+1)!)" ); Context("Interval"); Context()->strings->add( none=>{} ); Context()->flags->set( reduceConstants=>0 ); @i0over = ( String("none") ); @i0under = ( Compute("(-1,0)"), Compute("(0,1)") ); if ( $n == 2 ) { @i1over = ( Compute("(0,1)") ); @i1under = ( Compute("(-1,0)") ); } else { @i1over = ( String("none") ); @i1under = ( Compute("(-1,0)"), Compute("(0,1)") ); } } TEXT(beginproblem()); Context()->texStrings; BEGIN_TEXT Consider the error in using the approximation $$f \approx p0$$ on the interval $$[-1, 1]$$.$PAR ${BBOLD}(a)$EBOLD Reasoning informally, on what interval is this approximation an overestimate? \{ ans_rule(25) \} $BR An underestimate? \{ ans_rule(25) \}$BR ${BITALIC}(For each, give your answer as an interval or list of intervals, e.g., to specify the intervals $$-0.25 \le x < 0.5$$ and $$0.75 < x \le 1$$, enter${BBOLD}[-0.25, 0.75), (0.75,1]$EBOLD Enter${BBOLD}none$EBOLD if there are no such intervals.)$EITALIC $PAR${BBOLD}(b)$EBOLD Use the Error Bound for Taylor Polynomials to find a good smallest bound for the error in approximating $$f$$ with $$p0$$ on this interval:$BR error bound = \{ ans_rule(35) \} $PAR Now, consider the error in using the approximation $$f \approx p1$$ on the same interval.$PAR ${BBOLD}(c)$EBOLD Reasoning informally, on what interval is this approximation an overestimate? \{ ans_rule(25) \} $BR An underestimate? \{ ans_rule(25) \}$BR ${BITALIC}(For each, give your answer as an interval or list of intervals, e.g., to specify the intervals $$-0.25 \le x < 0.5$$ and $$0.75 < x \le 1$$, enter${BBOLD}[-0.25, 0.75), (0.75,1]$EBOLD Enter${BBOLD}none$EBOLD if there are no such intervals.)$EITALIC $PAR${BBOLD}(d)$EBOLD Use the Error Bound for Taylor Polynomials to find a good smallest bound for the error in approximating $$f$$ with $$p1$$ on this interval:$BR error bound = \{ ans_rule(35) \} END_TEXT Context()->normalStrings; ANS(List( @i0over )->cmp() ); ANS(List( @i0under )->cmp() ); ANS($err0->cmp( checker=>sub{ my ($correct, $student,$ansHash ) = @_; if ( $correct ==$student ) { return 1; } elsif ( $student >$correct ) { Value->Error("Your answer isn't the smallest bound " . "you can obtain with the theorem."); return 0; } else { return 0; } } ) ); ANS(List( @i1over )->cmp() ); ANS(List( @i1under )->cmp() ); ANS($err1->cmp( checker=>sub{ my ($correct, $student,$ansHash ) = @_; if ( $correct ==$student ) { return 1; } elsif ( $student >$correct ) { Value->Error("Your answer isn't the smallest bound " . "you can obtain with the theorem."); return 0; } else { return 0; } } ) ); $m0 = ($whichF ) ? "." : "; it is also the second degree approximation, " . "since the next term in the Taylor expansion is 0."; $e0deg = ($whichF ) ? "first" : "second"; $d0 = ($whichF ) ? "2" : "3"; $d0m1 =$d0 - 1; $d0fac = ($d0 == 2 ) ? 2 : 6; $m1 = ($whichF ) ? "no values of $$x$$" : "$$i0over[0]$$"; $m2 = ($whichF ) ? "$$i0under[0]$$ and $$i0under[1]$$" : "$$i0under[0]$$"; $f3 = ($whichF ) ? Compute("e^(-x)") : Compute("-cos(x)"); $dbound3 = ($whichF ) ? "e^{0.1}" : "1"; $np1 =$n+1; $np2 =$n+2; $d1 = ($whichF ) ? $np1 :$np2; $d1m1 =$d1 - 1; $d1fac = Compute( "$d1!" ); $m3 = ($whichF ) ? "." : "; it is also the ${np1}th degree approximation, " . "since the next term in the Taylor expansion is 0.";$m4 = ( $whichF &&$n==3 ) ? "no values of $$x$$" : "$$i1over[0]$$"; $m5 = ($whichF && $n==3 ) ? "$$i1under[0]$$ and $$i1under[1]$$" : "$$i1under[0]$$"; Context()->texStrings; SOLUTION(EV3(<<'END_SOLUTION'));$PAR SOLUTION $PAR${BBOLD}(a)$EBOLD $$p0$$ is the first degree approximation of $$f(x)=f$$$m0 $$P_1(x) = p0$$ is an overestimate for $m1 and an underestimate for$m2. (This can be seen easily from a graph.) $PAR${BBOLD}(b)$EBOLD Using the$e0deg degree error bound, if $$|f^{(d0)}(x)| \leq M$$ for $$-1 \leq x \leq 1$$, then $$|E_{d0m1}|\leq \frac{M\cdot |x|^{d0}}{{d0}!} \leq \frac{M}{d0fac}.$$ For what value of $$M$$ is $$|f^{(d0)}(x)| \leq M$$ for $$-1 \leq x \leq 1$$? Well, $$|f^{(d0)}(x)|=|f3| \leq dbound3$$. So $$|E_{d0m1}| \leq \frac{dbound3}{d0fac}.$$ $PAR${BBOLD}(c)$EBOLD As before, we note that $$p1$$ is the${n}th degree approximation of $$f(x)=f$$$m3 This is an overestimate for$m4 and an underestimate for $m5. (This also can be seen easily from a graph.)$PAR ${BBOLD}(d)$EBOLD Again, similar to (b), our error bound is $$|E_{d1m1}|\le \frac{M\cdot |x|^{d1}}{(d1)!} \le \frac{M}{d1fac},$$ where $$|f^{(d1)}(x)| \leq M$$ for $$-1 \leq x \leq 1$$. Then a good value for $$M$$ is $$M = dbound3$$, so $$|E_{d1m1}| \le \frac{dbound3}{d1fac}$$. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version'); ENDDOCUMENT();