[rochester] / trunk / rochester_problib / setDiffEQ13Systems1stOrder / ur_de_13_6.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/rochester_problib/setDiffEQ13Systems1stOrder/ur_de_13_6.pg

Wed Jul 30 18:51:19 2003 UTC (9 years, 9 months ago) by voloshin
File size: 4787 byte(s)
```fixed displaying matrices
```

```    1 ## DESCRIPTION
2 ##  ## Differential equations
3 ##  ay'' + by' + cy =  0,
4 ##  \$b =0,\$a,\$c integers
6 ##
7 ## ENDDESCRIPTION
8
9 # Description
10 # The first example using match lists
11 # EndDescription
12
13
14 DOCUMENT();        # This should be the first executable line in the problem.
15
17            "PGbasicmacros.pl",
18            "PGchoicemacros.pl",
20            "PGgraphmacros.pl",
21            "PGnumericalmacros.pl",
22            "PGmatrixmacros.pl"
23            );
24
25 # TEXT( ... , ... , )
26 # Is the simplest way of printing text, each string in the input is immediately printed.
27 # It does not do any of the simplifying and evaluating tricks performed by the BEGIN_TEXT/END_TEXT construction.
28
29 # beginproblem() is a macro which outputs the string
30 # which contains the number
31 # of points the problem is worth.
32
33 # Putting these two ideas together prints the standard opening line of a problem.
34 # We will use this construction routinely at the beginning of all subsequent problems.
35
36 TEXT(beginproblem());
37
38 # Since this is a matching questions, we do not usually wish to tell students which
39 # parts of the matching question have been answered correctly and which are
40 # incorrect.  That is too easy.  To accomplish this we set the following flag to zero.
41
43
44 # Make a new match list
45
46 \$ml = new_match_list();
47
48 # \$ml ->rf_print_a(~~&print_eqn_a);
49 # \$ml now "contains" the match list object.  (Actually \$ml is a scalar variable which contains a pointer to
50 # the match list object, but you can think of the match list object as being shoe horned into the variable \$ml.
51 # You need to remember that \$ml contains (a pointer to) an object, and not ordinary data such as a number or string.
52
53 # Some people use the convention \$o_ml to remind them that the variable contains an object, but for short problems
54 # that is probably not necessary.
55
56 # An object contains both data (in this case the list of questions and answers) and subroutines (called methods)
57 # for manipulating that data.
58
59 # Insert some  questions and matching answers in the q/a list by calling on the objects qa method.
60 # using the construction \$ml ->qa(..list of alternating questions and matching answers ...).
61 # Think of this as asking the object \$ml to store the  matching questions
62 # and answers given in the argument to the method qa.
63
64 #1    #####
65 \$ml -> qa (
66 mbox( "\(y'(t)=\)", display_matrix([[15, 0, 0], [4, 20, -15], [4, 30, -25]]), "\(y(t)\)" ),
67 \$BR.mbox( "\(y(t)=\)", display_matrix([[0], [1], [1]]), "\( e^{5 t}\)" )
68 );
69
70 #2    #################
71 \$ml -> qa (
72 mbox( "\(y'(t)=\)", display_matrix([[-32, 49, -23], [-64, 78, -34], [64, -78, 34]]), "\(y(t)\)" ),
73 \$BR.mbox( "\(y(t)=\)", display_matrix([[-1], [-3], [-5]]) )
74
75 );
76
77 #3   #########################
78 \$ml -> qa (
79 mbox( "\(y'(t)=\)", display_matrix([[14, 0, -4], [2, 13, -8], [-3, 0, 25]]), "\(y(t)\)" ),
80 \$BR.mbox( "\(y(t)=\)", display_matrix([[4], [5], [1]]), "\(e^{13 t}\)" )
81 );
82
83 #4    #########################
84 \$ml -> qa (
85 mbox( "\(y'(t)=\)", display_matrix([[-13, -2, 3], [-15, -18, 5], [-33, -18, 7]]), "\(y(t)\)" ),
86 \$BR.mbox( "\(y(t)=\)", display_matrix([[-1], [0], [-3]]), "\(e^{-4 t}\)" )
87 );
88
89 #5    #########################
90 \$ml -> qa (
91 mbox( "\(y'(t)=\)", display_matrix([[-97, 33, -5], [-140, 84, 35], [-4, 15, -8]]), "\(y(t)\)" ),
92 \$BR.mbox( "\(y(t)=\)", display_matrix([[-2], [-4], [4]]), "\(e^{-21 t}\)" )
93 );
94
95 #6    #########################
96 \$ml -> qa (
97 mbox( "\(y'(t)=\)", display_matrix([[-2, 0, 0], [0, -2, 0], [0, 0, -2]]), "\(y(t)\)" ),
98 \$BR.mbox( "\(y(t)=\)", display_matrix([[2], [2], [0]]), "\(e^{-2 t}\)" )
99 );
100
101 #7    #########################
102 \$ml -> qa (
103 mbox( "\(y'(t)=\)", display_matrix([[-86, 218, -160], [73, -49, 80], [111, -138, 165]]), "\(y(t)\)" ),
104 \$BR.mbox( "\(y(t)=\)", display_matrix([[-2], [1], [3]]), "\(e^{45 t}\)" )
105 );
106
107 ##########################
108
109 # Choose two of the question and answer pairs at random.
110 \$ml ->choose(3);  # Using choose(3) would choose all three questions, but the order of the questions and answers would be
111                   # scrambled.
112
113
114 # Now print the text using \$ml->print_q for the questions and \$ml->print_a to print the answers.
115
116 BEGIN_TEXT
117
118 Match the differential equations and their vector valued function solutions: \$BR
119 It will be good practice to multiply at least one solution out fully, to make sure that you
120 know how to do it, but you can get the other answers quickly by process of elimination and
121 just multiply out one row element.
122 \$BR\$BR
123 \{ \$ml -> print_q \}
124 \$BR
125 \{ \$ml -> print_a \}
126
127 END_TEXT
128
129 # Enter the correct answers to be checked against the answers to the students.
130
131 ANS( str_cmp( \$ml->ra_correct_ans )   ) ;
132
133 # That's it.
134
135 ENDDOCUMENT() ;
136
137
138
139
140
141
142
```