[npl] / trunk / NationalProblemLibrary / Dartmouth / setStewartCh18S1 / problem_2.pg Repository:
ViewVC logotype

View of /trunk/NationalProblemLibrary/Dartmouth/setStewartCh18S1/problem_2.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 269 - (download) (annotate)
Sat Jun 3 14:39:59 2006 UTC (6 years, 11 months ago) by gage
File size: 2664 byte(s)
 Cleaned problem code using convert-functions.pl

    1 ## DESCRIPTION
    2 ## Calculus
    3 ## ENDDESCRIPTION
    4 
    5 ## KEYWORDS('homogeneous' 'differential equation')
    6 ## Tagged by tda2d
    7 
    8 ## DBsubject('Calculus')
    9 ## DBchapter('Second-Order Differential Equations')
   10 ## DBsection('Second-Order Linear Equations')
   11 ## Date('')
   12 ## Author('')
   13 ## Institution('Dartmouth')
   14 ## TitleText1('Calculus')
   15 ## EditionText1('5')
   16 ## AuthorText1('Stewart')
   17 ## Section1('18.1')
   18 ## Problem1('')
   19 
   20 DOCUMENT();
   21 loadMacros("PG.pl",
   22            "PGbasicmacros.pl",
   23            "PGchoicemacros.pl",
   24            "PGanswermacros.pl",
   25            "PGauxiliaryFunctions.pl",
   26            );
   27 
   28 ##Hack around evaluation problem
   29 sub calleval {
   30    my ($ans_evaluator,$student_answer) = @_;
   31    my $rh_ans_hash = "";
   32    if  ( ref($ans_evaluator) eq 'AnswerEvaluator' ) { # new style
   33             $rh_ans_hash = $ans_evaluator->evaluate($student_answer);
   34    } elsif (ref($ans_evaluator) eq  'CODE' )     { #old style
   35             $rh_ans_hash = &$ans_evaluator($student_answer);
   36    } else {
   37             warn "There is a problem using the answer evaluator";
   38    }
   39    return $rh_ans_hash;
   40 }
   41 
   42 ## Do NOT show partial correct answers
   43 $showPartialCorrectAnswers = 0;
   44 
   45 ## Lots of set up goes here
   46 $root1 = 0;
   47 $root2 = random(1,15);
   48 $function1 = "exp($root1*t)";
   49 $function2 = "exp($root2*t)";
   50 
   51 ## Ok, we are ready to begin the problem...
   52 ##
   53 TEXT(beginproblem());
   54 
   55 
   56 BEGIN_TEXT
   57 Find the general solution to the homogeneous differential equation
   58 \[
   59     \frac{d^2y}{dt^2} - \{$root1 + $root2\}\frac{dy}{dt}  = 0
   60 \]
   61 $BR
   62 The solution has the form
   63 \[y = C_1 f_1(t) + C_2 f_2(t)\] with
   64 \(f_1(t) = \) \{NAMED_ANS_RULE(first_fcn,25)\}
   65 and \(f_2(t) = \) \{NAMED_ANS_RULE(second_fcn,25)\}
   66 $BR
   67 Left to your own devices, you will probably write down the correct
   68 answers, but in case you want to quibble, enter your answers so that
   69 \(f_1, f_2\) are normalized with their value at \(t = 0\) equal to
   70 1.
   71 
   72 END_TEXT
   73 
   74 ($ans_eval1) = num_cmp(exp($root1));             ## Value of $function1 at t = 1
   75 $firstAnswer = $inputs_ref->{first_fcn};         ## Grab the first answer entered by student
   76 $firstAnswer = '' unless defined($firstAnswer);  ## Make sure it is defined
   77 $firstAnswer =~ s/t/(1)/g;                       ## Globally substitute (1) for t in $firstAnswer
   78 $rh_ans_hash = &calleval($ans_eval1,$firstAnswer);        ## Check first answer against given
   79 
   80 
   81 ## Check answers accordingly
   82 if ( $rh_ans_hash->{score} == 1 )
   83 {
   84     NAMED_ANS(first_fcn, fun_cmp($function1, vars=>['t']) );
   85     NAMED_ANS(second_fcn, fun_cmp($function2, vars=>['t']) );
   86 }
   87 else
   88 {
   89     NAMED_ANS(first_fcn, fun_cmp($function2, vars=>['t']) );
   90     NAMED_ANS(second_fcn, fun_cmp($function1, vars=>['t']) );
   91 }
   92 
   93 ENDDOCUMENT();
   94 
   95 
   96 
   97 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9