##DESCRIPTION ## Algebra: Lines ##ENDDESCRIPTION ##KEYWORDS('Algebra', 'Lines') ##Tagged by up2p ##DBsubject('Algebra') ##DBchapter('Coordinates and Graphs') ##DBsection('Lines') ##Date('') ##Author('') ##Institution('Rochester') ##TitleText1('') ##EditionText1('') ##AuthorText1('') ##Section1('') ##Problem1('') DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "PGgraphmacros.pl", "extraAnswerEvaluators.pl" ); TEXT(beginproblem()); \$showPartialCorrectAnswers = 0; # Define the graph \$graph = init_graph(-10,-10,10,10,'axes'=>[0,0],'grid'=>[20,20],'size'=>[300,300]); # create a scrambled list of colors and letters. # Here are the basic colors @colors = ("blue", "red", "green"); # Slice will contain the numbers 1,2,3 in some permuted order @slice = NchooseK(3,3); # The slice of the color list (sc) contains the colors in a new order defined by the ordering in @slice. # This construction @array[@slice] is the way to apply a permutation to a list. @sc = @colors[@slice]; #scrambled colors # Now we scrambel the letters labeling the graphs using the same permutation. # These list will contain the correct answers in the proper order. @sa = ('L1','L2','L3')[@slice]; # Now that we have permuted colors in @sc and permuted letters in @sa we are ready to define the function. \$dom = 10; \$a=random(0.2,2, .1); \$b=random(-4, -2, .5); \$c=random(-2,-0.2,0.1); \$d=random(4,7, .5); \$e=random(\$b-\$a+1, -.5); \$f = FEQ("\$a x + \$b for x in <-\$dom,\$dom> using color:\$sc[0] and weight:2"); \$f1 = FEQ("\$c x+\$d for x in <-\$dom,\$dom> using color=\$sc[1] and weight:2"); \$f2 = FEQ("\$e for x in <-\$dom,\$dom> using color=\$sc[2] and weight=2"); # Install the functions into the graph object. # Plot_functions converts the string to a subroutine which performs the necessary calculations and # asks the graph object to plot the functions. (\$fRef,\$f1Ref,\$f2Ref) = plot_functions( \$graph, \$f,\$f1,\$f2 ); # The output of plot_functions is a list of pointers to functions which contain the appropriate data and methods. # So \$fpRef->rule points to the method which will calculate the value of the function. # &{\$fpRef->rule}(3) calculates the value of the function at 3. See Fun.pm for more details. # create labels for each function # The 'left' tag determines the justification of the label to the defining point. \$label_point=-1; \$label_f = new Label ( \$label_point,&{\$fRef->rule}(\$label_point),\$sa[0],\$sc[0],'left') ; # NOTE: \$fRef->ruleis a reference to the subroutine which calculates the # function. It was defined in the output of plot_functions. It is used here to calculate the y value of the label corresponding to the function, # and below to find the y values for the labels corresponding to the # first and second derivatives. \$label_f1 = new Label ( \$label_point,&{\$f1Ref->rule}(\$label_point),\$sa[1],\$sc[1],'left','bottom') ; # Place the second letter in the permuted letter list at the point (-.75, f1(-.75)) using # the second color in the permuted color list. \$label_f2 = new Label ( \$label_point,&{\$f2Ref->rule}(\$label_point),\$sa[2],\$sc[2],'left'); # insert the labels into the graph \$graph->lb(\$label_f,\$label_f1,\$label_f2); # Make a new match list \$ml = new_match_list(); # enter questions and matching answers \$ml -> qa ( "The slope of line \(\$sa[0]\)", "\( m=\$a \)", "The slope of line \(\$sa[1]\)", "\( m=\$c \)", "The slope of line \(\$sa[2]\)", "\( m=0 \)" ); # Choose four of the question and answer pairs at random. \$ml ->choose(3); # Now print the text using \$ml->print_q for # the questions and \$ml->print_a to print the answers. BEGIN_TEXT \$BR \{ image(insertGraph(\$graph), width=>300, height=>300) \} \$PAR Match the Lines L1 (blue), L2 ( red) and L3 (green) with the slopes by placing the letter of the slopes next to each set listed below: \$BR \{ \$ml -> print_q \} \$PAR \{\$ml -> print_a \} END_TEXT ANS(str_cmp( \$ml->ra_correct_ans ) ) ; ENDDOCUMENT(); # This should be the last executable line in the problem.