[npl] / branches / NAU / setLinearModeling / linearmodeling3.pg Repository:
ViewVC logotype

View of /branches/NAU/setLinearModeling/linearmodeling3.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1894 - (download) (annotate)
Sat Jun 25 00:53:16 2011 UTC (22 months, 4 weeks ago) by nandor.sieben
File size: 2645 byte(s)
upload

    1 ##DESCRIPTION
    2 ## DBsubject('Algebra')
    3 ## DBchapter('Functions')
    4 ## DBsection('Modeling with Functions')
    5 ## KEYWORDS('word problem')
    6 ## Author('N.Spencer Sitton')
    7 ## Institution('NAU')
    8 ##ENDDESCRIPTION
    9 
   10 # File Created: 06/20/05
   11 # Location: Northern Arizona University
   12 # Course:Quantitative Reasoning
   13 
   14 DOCUMENT();
   15 loadMacros("PGstandard.pl",
   16            "unionMacros.pl",
   17      "unionTables.pl",
   18      "PGchoicemacros.pl"
   19 );
   20 
   21 TEXT(&beginproblem);
   22 
   23 @list = ( 1, 2, 3, 4, 5);
   24 $a = list_random(2,3,4);
   25 
   26 do{$b =non_zero_random(-5,5,1);
   27 } until( $b != 1 && $b != -1);
   28 
   29 $c = non_zero_random(-9,9,1);
   30 
   31 do{$d =non_zero_random(-5,5,1);
   32 } until( $d != 1 );
   33 
   34 $e = list_random( -5, -4, -3, -2, 2, 3, 4, 5);
   35 
   36 do{$f= list_random( 2, 3, 4, 5);
   37 } until($e != $f);
   38 
   39 foreach $val(@list){
   40   $newval = $val ** $a;
   41   push @list1, $newval;
   42 } push @list1, '...';
   43 
   44 foreach $val(@list){
   45   $newval =$b*$val;
   46   push @list2, $newval;
   47 } push @list2, '...';
   48 
   49 foreach $val(@list){
   50   $newval = $d * $val + $c;
   51   push @list3, $newval;
   52 } push @list3, '...';
   53 
   54 for( $i = 0; $ i < 5; $i++){
   55   $newval = $e ** $i;
   56   push @list4, $newval;
   57 } push @list4, '...';
   58 
   59 @list5 = ( non_zero_random( -5, 5, 1 ));
   60 
   61 for( $i = 1; $ i < 5; $i++){
   62   $newval = $list5[$i - 1] + $i ;
   63   push @list5, $newval;
   64 } push @list5, '...';
   65 
   66 $z = non_zero_random( -2, 2, 1 );
   67 $y = non_zero_random( -4, 4, 1 );
   68 
   69 for( $i = 0; $ i < 5; $i++){
   70   $newval = $z*( $f ** $i );  # + $y;
   71   push @list6, $newval;
   72 } push @list6, '...';
   73 
   74 @lists = (( join ", ", @list1 ), ( join ", ", @list2 ), ( join ", ", @list3 ) ,( join ", ", @list4 ), ( join ", ", @list5 ), ( join ", ", @list6 ) );
   75 @ans = ( 'neither', 'linear', 'linear', 'exponential', 'neither', 'exponential');
   76 @slice = NchooseK( 6, 6 );
   77 
   78 push @row1, 'sequence', 'classification';
   79 push @row2, $lists[$slice[0]], ans_rule(20);
   80 push @row3, $lists[$slice[1]], ans_rule(20);
   81 push @row4, $lists[$slice[2]], ans_rule(20);
   82 push @row5, $lists[$slice[3]], ans_rule(20);
   83 push @row6, $lists[$slice[4]], ans_rule(20);
   84 push @row7, $lists[$slice[5]], ans_rule(20);
   85 
   86 BEGIN_TEXT
   87 
   88 The following numbers represent values of the dependent variable that
   89 corresponds to equally spaced values of the independent variable.
   90 Classify these sequences as linear, exponential or neither:$PAR
   91 \{begintable(3)\}
   92 \{row(@row1)\}
   93 \{row(@row2)\}
   94 \{row(@row3)\}
   95 \{row(@row4)\}
   96 \{row(@row5)\}
   97 \{row(@row6)\}
   98 \{row(@row7)\}
   99 \{endtable()\}
  100 
  101 END_TEXT
  102 
  103 ANS( str_cmp( $ans[$slice[0]] ) );
  104 ANS( str_cmp( $ans[$slice[1]] ) );
  105 ANS( str_cmp( $ans[$slice[2]] ) );
  106 ANS( str_cmp( $ans[$slice[3]] ) );
  107 ANS( str_cmp( $ans[$slice[4]] ) );
  108 ANS( str_cmp( $ans[$slice[5]] ) );
  109 
  110 ENDDOCUMENT();

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9