3
3
## DBsection(Taylor series)
4
4
## Level(3)
5
5
## MO(1)
6
+ ## Static(1)
6
7
## This problem is a good template for questions with Taylor Polynomials
7
8
8
9
DOCUMENT();
@@ -24,7 +25,7 @@ Context("Numeric");
24
25
#Number of decimals to use in the approximation
25
26
$dec = 3;
26
27
27
- $smallDec = 10**{ -$dec} ;
28
+ $smallDec = 10**( -$dec)/2 ;
28
29
Context()->flags->set(
29
30
tolerance=>$smallDec,
30
31
tolType=>"absolute"
@@ -43,23 +44,23 @@ $x = 10;
43
44
$f[0] = Formula("(1+x)^(1/2)");
44
45
45
46
# The zero degree approximation
46
- $tn[0] = $f[0]->eval(x=>"$a");
47
+ $tn[0] = Real( $f[0]->eval(x=>"$a") );
47
48
48
49
# code to compute the nth degree approximation
49
50
$nfact = 1;
50
51
for my $i (1..$n)
51
52
{
52
- $f[$i] = $f[$i-1]->D;
53
- $fa = $f[$i]->eval(x=>"$a" );
54
- $tn[$i] = $tn[$i-1]+$fa*($x-$a)**($i)/$nfact;
53
+ $f[$i] = $f[$i-1]->D('x') ;
54
+ $fa = $f[$i]->eval(x=>$a );
55
+ $tn[$i] = Formula( $tn[$i-1]+$fa*($x-$a)**($i)/$nfact) ;
55
56
$nfact = $nfact*($i+1);
56
57
}
57
58
58
- #decreasing the number of decimal places
59
- for my $i (1..$n)
60
- {
61
- $sTn[$i] = sprintf("%0.4f",$tn[$i]);
62
- }
59
+ ## decreasing the number of decimal places
60
+ # for my $i (1..$n)
61
+ # {
62
+ # $sTn[$i] = sprintf("%0.4f",$tn[$i]);
63
+ # }
63
64
64
65
Context()->texStrings;
65
66
BEGIN_TEXT
@@ -81,36 +82,44 @@ Context()->normalStrings;
81
82
82
83
Context()->texStrings;
83
84
BEGIN_TEXT
84
- $BR $BBOLD Use $dec decimal places in your answer $EBOLD
85
+ $BR $BBOLD Your answer must be accurate to at least $dec decimal places. $EBOLD
85
86
86
87
$PAR
87
88
END_TEXT
88
89
Context()->normalStrings;
89
90
90
- for $i (1..$n)
91
- {
92
- ANS(Compute("$sTn[$i]")->cmp() );
93
- }
91
+ #for $i (1..$n)
92
+ #{
93
+ #ANS(Compute("$sTn[$i]")->cmp() );
94
+ #}
95
+
96
+ #for $i (1..$n) {
97
+ #ANS(Compute($tn[$i]->eval(x=>$x))->cmp());
98
+ #}
94
99
100
+ ANS(Compute($tn[1])->cmp());
101
+ ANS(Compute($tn[2])->cmp());
102
+ ANS(Compute($tn[3])->cmp());
95
103
96
104
97
105
# You will have to change most of the solution to fit the question
98
106
Context()->texStrings;
99
107
BEGIN_SOLUTION
100
108
$PAR SOLUTION $PAR
101
- In general the \(n^{th}\) degree approximation of \(f($ x)\) about \(x=$a\) is given by:
102
- $BR \(T_n = f($a) + f'($a)($x- a) + \ldots + \frac{f^n($x)}{n! }($x-$a)^n\)
109
+ In general the \(n^{th}\) degree approximation of \(f(x)\) about \(x=$a\) is given by:
110
+ $BR \(T_n = f($a) + f'($a)(x-$ a) + \ldots + \frac{1}{n!}{f^{(n)}($a) }($x-$a)^n\)
103
111
104
112
$PAR
105
- \(f'(x) = \frac{1}{x\sqrt{1+x}}\),
106
- $BR \(f''(x) = -\frac{1}{4(1+x)^{\frac{3}{2}}}\),
107
- $BR \(f'''(x) = \frac{3}{8(1+x)^{\frac{5}{2}}}\).
113
+ Here,
114
+ \(f'(x) = \frac{1}{2}(x+1)^{-1/2}\),
115
+ $BR \(f''(x) = -\frac{1}{4}(x+1)^{-3/2}\),
116
+ $BR \(f'''(x) = \frac{3}{8}(x+1)^{-5/2}\).
108
117
109
118
$PAR
110
119
Therefore,
111
- $BR \(T_1 = $sTn [1]\),
112
- $PAR \(T_2 = $sTn [2]\),
113
- $PAR \(T_3 = $sTn [3]\).
120
+ $BR \(T_1($x) \approx $tn [1]\),
121
+ $PAR \(T_2($x) \approx $tn [2]\),
122
+ $PAR \(T_3($x) \approx $tn [3]\).
114
123
115
124
END_SOLUTION
116
125
Context()->normalStrings;
0 commit comments