Parent Directory
|
Revision Log
A collection of problems illustrating how to use MathObjects when writing WeBWorK questions.
1 ##DESCRIPTION 2 ##KEYWORDS('series', 'ratio test', 'absolute convergence') 3 ##ENDDESCRIPTION 4 5 DOCUMENT(); # This should be the first executable line in the problem. 6 7 loadMacros( 8 "PGstandard.pl", 9 "PGcourse.pl", 10 "MathObjects.pl", 11 # "source.pl", 12 ); 13 14 # No partial credit on this problem, so we say: 15 install_problem_grader(~~&std_problem_grader); 16 17 TEXT(beginproblem()); 18 $showPartialCorrectAnswers = 0; 19 20 ################### 21 # 22 # Setup 23 24 Context()->variables->add(n => 'Real'); 25 Context()->strings->add(divergent=>{},div=>{alias=>'divergent'}, 26 diverges=>{alias=>'divergent'}); 27 28 $a = non_zero_random(-9,9,1); 29 $b = random(1,9,1); 30 $c = non_zero_random(-8,8,1); 31 32 $expr_e = Formula("e^(n + $a)"); 33 $expr_ne = Formula("e^(n + $a)*sqrt(n + $c)")->reduce; 34 $expr_f = Formula("(n + $b)!")->reduce; 35 $expr_nf = Formula("sqrt(n + $c)*(n + $b)!")->reduce; 36 37 $gen = random(0,3,1); 38 39 Context()->texStrings; # Needed here to display the strings below correctly 40 # in the main part of the problem. 41 if ($gen == 0) { 42 $frac = "\frac{$expr_e}{$expr_nf}"; 43 $soln1 = Real("0"); 44 $soln2 = Real("1"); 45 } 46 47 elsif ($gen == 1) { 48 $frac = "\frac{$expr_ne}{$expr_f}"; 49 $soln1 = Real("0"); 50 $soln2 = Real("1"); 51 } 52 53 elsif ($gen == 2) { 54 $frac = "\frac{$expr_nf}{$expr_e}"; 55 $soln1 = String("infinity"); 56 $soln2 = Real("2"); 57 } 58 59 else { 60 $frac = "\frac{$expr_f}{$expr_ne}"; 61 $soln1 = String("infinity"); 62 $soln2 = Real("2"); 63 } 64 65 #### Prepare poplist for question 66 @num_of_sols_pop_up_list = ( 67 ' ' => '?', 68 1 => "1. The Ratio Test says that the series converges absolutely.", 69 2 => "2. The Ratio Test says that the series diverges.", 70 3 => "3. The Ratio Test says that the series converges conditionally.", 71 4 => "4. The Ratio Test is inconclusive, but the series converges 72 absolutely by another test or tests.", 73 5 => "5. The Ratio Test is inconclusive, but the series diverges 74 by another test or tests.", 75 6 => "6. The Ratio Test is inconclusive, but the series converges 76 conditionally by another test or tests.", 77 ); 78 79 ################### 80 # 81 # Text 82 83 BEGIN_TEXT 84 85 Consider the series \($NewThing\) 86 \( \displaystyle \sum_{n=1}^{\infty} a_n \) 87 where 88 \[ a_n = $frac \] 89 In this problem you must attempt to use the Ratio Test to decide 90 whether the series converges. 91 92 $BR $BR 93 94 Compute 95 \[ L=\lim_{n\rightarrow\infty} \left| \frac{ a_{n+1} }{a_n} \right| \] 96 Enter the numerical value of the limit L if it converges, 97 INF if it diverges to infinity, -INF if it diverges to negative infinity, 98 or DIV if it diverges but not to infinity or negative infinity. $BR 99 \( L = \) \{ ans_rule( 30) \} 100 101 $BR $BR 102 103 Which of the following statements is true? $BR 104 \{pop_up_list(@num_of_sols_pop_up_list)\} 105 106 END_TEXT 107 Context()->normalStrings; 108 109 ################### 110 # 111 # Custom Answer Checker 112 113 $checker = sub { 114 115 my ($correct, $student, $ans) = @_; 116 117 Value::Error("Remember to take the absolute value of the limit.") 118 if(($student < 0) ||($student == String("-infinity"))); 119 120 ($student == $correct); 121 }; 122 123 ################### 124 # 125 # Answers 126 127 ANS($soln1->cmp(checker=>$checker)); 128 ANS($soln2->cmp); 129 130 ENDDOCUMENT(); # This should be the last executable line in the problem.
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |