WeBWorK Problems
https://webwork.maa.org/moodle/mod/forum/view.php?f=3
The wiki and forum systems have changed encryption methods and some passwords need to be reset. If you can't login: first set (or reset) your password on the wiki (you can use the "forgot password" link). Make sure to complete the process to set a "new" permanent password. Then use that permanent password for moodle as well as the wiki.
Questions and comments related to WeBWorK problems, problem authoring, etc.Moodleen(c) 2021 WeBWorK: Online homework for math and sciencehttps://webwork.maa.org/moodle/theme/image.php/classic/core/1584125254/i/rsssitelogomoodle
https://webwork.maa.org/moodle
14035Currency context display options
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5024&parent=15426
Tue, 16 Feb 2021 20:03:04 GMTby Carl Yao. <p><p>Hello:</p><p>If the correct answer is $0.065, the Currency context automatically rounds it to $0.07 to show in the CorrectAnswer field. Is there a way to turn off this rounding? This way, students won't be confused when they see $0.07 as the correct answer, but WeBWorK grades $0.07 as incorrect.</p><p>Thanks!</p><p>Carl Yao</p><p>Portland Community College</p><p><br /></p><p>Code:</p><p><br /></p><p>DOCUMENT();</p><p>loadMacros(</p><p> "PGstandard.pl",</p><p> "MathObjects.pl",</p><p> "PGML.pl",</p><p> "parserAssignment.pl",</p><p> "contextCurrency.pl",</p><p> "PGcourse.pl",</p><p>);</p><p><br /></p><p>##############################################</p><p><br /></p><p>Context("Numeric");</p><p>Context("Numeric")->variables->add(y=>'Real');</p><p>Context()->noreduce('(-x)-y','(-x)+y');</p><p>Context()->flags->set(showExtraParens=>0);</p><p><br /></p><p>$m=random(1.5,6.5,1)/100;</p><p>$b=random(11,19,1);</p><p><br /></p><p>$x1=random(210,300,10);</p><p>$y1=$m*$x1+$b;</p><p>$x2=random(310,400,10);</p><p>$y2=$m*$x2+$b;</p><p>$x3=random(110,200,10);</p><p>$y3=$m*$x3+$b;</p><p>$x4=random(410,500,10);</p><p>$y4=$m*$x4+$b;</p><p><br /></p><p>parser::Assignment->Allow;</p><p>$ansSI=Formula("y=$m*x+$b")->reduce;</p><p><br /></p><p>Context("Currency")->flags->set(noExtraDecimals=>0);</p><p>$cy1 = Currency($y1);</p><p>$cy2 = Currency($y2);</p><p>$cy3 = Currency($y3);</p><p>$cy4 = Currency($y4);</p><p>$cm = Currency($m);</p><p><br /></p><p>##############################################</p><p><br /></p><p>TEXT(beginproblem());</p><p><br /></p><p>BEGIN_PGML</p><p><br /></p><p>By your cell phone contract, you pay a monthly fee plus some money for each minute you use the phone during the month. In one month, you spent [`[$x1]`] minutes on the phone, and paid [`[$cy1]`]. In another month, you spent [`[$x2]`] minutes on the phone, and paid [`[$cy2]`]. What is the rate (in dollars per minute) that the phone company is charging you? That is, what is the slope of the line if you plotted the bill versus the number of minutes spent on the phone?</p><p><br /></p><p>The rate is [__]{$cm}{width=>5} per minute.</p><p><br /></p><p>END_PGML</p><p><br /></p><p>ENDDOCUMENT();</p><p><br /></p><p><br /></p></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5024&parent=15426Re: MathQuill used with redefined operatorname
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15425
Tue, 16 Feb 2021 04:27:00 GMTby Paul Seeburger. <p><p>Thank you, Glenn!</p><p>I appreciate your help on this! I really don't like having students use the sec^(-1) notation, as I think it is so easy to misunderstand, but I do see that this works, as have some of my students.</p><p>I think asec(x) also would work, but again, I don't want my students to develop the habit of writing arcsec x this way. =)</p><p>Paul</p></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15425Re: MathQuill used with redefined operatorname
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15424
Mon, 15 Feb 2021 22:25:48 GMTby Glenn Rice. <p><div class="text_to_html">I just submitted a pull request that removes the operatorname from the text output. You could download the files from that pull request and replace the ones on your server to fix this issue. The pull request is https://github.com/openwebwork/webwork2/pull/1200.</div><div class="text_to_html"><br /></div><div class="text_to_html">You can also tell your students to use the inverse function notation. Have them enter sin^(-1) instead. That works with the current javascript, and webwork recognizes that.<br /></div></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15424MathQuill used with redefined operatorname
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15423
Mon, 15 Feb 2021 19:35:36 GMTby Paul Seeburger. <p><span class="filter_mathjaxloader_equation"><p>I have a Calculus 2 integration problem where I want students to be able to enter their answer using the arcsec (x) form of this inverse trig. function, so I have added this option to the problem as shown below.</p><p>But MathQuill does not treat it properly, but instead inserts 'operatorname{arcsec}' in place of "arcsec".</p><p>To eliminate this error, do I have to create a custom grader? Or is there another way I could define the arcsec as a function that would work properly with MathQuill?</p><p>Thanks!</p><p>Paul</p><p>See image below for the error given and the problem code below that:</p><p><br /></p><pre># DESCRIPTION
# WeBWorK problem written by Paul Seeburger, <pseeburger@monroecc.edu>
# ENDDESCRIPTION
## DBsubject(Calculus - single variable)
## DBchapter(Techniques of integration)
## DBsection(Trigonometric integrals)
## Date(2/5/2014)
## Institution(Monroe Community College)
## Author(Paul Seeburger)
## KEYWORDS('calculus', 'integral', 'antiderivatives', 'indefinite integrals', 'inverse trig', 'arcsec')
## Textbook tags
## HHChapter1('Integration')
## HHSection1('Inverse Trigonometric Integrals')
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"hhAdditionalMacros.pl",
"parserFormulaUpToConstant.pl",
);
Context("Numeric");
$a = random(2,9,1);
$asq = $a*$a;
$b = random(2,5,1);
$bsq = $b*$b;
$c = $a*2+1;
$bound = Compute(1.01*($a/$b));
Context()->variables->set(x=>{limits=>[$bound, 10]});
Context()->functions->set( asec => {TeX => '\text {arcsec}'}, );
Context()->flags->set(
reduceConstants=>0, # no decimals
reduceConstantFunctions=>1, # combine 4+5*2?
formatStudentAnswer=>'parsed', # no decimals
);
$aoverb = reduced_frac($a, $b);
$bovera = reduced_frac($b, $a);
$func = Compute("$c/(x*sqrt($bsq x^2 - $asq))");
$antider = Compute("($c/$a) arcsec(|$b x|/$a)");
$afunc = FormulaUpToConstant($antider." + C");
#$afunc->{test_at} = [[1, -$bound], [1, -$bound*2], [1, -$bound*10]];
$afunc->{test_at} = [-$bound, -$bound*2, -$bound*10];
TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT
Antidifferentiate. You may need to transform the integrand
first.
$PAR
<span class="nolink">\(\displaystyle \int\frac {$c}{x \sqrt{$bsq x^2 - $asq}}\, dx =\)</span>
\{ ans_rule(60) \}
END_TEXT
Context()->normalStrings;
ANS($afunc->cmp() );
Context()->texStrings;
BEGIN_SOLUTION
$PAR SOLUTION $PAR
Recognizing that this is NOT a natural log form integral, since we would need a factor of <span class="nolink">\(x\)</span> in the numerator (and not in the denominator) for that, we check to see if this may be an inverse trig form integral by rewriting the denominator of the integrand. $PAR
We see that <span class="nolink">\( a = $a \)</span>, <span class="nolink">\( u = $b x \)</span>, and <span class="nolink">\( du = $b \, dx \)</span>, $PAR
and we recognize that the integral is in the $BBOLD arcsecant $EBOLD form,
<span class="nolink">\[ \int\frac {du}{u\sqrt{u^2 - a^2}} = \frac{1}{a}\text{arcsec}\left(\frac {|u|}{a}\right) + C.\]</span>
Then we are able to evaluate the integral as follows:
<span class="nolink">\[
\int\frac {$c}{x \sqrt{$bsq x^2 - $asq}}\, dx =
$c \int\frac {$b}{$b x \sqrt{($b x)^2 - ($a)^2}}\, dx
\]</span>
<span class="nolink">\[
= \frac {$c}{$a} \text{arcsec}\left(\frac{|$b x|}{$a} \right) + C
= \frac {$c}{$a} \text{arcsec}\left($bovera |x| \right) + C.
\]</span>
END_SOLUTION
Context()->normalStrings;
COMMENT('MathObject version');
ENDDOCUMENT();
</pre><p><br /></p><p><br /></p></span></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5023&parent=15423Re: stats and least squares linear regression
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5021&parent=15415
Fri, 12 Feb 2021 20:58:03 GMTby Danny Glin. <p><p>You can look at the code of the problems in the Regression section of the OPL to get some ideas. Here are a few techniques that I am aware of:</p><p></p><ol><li>Use the <a href="https://webwork.maa.org/wiki/R_in_WeBWorK">R integration with WeBWorK</a>. This allows you to call any R functions to do statistical calculations. Many of the UBC statistics problems in the OPL take advantage of this.</li><li>There appears to be a function called linear_regression in PGstatisticsmacros.pl. According to the documentation, the usage is:<br /><span style="font-size:.9375rem;">@xdata = (-1,2,3,4,5,6,7);<br /></span><span style="font-size:.9375rem;">@ydata = (6,5,6,7,8,9,11);<br /></span><span style="font-size:.9375rem;">($slope,$intercept,$var,$SXX) = linear_regression(~~@xdata,~~@ydata);<br />Though based on a quick look, this isn't used in any OPL problem, so I don't know how well tested it is.</span></li><li>You can create a for loop within your problem to manually calculate the parameters. This is inelegant but effective.</li></ol></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5021&parent=15415stats and least squares linear regression
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5021&parent=15414
Fri, 12 Feb 2021 17:35:30 GMTby Zak Zarychta. <p><p>Having done a quick search I am unsure of the status of the stats functions available in WW. </p><p>What I am aiming to do is give the students a set of 10 data points which they are required to calculate the gradient and intercept of the line of best fit and their respective uncertainties. </p><p>Any pointers to existing functionality in WW is welcome.</p><p>Zak</p></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5021&parent=15414Re: random numbers in arrays
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15413
Wed, 10 Feb 2021 16:20:24 GMTby Alex Jordan. <p><p>A tangential observation. I've been using list_random() more since I learned about the perl .. operator. So instead of:</p><p>(-1)**(random(1,20,1)) * random(5,20,1)</p><p>you could have:</p><p>list_random(-20..-5,5..20)<br /></p></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15413Re: random numbers in arrays
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15412
Wed, 10 Feb 2021 15:12:01 GMTby Glenn Rice. <p><p>WW has no problem with random used in an array. I have done so many times in problems.</p><p>You have a syntax error in the line you gave. Are you sure that is not what is causing the problem?</p><p>The syntax error is an unmatched parenthesis.</p><p>@row0 = ($xVal, $yVal + (-1)**(random(1,20,1)*0.01*random(5,20,1)*$tVal);<br /> ^<br /></p><br /></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15412random numbers in arrays
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15411
Wed, 10 Feb 2021 14:37:43 GMTby Zak Zarychta. <p><p>Hi there I want to set up an array that contains manipulates some number using some generated random number to simulate experimental data</p><p><span style="font-size:.9375rem;">For example, one row of a data table might look like the following. where xVal and yVal are respectively independent and dependent variables. yVal is perturbed by a random amount</span><br /></p><p>@row0 = ($xVal, <span style="font-size:.9375rem;">$yVal + (-1)**(random(1,20,1)*0.01*random(5,20,1)*$tVal);</span></p><p><span style="font-size:.9375rem;">problem is WW does not seem to like the function random in an array. Also, WW itself traps the standard perl rand function. </span></p><p>Does anyone have any ideas on how to get around this?</p><p>Thanks,<span style="font-size:.9375rem;">Zak</span></p></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5020&parent=15411Re: Scaffolded problem and number of attempts.
https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5016&parent=15374
Thu, 04 Feb 2021 17:12:45 GMTby Sergio Chaves. <p><div class="text_to_html">Thanks for your reply Davide, maybe I was not clear enough. <br />
Yes, that is exactly what I would like to set up.</div></p>https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5016&parent=15374