Skip to content

Commit 11b01a9

Browse files
committed
Fix bug 4690
1 parent 948febf commit 11b01a9

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

OpenProblemLibrary/UBC/setTaylor/testingError.pg

+32-23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## DBsection(Taylor series)
44
## Level(3)
55
## MO(1)
6+
## Static(1)
67
## This problem is a good template for questions with Taylor Polynomials
78

89
DOCUMENT();
@@ -24,7 +25,7 @@ Context("Numeric");
2425
#Number of decimals to use in the approximation
2526
$dec = 3;
2627

27-
$smallDec = 10**{-$dec};
28+
$smallDec = 10**(-$dec)/2;
2829
Context()->flags->set(
2930
tolerance=>$smallDec,
3031
tolType=>"absolute"
@@ -43,23 +44,23 @@ $x = 10;
4344
$f[0] = Formula("(1+x)^(1/2)");
4445

4546
# The zero degree approximation
46-
$tn[0] = $f[0]->eval(x=>"$a");
47+
$tn[0] = Real($f[0]->eval(x=>"$a"));
4748

4849
# code to compute the nth degree approximation
4950
$nfact = 1;
5051
for my $i (1..$n)
5152
{
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);
5556
$nfact = $nfact*($i+1);
5657
}
5758

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+
#}
6364

6465
Context()->texStrings;
6566
BEGIN_TEXT
@@ -81,36 +82,44 @@ Context()->normalStrings;
8182

8283
Context()->texStrings;
8384
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
8586

8687
$PAR
8788
END_TEXT
8889
Context()->normalStrings;
8990

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+
#}
9499

100+
ANS(Compute($tn[1])->cmp());
101+
ANS(Compute($tn[2])->cmp());
102+
ANS(Compute($tn[3])->cmp());
95103

96104

97105
# You will have to change most of the solution to fit the question
98106
Context()->texStrings;
99107
BEGIN_SOLUTION
100108
$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\)
103111

104112
$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}\).
108117

109118
$PAR
110119
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]\).
114123

115124
END_SOLUTION
116125
Context()->normalStrings;

0 commit comments

Comments
 (0)