[system] / trunk / pg / macros / parserDifferenceQuotient.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/parserDifferenceQuotient.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5372 Revision 5373
3 3
4sub _parserDifferenceQuotient_init {}; # don't reload this file 4sub _parserDifferenceQuotient_init {}; # don't reload this file
5 5
6=head1 DESCRIPTION 6=head1 DESCRIPTION
7 7
8###################################################################### 8 ######################################################################
9# 9 #
10# This is a Parser class that implements an answer checker for 10 # This is a Parser class that implements an answer checker for
11# difference quotients as a subclass of the Formula class. The 11 # difference quotients as a subclass of the Formula class. The
12# standard ->cmp routine will work for this. The difference quotient 12 # standard ->cmp routine will work for this. The difference quotient
13# is just a special type of formula with a special variable 13 # is just a special type of formula with a special variable
14# for 'dx'. The checker will give an error message if the 14 # for 'dx'. The checker will give an error message if the
15# student's result contains a dx in the denominator, meaning it 15 # student's result contains a dx in the denominator, meaning it
16# is not fully reduced. 16 # is not fully reduced.
17# 17 #
18# Use DifferenceQuotient(formula) to create a difference equation 18 # Use DifferenceQuotient(formula) to create a difference equation
19# object. If the context has more than one variable, the last one 19 # object. If the context has more than one variable, the last one
20# alphabetically is used to form the dx. Otherwise, you can specify 20 # alphabetically is used to form the dx. Otherwise, you can specify
21# the variable used for dx as the second argument to 21 # the variable used for dx as the second argument to
22# DifferenceQuotient(). You could use a variable like h instead of 22 # DifferenceQuotient(). You could use a variable like h instead of
23# dx if you prefer. 23 # dx if you prefer.
24# 24 #
25# Usage examples: 25 # Usage examples:
26# 26 #
27# $df = DifferenceQuotient("2x+dx"); 27 # $df = DifferenceQuotient("2x+dx");
28# ANS($df->cmp); 28 # ANS($df->cmp);
29# 29 #
30# $df = DifferenceQuotient("2x+h","h"); 30 # $df = DifferenceQuotient("2x+h","h");
31# ANS($df->cmp); 31 # ANS($df->cmp);
32# 32 #
33# Context()->variables->are(t=>'Real',a=>'Real'); 33 # Context()->variables->are(t=>'Real',a=>'Real');
34# ANS(DifferenceQuotient("-a/[t(t+dt)]","dt")->cmp); 34 # ANS(DifferenceQuotient("-a/[t(t+dt)]","dt")->cmp);
35# 35 #
36 36
37=cut 37=cut
38 38
39Context("Numeric"); 39Context("Numeric");
40 40
72 my ($value,$err) = main::PG_restricted_eval('$__student_value__->substitute(\''.$dx.'\'=>0)->reduce'); 72 my ($value,$err) = main::PG_restricted_eval('$__student_value__->substitute(\''.$dx.'\'=>0)->reduce');
73 $self->cmp_Error($ans,"It looks like you didn't finish simplifying your answer") 73 $self->cmp_Error($ans,"It looks like you didn't finish simplifying your answer")
74 if $err && $err =~ m/division by zero/i; 74 if $err && $err =~ m/division by zero/i;
75} 75}
76 76
771;

Legend:
Removed from v.5372  
changed lines
  Added in v.5373

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9