[system] / trunk / webwork / courses / demoCourse / templates / set0 / prob1b.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/webwork/courses/demoCourse/templates/set0/prob1b.pg

Revision 466 - (download) (annotate)
Fri Aug 16 20:10:58 2002 UTC (10 years, 9 months ago) by gage
File size: 3530 byte(s)
More files for demoCourse


    1 ##DESCRIPTION
2 ##  help for leaning precedence
3 ##ENDDESCRIPTION
4
5 ##KEYWORDS('functions')
6
7 DOCUMENT();        # This should be the first executable line in the problem.
8
9 loadMacros(
10 "PG.pl",
11 "PGbasicmacros.pl",
12 "PGchoicemacros.pl",
13 "PGanswermacros.pl",
14 "PGauxiliaryFunctions.pl"
15 );
16
17 TEXT(&beginproblem);
18 $showPartialCorrectAnswers = 1; 19 20 21 BEGIN_TEXT 22 This problem will help you learn the rules of precedence, i.e. the order in which 23 mathematical operations are preformed. You can use parentheses (and also square brackets 24 [ ] and/or curly braces$LB $RB) if you want to change the normal way operations work.$PAR
25
26 So first let us review the normal way operations are performed.$PAR 27 28 The rules are simple. Exponentiation is always done before multiplication 29 and division and multiplication and division are always done before addition 30 and subtraction. (Mathematically we say exponentiation takes precedence over 31 multiplication and division, etc.). For example what is 1+2*3?$BR
32 \{ ans_rule(25) \}
33 END_TEXT
34
35 $ans = 7; 36 &ANS(std_num_cmp($ans));
37
38
39 BEGIN_TEXT
40 $BR and what is $$2\cdot 3^2$$?$BR
41 \{ ans_rule(25) \}
42 END_TEXT
43
44 $ans = 2*3**2; 45 &ANS(std_num_cmp($ans));
46
47 BEGIN_TEXT
48
49 $BR 50 Now sometime you want to force things to be done in a different way. This is 51 what parentheses are used for. The rule is: whatever is enclosed in 52 parentheses is done before anything else (and things in the inner most 53 parentheses are done first). 54 55 For example how do you enter $\frac {1+\sin(3)}{2+\tan(4)}$? Hint: this is a good place to use 56 [ ]'s and also to use the${LQ}Preview${RQ} button.$BR
57 \{ ans_rule(25) \}
58 END_TEXT
59
60 $ans = (1+sin(3))/(2+tan(4)) ; 61 &ANS(std_num_cmp($ans));
62
63 BEGIN_TEXT
64 $BR 65 Here are some more examples: 66 67 (1+3)9 =36, (2*3)**2 = 6**2 = 36, 3**(2*2) = 3**4 = 81, (2+3)**2 = 5**2 = 25, 3**(2+2) = 3**4 = 81 68 69$BR
70 (Here we have used ** to denote exponentiation and you can also use this instead of a ${LQ}caret${RQ} if you want).  Try entering some of these and use the "Preview" button to see the result.  The "correct"
71 result for this answer blank is 36, but by using the ${LQ}Preview${RQ} button, you can enter whatever
72 you want and use WeBWorK as a hand calculator.$BR 73 \{ ans_rule(25) \} 74 75 END_TEXT 76 77$ans =36;
78
79 &ANS(std_num_cmp($ans)); 80 81 BEGIN_TEXT 82$BR
83
84 There is one other thing to be careful of.  Multiplication and division have the
85 same precedence and there are no universal rules as to which should be done first.
86 For example, what does 2/3*4 mean?  (Note that / is the "division symbol", which
87 is usually written as a line with two dots, but unfortunately, this "line with
88 two dots" symbol is not on computer keyboards. Don't think of / as the horizontal
89 line in a fraction. Ask yourself what 1/2/2 should mean.) WeBWorK and most other
90 computers read things from left to right, i.e. 2/3*4 means (2/3)*4 or 8/3, IT DOES
91 NOT MEAN 2/12.  Some computers may do operations from right to left.  If you
92 want 2/(3*4) = 2/12, you have to use parentheses.  The same thing happens with
93 addition and subtraction. 1-3+2 = 0 but 1-(3+2) = -4. This is one case where using
94 parentheses even if they are not needed might be a good idea, e.g. write (2/3)*4
95 even though you could write 2/3*4. This is also a case where previewing your answer
96 can save you a lot a grief since you will be able to see what you entered.
97
98 $BR 99 Enter 2/3*4 and use the Preview button to see what you get.$BR
100 \{ ans_rule(25) \}
101 END_TEXT
102
103 $ans = 8/3; 104 &ANS(std_num_cmp($ans));
105
106 ENDDOCUMENT();        # This should be the last executable line in the problem.


 aubreyja at gmail dot com ViewVC Help Powered by ViewVC 1.0.9