## DESCRIPTION ## Introduction to WeBWorK ## ENDDESCRIPTION ## KEYWORDS('functions', 'enter numerical answers') ## Tagged by XW ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('WeBWorK Tutorial') ## Date('') ## Author('') ## Institution('ASU') ## 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" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; $a = random(-10,-1,1); $b = random(1,11,1); $c = random(1,11,1); $d = random(1,11,1); BEGIN_TEXT This problem set demonstrates how you enter numerical answers into WeBWorK. $PAR In these problems you need to enter a number, since we're checking whether you can does these calculations. Do the calculation, then enter the correct numerical result in the box provided. $PAR $BBOLD Warning: $EBOLD While you might use a calculator here, you may not be allowed a calculator on some of your tests. $PAR END_TEXT BEGIN_TEXT $HR $PAR Evaluate the expression \(0($a)(-2($d ))\): \{ ans_rule(5) \} $PAR END_TEXT $ans = 0*($a)*(-2*($d)) ; ANS(num_cmp($ans, mode=>"strict")) ; BEGIN_TEXT $HR $PAR Evaluate the expression \( $a ($b )($c + $d) \): \{ ans_rule(10) \} $PAR END_TEXT $ans = $a * $b *($c + $d) ; ANS(num_cmp($ans, mode=>"strict")) ; BEGIN_TEXT $HR $PAR Evaluate the expression \( ($a + $b )($c + 12 ($d)) \): \{ ans_rule(5) \} $PAR END_TEXT $ans = ($a + $b )*($c + 12 * $d) ; ANS(num_cmp($ans, mode=>"strict")) ; BEGIN_TEXT $PAR $HR $PAR For some problems, you will be able to get WeBWorK to do some of the work for you. $PAR For example, calculate ($a) * ($b): \{ ans_rule()\} $PAR END_TEXT $ans = $a*$b; ANS(num_cmp($ans)); BEGIN_TEXT $PAR The asterisk is how most calculators and computers show multiplication and you can use this with WeBWorK. But WeBWorK will also allow you to use a space to show multiplication. You can either \($a * $b\) or \{$a*$b\}. All will work. Try them. $PAR $HR $PAR Now try calculating $SPACE \( \sqrt{7}\)$SPACE, the square root of 7. $PAR You can enter this as sqrt(7), or as 7$CARET(1/2). This is because WeBWorK knows about standard calculations like square root, and that roots can be represented using fractional exponents. You'll study this in detail very shortly. $PAR Note, exponents can be entered with either a $CARET (caret) or ** (two asterisks). Try it in the box below. $PAR \( \sqrt{7} = \) \{ ans_rule(20) \} $PAR $HR $PAR END_TEXT ANS(num_cmp("sqrt(7)") ); BEGIN_TEXT When it is very clear that only multiplication is involved, you can simpley write two characters together $PAR E.g., enter the square root of 5 divided 3. You can enter this as 2*sqrt(5/3) or more simply as 2sqrt(5/3). Try it: $PAR \( 2\sqrt{5/3} = \) \{ ans_rule(20) \} $PAR END_TEXT ANS(num_cmp("2*sqrt(5/3)") ); BEGIN_TEXT $PAR $HR $PAR Think about the problem above. How sure are you that we should divide 5 by 3 then take the square root. If we are verablizing the process, we could say "divide 5 by 3 then take the square root of the result." It is a little longer to say, but very clear. In written math (symbology) sometimes you need to use ( )'s to make your meaning clear. $PAR E.g. 1/2+3 is 3.5, but 1/(2+3) is .2 Why? Try entering both and use the ${LQ}Preview${RQ} button below to see the difference. In addition to ( )'s, you can also use [ ]'s and \(\lbrace \rbrace\). $PAR \( (1/2) + 3 = \)\{ ans_rule(20) \} $PAR Now go back to the previous problem and enter 2sqrt5/3 instead of 2sqrt(5/3). Use the ${LQ}Preview${RQ} button to see how WeBWorK interprets the symbology. END_TEXT ANS(num_cmp(3.5)); BEGIN_TEXT $PAR $HR $PAR When entering numbers, leave off units (or dollar signs for money) unless the problem directs you to do otherwise. $PAR For example, if we want to know how much money you will have if you collect $DOLLAR 100 from 200 people, the answer is $DOLLAR 20,000. $PAR When entering this value, you should just give 20000 (or 100*200). $PAR When doing WeBWorK problems alsways look "outside the (answer) box." If the problems has units associated, they are usually provided. Don't include the stuff already provided outside the box! $PAR $DOLLAR 100 from 200 people yields $DOLLAR \{ ans_rule(20) \} $PAR $HR $PAR You can always try to enter answers and let WeBWorK do the calculating. After a little experience, you may find that the WeBWorK preview lets you "see" the answer you would type into your calculator in the same form as a textbook or a correctly expression. It is a great way to find mistakes like omitted parentheses or incorrect grouping. $PAR Or, if you have trouble with the syntax while entering expressions, you can compute most answers on yourself then type the answer into WeBWorK. If you do, just be sure to include lots of decimal places (including the first 5 non-zero places should be safe). $PAR $BBOLD In general, there is no penalty for getting an answer wrong.$EBOLD If you are limited in the number of attempts you get for a problem, you will be warned by the problem itself (this could happen, for example, on a true/false question). What counts is that you get the answer right before the due date. $PAR $BBOLD However, $EBOLD even though you get a "correct" from WeBWorK, if that answer comes from an invalid mathematical process (in relation to your problem), your instructor will almost certainly catch it in written work! Be certain you understand the process and can write the steps for each problem answered in correctly. $PAR $BBOLD Remember: $EBOLD For complicated answers you should use the ${LQ}Preview${RQ} button to check for syntax errors and also to check that the answer you enter is really what you think it is. END_TEXT ANS(num_cmp("100*200")); ENDDOCUMENT(); # This should be the last executable line in the problem. ________________________________________________________________________________ ## DESCRIPTION ## Introduction to WeBWorK ## ENDDESCRIPTION ## KEYWORDS('functions', 'enter functions') ## Tagged by XW ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('WeBWorK Tutorial') ## Date('') ## Author('') ## Institution('ASU') ## 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" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; BEGIN_TEXT This problem demonstrates how you enter function answers into WeBWorK. $PAR First enter the absolute value of -7 in the box below. $PAR \{ans_rule(35) \} $PAR When entering the answer, you should just enter the value 7. But WeBWorK will also accept abs -7 or even abs-7. $PAR $BBOLD Warning:$EBOLD WeBWorK will accept this or any other value equal to abs(-7), e.g. 7, or 14/2, or sqrt(49). However your instructor is almost certain to notice one of those incorrect ways of getting to a correct answer on a written assignment! END_TEXT $ans = "abs(-7)"; ANS(fun_cmp($ans, limits=>[[0.2, 100]])); BEGIN_TEXT $PAR $HR $PAR It is better to enter abs(x), even though WeBWorK will also accept abs x or even absx, because you are less likely to make a mistake. Try entering abs(2x) without the parentheses and you may be surprised at what you get. Use the Preview button to see what you get. $PAR WeBWorK will evaluate standard calculations (such as abs or sqrt) before doing anything else, so abs 2x means first find the absolute value of 2 which gives abs(2) and then multiply by x. $PAR Try it. \{ans_rule(35) \} END_TEXT $ans = "abs(2*x)"; ANS(fun_cmp($ans, limits=>[[0.2, 100]])); BEGIN_TEXT $PAR $HR $PAR Now enter the calculation \(2\sqrt{ t}\) using 2sqrt(t). \{ans_rule(35) \} $PAR Note this uses the variable \(t\) and not \(x\). Try entering 2sqrt(x) and see what happens. Be carful to read the error statements in WeBWorK. They are trying to tell you where you made an error. $PAR When WeBWork says an answer doesn't \(parse\) correctly, that is it's overly computerish way of saying the answer doesn't fit the problem. It will also try to warn you that a parenthesis or some other closing symbol is missing. $PAR $BBOLD Here's a tip from the lazy side! $EBOLD If you can highlight a text in a WeBWorK page, you can drag and drop it or copy into the answer box! Try it out. Enter 2sqrt(t) in the box above by highlighting, dragging and dropping. Be careful about picking up extra characters. But if you picked up an improperly placed period or comma, WeBWork will show you the error when you submit your answer. Drag/drop and copy make it much easier to do substitutions in formulas. $PAR END_TEXT $ans = "2*sqrt(t)"; ANS(fun_cmp($ans,var=>'t', limits=>[[0,100]])); ENDDOCUMENT(); # This should be the last executable line the problem. ________________________________________________________________________________ ## DESCRIPTION ## Introduction to WeBWorK ## ENDDESCRIPTION ## KEYWORDS('functions', 'order of operations') ## Tagged by XW ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('WeBWorK Tutorial') ## Date('') ## Author('') ## Institution('ASU') ## 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" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; BEGIN_TEXT This problem will review $BBOLD order of operations,$EBOLD i.e. rules of precedence or order in which mathematical operations are performed. $PAR The rules are simple. Exponentiation is always done before multiplication and division, and multiplication and division are always done before addition and subtraction. (Mathematically we say exponentiation takes precedence over multiplication and division, etc.). For example what is 1+2*3? You can use parentheses (and also square brackets [ ] or curly braces \(\lbrace \rbrace\)) if you want to change the normal way operations work. $PAR $BBOLD Note:$EBOLD You must compute this number before entering it into WeBWorK. $PAR 1+2*3 = \{ ans_rule(25) \} $PAR END_TEXT $ans = 7; ANS(num_cmp($ans, mode=>'strict')); BEGIN_TEXT $BBOLD Note:$EBOLD You must compute this number before entering it into WeBWorK. $PAR What is \( 2\cdot 3^2 \)? \{ ans_rule(25) \} END_TEXT $ans = 2*3**2; ANS(num_cmp($ans, mode=>'strict')); BEGIN_TEXT $PAR $HR $PAR Now sometimes you want to force things to be done in a different way. This is what parentheses are used for. $PAR $BBOLD Rule 1:$EBOLD Groups are simplified first. IE, Whatever is enclosed in parentheses (--), braces {--}, brackets [--], all in a numerator, all in a denominator, within an absolute value symbol |--|, or all under a radical \( \sqrt{x}\) are done before anything else (and things in the inner most parentheses are done first). $PAR For example, simplfy the following expression yourself, then enter the expression in the box below: $PAR \[ \frac {1+|9-3|}{2+\sqrt{49}}\] $PAR $BBOLD Hint: $EBOLD This is a good place to use [ ]'s and also to use the ${LQ}Preview${RQ} button. Also remember, |x| in standard notation is absolute value of x, so you must replace |x| with abs(x). $PAR \{ ans_rule(25) \} END_TEXT $ans = "(1+abs(9-3))/(2+sqrt(49))" ; ANS(num_cmp($ans)); BEGIN_TEXT $PAR $HR $PAR Here are some more examples: (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 $PAR (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" result for this answer blank is 36, but by using the ${LQ}Preview${RQ} button, you can enter whatever you want and use WeBWorK as a hand calculator. $PAR \{ ans_rule(25) \} $PAR $HR $PAR END_TEXT $ans =36; ANS(num_cmp($ans)); BEGIN_TEXT $PAR $BBOLD Rule 2:$EBOLD The correct order of evaluation is > Roots and Powers (Exponents) > Division and Multiplication > Subtractions and Additiion Think! Correct order of operations goes from the hardest stuff (Roots) first to the easiest stuff (Addition) last. $PAR There is one other thing to be careful about. Multiplication and division have the same precedence. For example, what does 2/3*4 mean? (Note that / is the "division symbol", which is sometimes written as a line with two dots. Don't think of / as the horizontal line in a fraction. Ask yourself what 1/2/2 should mean.) $PAR $BBOLD Rule 3:$EBOLD Multiplication and divsion are evaluated from left to right. $PAR Example: 2/3*4 means (2/3)*4 = 8/3, IT DOES NOT MEAN 2/12. If you want 2/(3*4) = 2/12, you have to use parentheses. $PAR $BBOLD Rule 4:$EBOLD Addition and subtraction are evaluated from left to right. $PAR Example: The same thing happens with addition and subtraction as with multiplication and division. Notice 1-3+2 = 0, but 1-(3+2) = -4. $PAR This aare many situations where using parentheses might be a good idea, even if they are not needed $PAR Example: Write (2/3)*4 rather than 2/3*4. This is also a case where previewing your answer can save you a lot a grief since you will be able to see what you entered. $PAR Enter 2/3*4 and use the Preview button to see what you get. $PAR \{ ans_rule(25) \} $PAR END_TEXT $ans = 8/3; ANS(num_cmp($ans)); BEGIN_TEXT $PAR $HR $PAR $BBOLD A Hand-in Assignment $EBOLD $PAR Here's the link to the \{htmlLink(qq! http://webwork.asu.edu/availableFunctions.html!, "list of the functions") \} which WeBWorK understands. WeBWorK ALWAYS uses radian mode for trig functions. $PAR $BBOLD 1. Click on the link. Print out this list and turn it in to your instructor before the due date of this assignment. $PAR 2. On the back of the list of functions, write the rules for the correct order of operations. $PAR 3. Also on the back of the page, calculate the following expression exactly. Show all steps as your apply order of operations. $PAR \[ \frac {3+|9-13|}{2+\sqrt{29-4}}\] $PAR 4. Look up the word "function" in your textbook. Write a defintion for "function" and provide a simple example of the concept. $EBOLD END_TEXT ENDDOCUMENT(); # This should be the last executable line in the problem. ________________________________________________________________________________ ## DESCRIPTION ## Introduction to WeBWorK ## ENDDESCRIPTION ## KEYWORDS('functions', 'enter letters or words', 'true or false questions') ## Tagged by XW ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('WeBWorK Tutorial') ## Date('') ## Author('') ## Institution('ASU') ## 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" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; BEGIN_TEXT This part demonstrates WeBWorK problems where you enter letters or words. We start with a True/False question. $PAR Enter a $BITALIC T $EITALIC or an $BITALIC F $EITALIC in each answer space below to indicate whether the corresponding statement is true or false. $PAR END_TEXT ## First we set up our variables. $a = random(1,5,1); $b = random(6,10,1); $c = random(-10,-1,1); $d = random(-10,-1,1); $e = random(1,10,1); $f = random(5,10,1); $questStr1 = EV2(" \( -$a \lt -$b \) "); $ansStr1 = "F"; $questStr2 = EV2(" \( $c \leq $c \) "); $ansStr2 = "T"; $questStr3 = EV2(" \( $d \lt $d \) "); $ansStr3 = "F"; $questStr4 = EV2(" \( \pi \geq \frac{22}{7} \) ") ; $ansStr4 = "F"; $questStr5 = EV2(" \( \sqrt {$e+3} \geq \sqrt $e + \sqrt 3 \) "); $ansStr5 = "F"; $questStr6 = EV2(" \( \sqrt {$f-3} \geq \sqrt $f - \sqrt 3 \) "); $ansStr6 = "T"; $questStr7 = EV2(" \( \sqrt {$f*$e} \geq \sqrt $e \sqrt $f \) "); $ansStr7 = "T"; @questions =( $questStr1,$questStr2,$questStr3,$questStr4,$questStr5,$questStr6,$questStr7); @answers =( $ansStr1,$ansStr2,$ansStr3,$ansStr4,$ansStr5,$ansStr6,$ansStr7); ## Now choose randomly 5 questions out of the 7 question strings above. @slice = NchooseK(scalar(@questions),5); ## Next we output the 5 chosen questions. # TEXT( &match_questions_list(@questions[@slice]) ); ANS(str_cmp([ @answers[@slice] ] )); TEXT(<WeBWorK can accept a number, mathematical expression or even a complete sentence. In this example you are asked to enter a mathematical expression. It wants you to type in (x+2)^2. You will study this problem in a later lesson.

Consider a function f(x)=x^2. This is the squaring rule. It says "take a number and square it."

If the graph of a new function g(x)is the graph of f(x) shifted to the left 2 units, what is the algebraic expression for the function g(x)?

g(x) = \{ans_rule(20) \} END_TEXT ANS(fun_cmp("(x+2)^2")); ENDDOCUMENT(); # This should be the last executable line the problem.