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

View of /trunk/NationalProblemLibrary/Dartmouth/setStewartCh18S1/problem_8.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: 2808 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 
   46 $alpha = random(1,10);
   47 $beta = random(1,10);
   48 
   49 $function1 = "exp($alpha * t) * cos($beta * t)";
   50 $function2 = "exp($alpha * t) * sin($beta * t)";
   51 
   52 ## Ok, we are ready to begin the problem...
   53 ##
   54 TEXT(beginproblem());
   55 
   56 
   57 BEGIN_TEXT
   58 $BR
   59 Find the general solution to the homogeneous differential equation
   60 \[
   61     \frac{d^2y}{dt^2} - \{2* $alpha\}\frac{dy}{dt} + \{$alpha**2 + $beta**2\}y = 0
   62 \]
   63 $BR
   64 The solution has the form
   65 \[y = C_1 f_1(t) + C_2 f_2(t)\]
   66 with
   67 \(f_1(t) = \) \{NAMED_ANS_RULE(first_fcn,50)\}
   68 and \(f_2(t) = \) \{NAMED_ANS_RULE(second_fcn,50)\}
   69 $BR
   70 
   71 Left to your own devices, you will probably write down the correct
   72 answers, but in case you want to quibble, enter your answers so that
   73 the functions are normalized with their values at \(t = 0\) equal to
   74 0 and 1(respectively), and they are expressed as simply as possible.
   75 
   76 $PAR
   77 END_TEXT
   78 
   79 ($ans_eval1) = num_cmp(exp($alpha* 0) * cos($beta * 0));
   80 ## Value of $function1 at t = 0
   81 $firstAnswer = $inputs_ref->{first_fcn};         ## Grab the first answer entered by student
   82 $firstAnswer = '' unless defined($firstAnswer);  ## Make sure it is defined
   83 $firstAnswer =~ s/t/(0)/g;                       ## Globally substitute (1) for t in $firstAnswer
   84 $rh_ans_hash = &calleval($ans_eval1,$firstAnswer);        ## Check first answer against given
   85 
   86 
   87 ## Check answers accordingly
   88 if ( $rh_ans_hash->{score} == 1 )
   89 {
   90     NAMED_ANS(first_fcn, fun_cmp($function1, vars=>['t']) );
   91     NAMED_ANS(second_fcn, fun_cmp($function2, vars=>['t']) );
   92 }
   93 else
   94 {
   95     NAMED_ANS(first_fcn, fun_cmp($function2, vars=>['t']) );
   96     NAMED_ANS(second_fcn, fun_cmp($function1, vars=>['t']) );
   97 }
   98 
   99 ENDDOCUMENT();
  100 
  101 
  102 
  103 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9