

1  =head1 NAME 


2  


3  parserDifferenceQuotient.pl  An answer checker for difference quotients. 


4  


5  =head1 DESCRIPTION 


6  


7  This is a Parser class that implements an answer checker for 


8  difference quotients as a subclass of the Formula class. The 


9  standard >cmp routine will work for this. The difference quotient 


10  is just a special type of formula with a special variable 


11  for 'dx'. The checker will give an error message if the 


12  student's result contains a dx in the denominator, meaning it 


13  is not fully reduced. 


14  


15  Use DifferenceQuotient(formula) to create a difference equation 


16  object. If the context has more than one variable, the last one 


17  alphabetically is used to form the dx. Otherwise, you can specify 


18  the variable used for dx as the second argument to 


19  DifferenceQuotient(). You could use a variable like h instead of 


20  dx if you prefer. 


21  


22  Usage examples: 


23  


24  $df = DifferenceQuotient("2x+dx"); 


25  ANS($df>cmp); 


26  


27  $df = DifferenceQuotient("2x+h","h"); 


28  ANS($df>cmp); 


29  


30  Context()>variables>are(t=>'Real',a=>'Real'); 


31  ANS(DifferenceQuotient("a/[t(t+dt)]","dt")>cmp); 


32  


33  =cut 
1  
34  
2  loadMacros('MathObjects.pl'); 
35  loadMacros('MathObjects.pl'); 
3  
36  
4  sub _parserDifferenceQuotient_init {DifferenceQuotient::Init()}; # don't reload this file 
37  sub _parserDifferenceQuotient_init {DifferenceQuotient::Init()}; # don't reload this file 
5  


6  =head1 DESCRIPTION 


7  


8  ###################################################################### 


9  # 


10  # This is a Parser class that implements an answer checker for 


11  # difference quotients as a subclass of the Formula class. The 


12  # standard >cmp routine will work for this. The difference quotient 


13  # is just a special type of formula with a special variable 


14  # for 'dx'. The checker will give an error message if the 


15  # student's result contains a dx in the denominator, meaning it 


16  # is not fully reduced. 


17  # 


18  # Use DifferenceQuotient(formula) to create a difference equation 


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 


21  # the variable used for dx as the second argument to 


22  # DifferenceQuotient(). You could use a variable like h instead of 


23  # dx if you prefer. 


24  # 


25  # Usage examples: 


26  # 


27  # $df = DifferenceQuotient("2x+dx"); 


28  # ANS($df>cmp); 


29  # 


30  # $df = DifferenceQuotient("2x+h","h"); 


31  # ANS($df>cmp); 


32  # 


33  # Context()>variables>are(t=>'Real',a=>'Real'); 


34  # ANS(DifferenceQuotient("a/[t(t+dt)]","dt")>cmp); 


35  # 


36  


37  =cut 


38  
38  
39  package DifferenceQuotient; 
39  package DifferenceQuotient; 
40  our @ISA = qw(Value::Formula); 
40  our @ISA = qw(Value::Formula); 
41  
41  
42  sub Init { 
42  sub Init { 