https://webwork.maa.org/mediawiki_new/api.php?action=feedcontributions&user=Pstaabp&feedformat=atomWeBWorK_wiki - User contributions [en]2024-03-29T12:54:59ZUser contributionsMediaWiki 1.34.0https://webwork.maa.org/mediawiki_new/index.php?title=Release_notes_for_WeBWorK_2.18&diff=23883Release notes for WeBWorK 2.182023-08-15T13:15:24Z<p>Pstaabp: removed under construction</p>
<hr />
<div>== New WeBWorK Features ==<br />
* UI Changes for WeBWorK<br />
** The overall layout of WeBWorK has changed a bit with the sidebar navigation menu scrolling independently of the main content.<br />
** The page Help (which was a ? icon in the navigation list) has been moved to a ? next to the page title. The page help for each page has been improved.<br />
** The instructor Tools is more clearly a separate page rather than a Header for other tools.<br />
** The Set Assigner and Problem Editor can now be directly accessed from the sidebar navigation.<br />
** The Student Progress page has a new option to show 'Time remaining' for tests.<br />
** The Stats page has been rewritten for layout and clarity. <br />
** PG problem editor improvements<br />
*** The layout of the page is updated to include a source editor and viewer in a side-by-side manner.<br />
*** There is a new Generate Hardcopy tab from which you can generate a PDF displaying only the problem being edited. This makes it much easier to test hardcopy generation for problems.<br />
*** There are new problem viewing output formats (TeX and PTX -- PreTeXt).<br />
*** The Update/New Version tab options are now called Save/Save As... <br />
*** There are options to save backups for pg problems. (documentation?)<br />
** The date/time widget (flatpicker) now includes a "Now" and "Today" button to set the date/time to now or adjust the date only respectively. <br />
* A new LTI version 1.3 authentication module has been added that utilizes some of the LTI Advantage tool set. The LTI version 1.1 authentication module is still available.<br />
* A new status called "observer" has been added. This can be used for TAs and professors or others to ensure that they don't show up in scoring, statistics and student progress views. They will be shown in green in the Classlist Editor.<br />
* Gateway quizzes are now called Tests.<br />
* Hardcopy generation has been revamped. A new hardcopy theme system has been devised. Each theme is contained in a single XML file. These theme files can be edited from the PG problem editor. There are eleven themes distributed with webwork2. (Update documentation for hardcopy?)<br />
* The ability to save/retrieve data within pg problems on a user-set level has been added. (Needs documentation)<br />
* Essay answers<br />
** There is now an equation editor to insert math via MathQuill (similar in nature to the MathView equation editor).<br />
** This equation editor is also available for manual graders.<br />
* When using the problem grader, there is now an option for using points (default), percent or both. This is a new option in the Problem Display/Answer Checking tab of the Course Configuration.<br />
* The Wiris Math Editor has been removed. It was never functional and input is better handled by MathQuill.<br />
<br />
== New PG Features ==<br />
<br />
* Built-in Features<br />
** Images can be inserted in PGML with the code <tt>[!alt text!]{image source}{optional width}{optional height}</tt>. See [https://webwork.maa.org/wiki/Images_-_PGML the wiki page on PGML images] and a [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/Images.html sample problem].<br />
<br />
* New Macros:<br />
** There is a new macro for plotting three dimensional curves and surfaces using the plotly.js JavaScript library. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/graph/plotly3D.html POD for plotly3D.pl] and sample problems on [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SpaceCurveGraph.html space curves] and [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SurfaceGraph.html surface graphs].<br />
** A new macro allows you to generate a random name for a person. Methods are provided to insert the correct pronouns (he, she, or they) for that name into sentences. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/misc/randomPerson.html POD for randomPerson.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/Misc/RandomPerson.html sample problem].<br />
** There is a new MathObject checkboxes macro for creating multiple choice checkbox answers. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserCheckboxList.html POD for parserCheckBoxList.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoiceCheckbox.html sample problem].<br />
** A new macro allows authors to tie a radio answer together with several answer blanks that are dependent on the radio choice. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserRadioMultiAnswer.html POD for parserRadioMultiAnswer.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixOperations.html sample problem].<br />
** There is a new linear relation context for lines and linear inequalities. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserLinearRelation.html POD for parserLinearRelation.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/LinearInequality.html sample problem].<br />
** A new specialTrigValues.pl macro provides the standard values of trig functions on the unit circle. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/math/specialTrigValues.html POD for specialTrigValues.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/Trig/SpecialTrigValues.html sample problem].<br />
<br />
* Updates to existing macros:<br />
** The niceTables.pl macro has been completely overhauled. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/ui/niceTables.html POD for niceTables.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/DataTables.html sample problem].<br />
** Authors can now specify values for checkbox and radio answers added via the parserCheckboxList.pl and parserRadioButtons.pl macros that will be displayed on the past answers page (instead of B0, B1, etc., as was previously shown). See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserCheckboxList.html POD for parserCheckboxList.pl] and [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserRadioButtons.html POD for parserRadioButtons.pl].<br />
** The graphTool macro has been updated:<br />
*** There is now a number line mode for graphing intervals. <br />
*** There are default answer checkers that make writing graph tool problems easier.<br />
*** A <tt>generateAnswerGraph</tt> method has been added which shows the correct answer graph. This is useful for solutions.<br />
*** A dynamic help system has been implemented to help students use the graph tool.<br />
*** See the following sample problems: [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolNumberLine.html Number Line Mode], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolCircle.html Plotting a Circle], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolCubic.html Plotting a Cubic], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolLine.html Plotting a Line], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolPoints.html Plotting Points]<br />
*** Also see the [https://openwebwork.github.io/pg-docs/pod/pg/macros/graph/parserGraphTool.html POD for parserGraphTool.pl].<br />
** There is a new DropDown method provided by the parserPopup.pl macro. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserPopUp.html POD for parserPopUp.pl] and a [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/SimplePopUp.html sample problem].<br />
<br />
* Mathquill changes<br />
** Typing <code>deg</code> will automatically turn into a degree symbol. So for example, if <code>23degF</code> is typed it will become <code>23°F</code>.<br />
** Trigonometric functions such as sin, cos, tan, arcsin, arccos, etc, and logarithmic functions ln and log will now automatically wrap the function argument in parentheses. Exponents (or subscripts) on these functions can be typed before the parentheses or after.<br />
** Double and triple click selection behavior has been implemented for MathQuill inputs.<br />
<br />
* Changes to Units:<br />
** Students can enter °C or °F instead of degC or degF for Celsius and Fahrenheit degrees. This can be done easily if MathQuill is enabled as described above. Students may also paste unicode characters for these from other websites.<br />
** Several new units have been added, including angstroms, microseconds, nanoseconds, picometers, femtometers, tera electron volts, Megawatts, milliwatts, milliCoulombs, microCoulombs, nanoCoulombs, milli-amperes, milli-teslas, Becquerels, (US) gallons, (US) quarts, and (US) pints.<br />
** Many unicode characters for units have been added.<br />
** More forms of units are now allowed including plural forms. For example, one may enter <code>30 ft</code>, <code>30 feet</code>, or <code>1 foot</code>.<br />
<br />
== Deprecated PG ==<br />
<br />
* Deprecated Macros:<br />
** <tt>AnswerFormatHelp.pl</tt>: Authors should now use the [https://openwebwork.github.io/pg-docs/pod/pg/macros/core/PGbasicmacros.html#helpLink-type-display_text-helpurl helpLink] function from <tt>PGbasicmacros.pl</tt> instead.<br />
** <tt>unionInclude.pl</tt>: This was used for random problems.<br />
** Although not officially deprecated at this point, <tt>unionTables.pl</tt> should not be used due to accessibility and html validation issues. Use <tt>niceTables.pl</tt> instead.<br />
<br />
* Other Deprecation<br />
** <tt>$BEGIN_ONE_COLUMN</tt> and <tt>$END_ONE_COLUMN</tt>: These have often been used in set header files. These variables are now defined to be the empty string, and no longer actually start or end one column mode. Set headers are now always inserted in one column mode in hardcopy.<br />
<br />
== Security/Advanced Features ==<br />
<br />
The backend of WeBWorK has been relying on mod_perl for nearly two decades. However, mod_perl is deprecated and has not been updated since 2011. Many Linux distributions no longer support mod_perl, and it is becoming increasing difficult to install it on some of them. The server part of WeBWorK is now implemented with [https://mojolicious.org Mojolicious], which includes a stand alone web server (hypnotoad) written completely in Perl.<br />
<br />
== Upgrade Instructions ==<br />
* It is recommended to back up your current webwork2 configuration files before proceeding. Do this with<br />
*: <code>> cp -r /opt/webwork/webwork2/conf /opt/webwork/webwork2/conf.bak</code><br />
* Now update the webwork2 and pg code. For this run<br />
*: <code>> cd /opt/webwork/webwork2</code><br />
*: <code>> git fetch origin</code><br />
*: <code>> git checkout main</code><br />
*: <code>> git pull</code><br />
*: <code>> cd /opt/webwork/pg</code><br />
*: <code>> git fetch origin</code><br />
*: <code>> git checkout main</code><br />
*: <code>> git pull</code><br />
* Update the javascript and css assets for webwork2 and pg with<br />
*: <code>> cd /opt/webwork/webwork2/htdocs</code><br />
*: <code>> npm ci</code><br />
*: <code>> cd /opt/webwork/pg/htdocs</code><br />
*: <code>> npm ci</code><br />
* The following perl packages will need to be installed (run <code>bin/check_modules.pl</code> to ensure you have all programs/modules)<br />
** Mojolicious (on Ubuntu 22.04 install the package libmojolicious-perl, on earlier versions of Ubuntu install from cpan)<br />
** Future::AsyncAwait (on Ubuntu 22.04 install the package libfuture-asyncawait-perl, on earlier versions of Ubuntu install from cpan)<br />
** SVG (on Ubuntu install libsvg-perl)<br />
** Data::Structure::Util (on Ubuntu install libdata-structure-util-perl)<br />
** Crypt::JWT (on Ubuntu install libcrypt-jwt-perl)<br />
** Crypt::PK::RSA (on Ubuntu install libcryptx-perl)<br />
** Math::Random::Secure (on Ubuntu install libmath-random-secure-perl)<br />
** Mojolicious::Plugin::NotYAMLConfig (this is included in libmojolicious-perl on Ubuntu 22.04, on earlier versions of Ubuntu install from cpan)<br />
** Mojolicious::Plugin::RenderFile (on Ubuntu install libmojolicious-plugin-renderfile-perl)<br />
** Minion (on Ubuntu install libminion-perl)<br />
** Minion::Backend::SQLite (on Ubuntu install libminion-backend-sqlite-perl)<br />
** Perl::Tidy (install using cpanm with <code>sudo cpanm Perl::Tidy@20220613</code>)<br />
** Pandoc and the pandoc application (on Ubuntu install libpandoc-wrapper-perl for both)<br />
* Hardcopy generation now requires that the <code>mhchem</code> LaTeX package be installed. (on Ubuntu install texlive-science.)<br />
* Delete the old apache2 configuration file /opt/webwork/webwork2/conf/webwork.apache2.4-config and the link to it in /etc/apache2/conf-enabled with<br />
*: <code>> rm /opt/webwork/webwork2/conf/webwork.apache2.4-config</code><br />
*: <code>> sudo rm /etc/apache2/conf-enabled/webwork.conf</code><br />
* Compare your site.conf file to site.conf.dist, and your localOverrides.conf file to localOverrides.conf.dist and update as needed.<br />
* Enable new apache2 modules that are needed with<br />
*: <code>> sudo a2enmod proxy_http headers</code><br />
* Switch from mpm_prefork to mpm_event. This step is optional but recommended. The only reason we have been using mpm_prefork is because it is required for mod_perl2. The mpm_event module is a threaded module that is better with memory management and high server loads. Another option that may be better in some cases is the mpm_worker module. In general it is not recommended to use the mpm_prefork module anymore. There are no advantages, only disadvantages.<br />
** Disable the apache2 mpm_prefork module and enable mpm_event with<br />
*: <code>> sudo a2dismod mpm_prefork</code><br />
*: <code>> sudo a2enmod mpm_event</code><br />
** Adjust the parameters in the file /etc/apache2/mods-available/mpm_event.conf as needed. See [[Installation Manual for 2.18 on Ubuntu#Edit mpm_event.conf]] for details.<br />
* Next set up the new apache2 configuration.<br />
*: <code>> cp /opt/webwork/webwork2/conf/webwork2.apache2.4.dist.conf /opt/webwork/webwork2/conf/webwork2.apache2.4.conf</code><br />
*: <code>> sudo ln -s /opt/webwork/webwork2/conf/webwork2.apache2.4.conf /etc/apache2/conf-enabled/webwork2.conf</code><br />
* Restart apache2 to make all of the apache2 changes take effect with<br />
*: <code>> sudo systemctl restart apache2</code><br />
* Note that at this point webwork2 is not running, and you will not be able to access the usual pages. The webwork2 service now needs to be set up for this to work. Start by copying the systemd service .dist file for webwork2.<br />
*: <code>> cp /opt/webwork/webwork2/conf/webwork2.dist.service /opt/webwork/webwork2/conf/webwork2.service</code><br />
* Now enable and start the service with<br />
*: <code>> sudo systemctl enable /opt/webwork/webwork2/conf/webwork2.service</code><br />
*: <code>> sudo systemctl start webwork2</code><br />
* You should now be able to visit <nowiki>http://your.server.edu/webwork2</nowiki> (the usual url for your server) and see webwork2 in action.<br />
* Note that anytime prior to this upgrade that you would have restarted apache2 to make changes to code or configuration take effect, you will instead now run <code>sudo systemctl restart webwork2</code>. You will rarely need to restart apache2.<br />
* Make sure to upgrade courses from the admin course to relegate changes to the database.<br />
* If you have course archives located in /opt/webwork/courses, then you will need to move them to /opt/webwork/courses/admin/archives. That directory probably will not exist, so you will also need to create it. You can do this with<br />
*: <code>sudo mkdir /opt/webwork/courses/admin/archives</code><br />
*: <code>sudo cp /opt/webwork/courses/*.tar.gz /opt/webwork/courses/admin/archives/</code><br />
*: These files will also now be available from the "File Manager" in the admin course.<br />
* This final step is optional. Some long running processes are not directly run by the webwork2 app. Particularly mass grade updates via LTI and sending of instructor emails. Instead these tasks are executed via the webwork2 Minion job queue. If the users of your system will be utilizing either of those features, then you will need to set up the webwork2 job queue. If those features will not be utilized by the users of your system, then you can skip this step. See [[Installation Manual for 2.18 on Ubuntu#Set Up the Webwork2 Job Queue]] for instructions on how to set up the job queue.<br />
<br />
== Release Details ==<br />
<pre><br />
WeBWorK <br />
Online Homework Delivery System <br />
Version 2.18 <br />
<br />
Copyright 2000-2023, The WeBWorK Project <br />
All rights reserved. <br />
<br />
Details<br />
-------<br />
<br />
Release date: July 20, 2023<br />
<br />
Commits: The webwork2 main branch was modified by 792 commits in merging the WeBWorKk-2.18 branch into main, and the pg main branch was modified by 504 commits in merging the PG-2.18 branch into main.<br />
<br />
Github repository: https://github.com/openwebwork<br />
Modules: webwork2 pg<br />
<br />
Release team:<br />
* Glenn Rice, Missouri Western State University<br />
* Danny Glin, University of Calgary, technical manager for The WeBWorK Project (TWP)<br />
* K. Andrew Parker, New York City College of Technology (“City Tech”), City University of New York<br />
* Nathan Wallach, Technion - Israel Institute of Technology<br />
* Alex Jordan, Portland Community College (PCC)<br />
* Peter Staab, Fitchburg State University<br />
* Mike Gage, University of Rochester<br />
* Jaimos Skriletz, Boise State University<br />
</pre><br />
<br />
[[Category:Release_Notes]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Images_-_PGML&diff=23857Images - PGML2023-07-25T19:43:22Z<p>Pstaabp: </p>
<hr />
<div>__TOC__<br />
== Static Images ==<br />
<br />
Images can be inserted into a PGML block with<br />
<br />
[!alt text!]{'image_file'}{width (optional)}{height (optional)}<br />
<br />
Image files are local to the problem (either in the same directory or a sub directory) or as a URL. Standard image types of gif, jpeg and png are supported. <br />
<br />
== Dynamically Created Images ==<br />
<br />
Images can be created with macros as well. These include WWPlot, TikZ, LaTeXImage, or graphtool plots.<br />
<br />
For example, consider a TikZ image created with <br />
<br />
loadMacros('PGtikz.pl')<br />
<br />
$TikZ = createTikZImage();<br />
$TikZ->BEGIN_TIKZ<br />
\draw (0,0) circle[radius=1.5];<br />
END_TIKZ<br />
<br />
This can be added with<br />
<br />
[!Graph of a circle!]{$TikZ}{250}<br />
<br />
If a WWPlot, LaTeXImage or GraphTool is created, it can be added in the same way. See [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/Images.html a sample problem] for a full problem that shows this.<br />
<br />
== Storing Alternate Text in a variable == <br />
<br />
If you store alternate text in a variable (which often will occur with a dynamic image), you will need to bracket your variable. For example<br />
<br />
$alt_text = 'This is some alternate text.';<br />
<br />
and then in the PGML image call<br />
<br />
[! [$alt_text] !]{$TikZ}{250}<br />
<br />
== Optional sizes ==<br />
<br />
The width and height can be added optionally.<br />
<br />
* The <tt>width</tt> will be the width of the image in pixels. If not given, 100 is given as the default.<br />
<br />
* The <tt>height</tt> will be the height of the image in pixels. If not given, it is determined by the natural (based on aspect ratio) value of the image.<br />
<br />
Note: For hardcopy output, there is a <tt>tex_size</tt> that is set automatically based on the formula <tt>width*1000/6000</tt> to indicate a scale of the width as a proportion of the width of the page or column where 1000 mean 100% of the width.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Release_notes_for_WeBWorK_2.18&diff=23813Release notes for WeBWorK 2.182023-07-18T12:01:59Z<p>Pstaabp: /* New PG Features */</p>
<hr />
<div>{{UnderConstruction}}<br />
Note that WeBWorK 2.18 has not yet been released. Currently this page is a work in progress.<br />
<br />
== New WeBWorK Features ==<br />
* UI Changes for WeBWorK<br />
** The overall layout of WeBWorK has changed a bit with the sidebar navigation menu scrolling independently of the main content.<br />
** The page Help (which was a ? icon in the navigation list) has been moved to a ? next to the page title. The page help for each page has been improved.<br />
** The instructor Tools is more clearly a separate page rather than a Header for other tools.<br />
** The Set Assigner page/tool is not separate&nbsp;it could only be accessed via the Instructor Tools Page.<br />
** The Problem Editor has its own sidebar navigation link. <br />
** The Student Progress page has a new option to show 'Time remaining' for tests.<br />
** The Stats page has been rewritten for layout and clarity. <br />
** The PG problem editor improvements<br />
*** The layout of the page is updated to include a source editor and viewer in a side-by-side manner.<br />
*** There is a new Generate Hardcopy tab from which you can generate a PDF displaying only the problem being edited. This makes it much easier to test hardcopy generation for problems.<br />
*** There are new problem viewing output formats (TeX and PTX--pretext).<br />
*** The update/new version tab options are now called Save/Save As... <br />
*** There are options to save backups for pg problems. (documentation?)<br />
** The date/time widget (flatpicker) now includes a "Now" and "Today" button to set the date/time to now or adjust the date only respectively. <br />
* A new LTI version 1.3 authentication module has been added that utilizes some of the LTI Advantage tool set. The LTI version 1.1 authentication module is still available.<br />
* A new status called "observer" has been added. This can be used for TAs and professors or others to ensure that they don't show up in scoring, statistics and student progress views. They will be shown in green in the Classlist Editor.<br />
* Gateway quizzes are now called Tests.<br />
* Hardcopy generation has been revamped. It now uses the exam class from latex. (Update documentation for hardcopy?)<br />
* The ability to save/retrieve data within pg problems on a user-set level has been added. (Needs documentation)<br />
* Essay answers<br />
** There is now a button to insert math via Mathquill (similar in nature to the MathView button that does the same).<br />
** The same is try for manual graders. <br />
* When using the problem grader, there is now an option for using points (default), percent or both. This is a new option in the Problem Display/Answer Checking tab of the Course Configuration.<br />
* The Wiris Math Editor has been removed. It was never functional and input is better handled by MathQuill.<br />
<br />
== New PG Features ==<br />
<br />
* Built-in Features<br />
** images can be inserted in PGML with the code <tt>[! alt text!]{image source}{optional width}{optional height}</tt>. See [https://webwork.maa.org/wiki/Images_-_PGML the wiki page on PGML images] and [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/Images.html a sample problem].<br />
<br />
* New Macros:<br />
** The plotly3D macro plots 3D space curves and surfaces using the plotly.js package. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/graph/plotly3D.html POD] and sample problems on [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SpaceCurveGraph.html space curves] and [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SurfaceGraph.html Surface Graphs]<br />
** A random person macro that generates a person with he, she or they pronouns. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/misc/randomPerson.html POD] and a [https://openwebwork.github.io/pg-docs/sample-problems/Misc/RandomPerson.html sample problem].<br />
** MathObject checkboxes. See [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserCheckboxList.html the POD] and a [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoiceCheckbox.html sample problem].<br />
** A new parserRadioMultiAnswer macro allows for a mixture of radio buttons and within each, other inputs. See the [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserRadioMultiAnswer.html the POD] and [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixOperations.html a sample problem].<br />
** Non-decimal base context (documentation)<br />
** Linear Relation context for lines and linear inequalities. See [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserLinearRelation.html the POD] and a [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/LinearInequality.html sample problem]<br />
** Special Trig Values--provides the standard values of trig functions on the unit circle '''Doc needed'''<br />
<br />
* Updates to existing macros<br />
** niceTables.pl has been completely overhauled.<br />
*** New features:...<br />
*** Changes?<br />
*** see [https://openwebwork.github.io/pg-docs/pod/pg/macros/ui/niceTables.html the POD] and [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/DataTables.html a sample problem] <br />
** Labels for checkbox/radio answers. See [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserCheckboxList.html the POD]. <br />
** The graphTool macro has been updated:<br />
*** There is now has a number line option to graph intervals. <br />
*** There are default answer checkers to make writing problems easier. See [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserGraphTool.html the POD].<br />
*** Sample problems: [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolNumberLine.html number line mode], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolCircle.html Plotting a Circle], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolCubic.html Plotting a Cubic], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolLine.html Plotting a Line], [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/GraphToolPoints.html Plotting Points]<br />
*** A method <tt>generateAnswerGraph</tt> has been added which shows the correct answer graph&mdash;useful for plotting in solutions.<br />
** DropDown option to Popup macro. See [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserPopUp.html the POD] and [https://openwebwork.github.io/pg-docs/pod/pg/macros/parsers/parserPopUp.html a sample problem].<br />
<br />
* Mathquill changes<br />
<br />
* Changes to Units:<br />
** degrees (celsius, Fahrenheit, Kelvin) and mathquill<br />
** new units: angstroms, microsecond, nanosecond, picometre, femtometre, tera electron-volt, Megawatt, milliwatt, milliCoulomb, microCoulomb, nanoCoulomb, milli-ampere, milli-tesla, Becquerel as well as gallon (U.S.), quart, pint.<br />
<br />
== Deprecated PG ==<br />
<br />
* Deprecated Macros:<br />
** <tt>AnswerHelpFormat</tt>. Authors should now use standard [https://openwebwork.github.io/pg-docs/pod/pg/macros/core/PGbasicmacros.html#helpLink-type-display_text-helpurl helpLink] function instead. <br />
** <tt>unionInclude</tt> This was used for random problems.<br />
** although not deprecated, <tt>unionTables</tt> should not be used due to accessibility issues. Use <tt>niceTables.pl</tt> instead.<br />
<br />
* Other Deprecation<br />
** <tt>$BEGIN_ONE_COLUMN</tt> and <tt>$END_ONE_COLUMN</tt> use in hardcopy output.<br />
<br />
== Security/Advanced Features ==<br />
<br />
The backend of WeBWorK has been relying on apache and mod_perl for nearly two decades. However, mod_perl has not been updated since 2011 and many linux distros are no longer supporting mod_perl in an easy way. The server part of WeBWorK is now functioning with [https://mojolicious.org Mojolicious], which includes a standalone web server (hypnotoad) written completely in perl. <br />
<br />
Mojolicious has some nice modern route handling features...<br />
<br />
(Include some security features?)<br />
<br />
== Upgrade Instructions ==<br />
* It is recommended to back up your current webwork2 configuration files before proceeding. Do this with<br />
*: <code>> cp -r /opt/webwork/webwork2/conf /opt/webwork/webwork2/conf.bak</code><br />
* Now update the webwork2 and pg code. For this run<br />
*: <code>> cd /opt/webwork/webwork2</code><br />
*: <code>> git fetch origin</code><br />
*: <code>> git checkout main</code><br />
*: <code>> git pull</code><br />
*: <code>> cd /opt/webwork/pg</code><br />
*: <code>> git fetch origin</code><br />
*: <code>> git checkout main</code><br />
*: <code>> git pull</code><br />
*: Note: Until the actual release replace "main" above with "WeBWorK-2.18" for the webwork2 code, and "PG-2.18" for the pg code to obtain the code for the release candidate.<br />
* Update the javascript and css assets for webwork2 and pg with<br />
*: <code>> cd /opt/webwork/webwork2/htdocs</code><br />
*: <code>> npm ci</code><br />
*: <code>> cd /opt/webwork/pg/htdocs</code><br />
*: <code>> npm ci</code><br />
* The following perl packages will need to be installed (run <code>bin/check_modules.pl</code> to ensure you have all programs/modules)<br />
** Mojolicious (on Ubuntu 22.04 install the package libmojolicious-perl, on earlier versions of Ubuntu install from cpan)<br />
** Future::AsyncAwait (on Ubuntu 22.04 install the package libfuture-asyncawait-perl, on earlier versions of Ubuntu install from cpan)<br />
** SVG (on Ubuntu install libsvg-perl)<br />
** Data::Structure::Util (on Ubuntu install libdata-structure-util-perl)<br />
** Crypt::JWT (on Ubuntu install libcrypt-jwt-perl)<br />
** Crypt::PK::RSA (on Ubuntu install libcryptx-perl)<br />
** Math::Random::Secure (on Ubuntu install libmath-random-secure-perl)<br />
** Mojolicious::Plugin::NotYAMLConfig (this is included in libmojolicious-perl on Ubuntu 22.04, on earlier versions of Ubuntu install from cpan)<br />
** Minion (on Ubuntu install libminion-perl)<br />
** Minion::Backend::SQLite (on Ubuntu install libminion-backend-sqlite-perl)<br />
* Hardcopy generation now requires that the <code>mhchem</code> LaTeX package be installed. (on Ubuntu install texlive-science.)<br />
* Delete the old apache2 configuration file /opt/webwork/webwork2/conf/webwork.apache2.4-config and the link to it in /etc/apache2/conf-enabled with<br />
*: <code>> rm /opt/webwork/webwork2/conf/webwork.apache2.4-config</code><br />
*: <code>> sudo rm /etc/apache2/conf-enabled/webwork.conf</code><br />
* Compare your site.conf file to site.conf.dist, and your localOverrides.conf file to localOverrides.conf.dist and update as needed.<br />
* Enable new apache2 modules that are needed with<br />
*: <code>> sudo a2enmod proxy_http headers</code><br />
* Switch from mpm_prefork to mpm_event. This step is optional but recommended. The only reason we have been using mpm_prefork is because it is required for mod_perl2. The mpm_event module is a threaded module that is better with memory management and high server loads. Another option that may be better in some cases is the mpm_worker module. In general it is not recommended to use the mpm_prefork module anymore. There are no advantages, only disadvantages.<br />
** Disable the apache2 mpm_prefork module and enable mpm_event with<br />
*: <code>> sudo a2dismod mpm_prefork</code><br />
*: <code>> sudo a2enmod mpm_event</code><br />
** Adjust the parameters in the file /etc/apache2/mods-available/mpm_event.conf as needed. See [[Installation Manual for 2.18 on Ubuntu#Edit mpm_event.conf]] for details.<br />
* Next set up the new apache2 configuration.<br />
*: <code>> cp /opt/webwork/webwork2/conf/webwork2.apache2.4.dist.conf /opt/webwork/webwork2/conf/webwork2.apache2.4.conf</code><br />
*: <code>> sudo ln -s /opt/webwork/webwork2/conf/webwork2.apache2.4.conf /etc/apache2/conf-enabled/webwork2.conf</code><br />
* Restart apache2 to make all of the apache2 changes take effect with<br />
*: <code>> sudo systemctl restart apache2</code><br />
* Note that at this point webwork2 is not running, and you will not be able to access the usual pages. The webwork2 service now needs to be set up for this to work. Start by copying the systemd service .dist file for webwork2.<br />
*: <code>> cp /opt/webwork/webwork2/conf/webwork2.dist.service /opt/webwork/webwork2/conf/webwork2.service</code><br />
* Now enable and start the service with<br />
*: <code>> sudo systemctl enable /opt/webwork/webwork2/conf/webwork2.service</code><br />
*: <code>> sudo systemctl start webwork2</code><br />
* You should now be able to visit <nowiki>http://your.server.edu/webwork2</nowiki> (the usual url for your server) and see webwork2 in action.<br />
* Note that anytime prior to this upgrade that you would have restarted apache2 to make changes to code or configuration take effect, you will instead now run <code>sudo systemctl restart webwork2</code>. You will rarely need to restart apache2.<br />
* Make sure to upgrade courses from the admin course to relegate changes to the database.<br />
* If you have course archives located in /opt/webwork/courses, then you will need to move them to /opt/webwork/courses/admin/archives. That directory probably will not exist, so you will also need to create it. You can do this with<br />
*: <code>sudo mkdir /opt/webwork/courses/admin/archives</code><br />
*: <code>sudo cp /opt/webwork/courses/*.tar.gz /opt/webwork/courses/admin/archives/</code><br />
*: These files will also now be available from the "File Manager" in the admin course.<br />
* This final step is optional. Some long running processes are not directly run by the webwork2 app. Particularly mass grade updates via LTI and sending of instructor emails. Instead these tasks are executed via the webwork2 Minion job queue. If the users of your system will be utilizing either of those features, then you will need to set up the webwork2 job queue. If those features will not be utilized by the users of your system, then you can skip this step. See [[Installation Manual for 2.18 on Ubuntu#Set Up the Webwork2 Job Queue]] for instructions on how to set up the job queue.<br />
<br />
[[Category:Release_Notes]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Scaffolding1&diff=23812Scaffolding12023-07-18T11:57:57Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/Scaffolding.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Sequentially Revealed (Scaffolded) Problems</h2><br />
<br />
[[File:Scaffolding1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to create multi-part questions that hide from students parts that have not yet been answered correct. This example is deprecated: see [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/Scaffolding2_PGML.pg FortLewis/Authoring/Templates/Misc/Scaffolding2_PGML.pg] instead (requires macro file [https://github.com/openwebwork/pg/blob/master/macros/scaffold.pl scaffold.pl] from after December, 2014).<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/Scaffolding1.pg FortLewis/Authoring/Templates/Misc/Scaffolding1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"compoundProblem5.pl",<br />
#"scaffolding.pl", # alternate future name<br />
"PGcourse.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
$showPartialCorrectAnswers = 1;<br />
<br />
$scaffold = Scaffold();<br />
INITIALIZE_SCAFFOLD('$scaffold');<br />
<br />
$isInstructor = 0; # = 0 when students use it<br />
<br />
TEXT(MODES(<br />
HTML=>'Clicking on a section opens it <br />
provided that you have answered previous sections correctly.',<br />
TeX=>''));<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Use the <code>compoundProblem5.pl</code> macro to provide scaffolding (this macro may be renamed to <code>scaffolding.pl</code> in the future as it is finalized).<br />
We initialize the scaffolding with the name <code>$scaffold</code>.<br />
Set <code>$isInstructor = 0;</code> when the problem is available to students, or set to 1 when debugging.<br />
Alternatively, we could set <br />
<pre><br />
$isInstructor = ($envir{effectivePermissionLevel} >= <br />
$envir{ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL});<br />
</pre> <br />
to ensure that only users that always have permission to show correct answers can open all of the sections of the scaffolding without needing to enter correct answers.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Section 1 --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$answer1a = Compute(11);<br />
$answer1b = Compute(12);<br />
<br />
Context()->texStrings;<br />
DISPLAY_SECTION({ <br />
section=>1,<br />
name=>"1: Antiquated ideas (a descriptive title)", <br />
canshow =>1,<br />
iscorrect=>$scaffold->requireCorrect(1,2), <br />
} , <<'END_SECTION'); <br />
<br />
Continue the pattern: 7, 8, 9, 10, <br />
\{SECTION_ANS($answer1a->cmp), $answer1a->ans_rule(3) \},<br />
\{SECTION_ANS($answer1b->cmp), $answer1b->ans_rule(3)\}.<br />
<br />
END_SECTION<br />
<br />
SECTION_SOLUTION({section=>1},<<'END_SOLUTION');<br />
$PAR<br />
Put some text here for the solution to section 1.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Section 1:</b> <br />
Use <code>DISPLAY_SECTION</code> to set the parameters for the first section.<br />
Use <code>section=>1</code> to set the section number.<br />
Use <code>name=>"1: Descriptive title"</code> to give a title for the section.<br />
Since the first section should always be available to students, we set <code>canshow=>1</code>.<br />
Use <code>iscorrect=>$scaffold->requireCorrect(1,2)</code> to specify that this section will be marked all correct when the answers in answer boxes 1 and 2 are both correct.<br />
</p><br />
<p><br />
The text that gets displayed to students starts at "Continue..."<br />
</p><br />
<p><br />
Use <code>SECTION_ANS()</code> to record the correct weighted score into the grade book (i.e., database of scores).<br />
Note that we use <code>SECTION_ANS($answer->cmp)</code> before <code>$answer->ans_rule(width)</code>, which is a bit different from how things are usually done.<br />
</p><br />
<p><br />
It is also possible to provide a solution for each section.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Section 2 --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
$M = Matrix([[1,2],[3,4]]);<br />
$v = Matrix([[5],[6]]);<br />
<br />
$answer2 = $M * $v;<br />
<br />
Context()->texStrings;<br />
DISPLAY_SECTION( { <br />
section=>2,<br />
name=>"2: Bungling", <br />
canshow =>$scaffold->requireCorrect(1,2). " or $isInstructor",<br />
iscorrect=>$scaffold->requireCorrect(3), <br />
}, <<'END_SECTION'); <br />
<br />
\( $M $v = \) \{SECTION_ANS($answer2->cmp()), $answer2->ans_array()\}<br />
<br />
END_SECTION<br />
<br />
SECTION_SOLUTION({section=>2},<<'END_SOLUTION');<br />
Put solution text here. <br />
END_SOLUTION<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Section 2:</b><br />
For kicks, we change to the matrix context.<br />
Use <code>canshow =>$scaffold->requireCorrect(1,2). " or $isInstructor"</code> to specify that this section (section 2) can be revealed if answer boxes 1 and 2 are both correct (from section 1) or if the permission level of the user is high enough.<br />
Use <code>iscorrect=>$scaffold->requireCorrect(3)</code> to specify that this section (section 2) will be marked correct when the third answer (the entire matrix) is marked correct.<br />
We used <code>$answer->ans_array(width)</code> to generate an array of answer boxes with the same size as the correct answer that are treated as a single entity when grading.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Section 3 --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$answer3a = Compute("NONE");<br />
$answer3b = Compute("DNE");<br />
<br />
Context()->texStrings;<br />
DISPLAY_SECTION({ <br />
section=>3,<br />
name=>"3: False concepts", <br />
canshow =>$scaffold->requireCorrect(3). " or $isInstructor",<br />
iscorrect=>$scaffold->requireCorrect(4,5), <br />
}, <<'END_SECTION'); <br />
<br />
Enter ${BTT}NONE${ETT}: \{SECTION_ANS($answer3a->cmp), $answer3a->ans_rule(10)\}<br />
$BR<br />
Enter ${BTT}DNE${ETT}: \{SECTION_ANS($answer3b->cmp), $answer3b->ans_rule(10) \}.<br />
<br />
END_SECTION<br />
<br />
SECTION_SOLUTION({section=>3},<<'END_SOLUTION');<br />
Solution text goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Section 3:</b><br />
Same syntax as before.<br />
Since the third section is revealed only after the section section is correct, we can use <code>canshow =>$scaffold->requireCorrect(3)</code> to specify that this section (section 3) will be revealed only when answer blank 3 (the matrix from section 2) is correct.<br />
This section will be marked correct only when answer boxes 4 and 5 are both correct, as specified by <code>iscorrect=>$scaffold->requireCorrect(4,5)</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Section 4 --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
foreach my $i (1..5) {<br />
$answer4[$i] = Compute($i);<br />
}<br />
<br />
Context()->texStrings;<br />
DISPLAY_SECTION({ <br />
section=>4,<br />
name=>"4: Superstition", <br />
canshow =>$scaffold->requireCorrect(5). " or $isInstructor",<br />
iscorrect=>$scaffold->requireCorrect(6..10), <br />
}, <<'END_SECTION'); <br />
<br />
Enter 1, 2, 3, 4, 5: <br />
\{$answer4[1]->ans_rule(3)\},<br />
\{$answer4[2]->ans_rule(3)\},<br />
\{$answer4[3]->ans_rule(3)\},<br />
\{$answer4[4]->ans_rule(3)\},<br />
\{$answer4[5]->ans_rule(3)\}.<br />
<br />
END_SECTION<br />
<br />
foreach my $i (1..5) {<br />
SECTION_ANS($answer4[$i]->cmp)<br />
}<br />
<br />
SECTION_SOLUTION({section=>4},<<'END_SOLUTION');<br />
It's a little known fact that <br />
antiquated ideas, bungling, false concepts, and superstition<br />
are the labels on the file drawers inside of Donald Duck's brain<br />
in the movie Donald Duck in Mathmagic Land.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Section 4:</b><br />
We use for loops to deal with the five answers and answer checkers in this section.<br />
Note that in the code we have pulled the <code>SECTION_ANS()</code> commands away from the <code>ans_rule(width)</code> answer boxes, which is to say that we're using the "standard approach" to formatting our code, which helps us use the for loops. <br />
</p><br />
<p><br />
The solution gives an answer to the question, "Where did the section titles come from?"<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<!-- Answer evaluation --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
PROCESS_ANSWERS();<br />
<br />
$last_correct_section = PROCESS_SECTIONS();<br />
<br />
#determine which section to leave open<br />
$opensection = $last_correct_section + 1;<br />
$scaffold->openSections($opensection);<br />
<br />
COMMENT('MathObject version. Uses compoundProblem5.pl <br />
to hide parts that the student has not yet answered correct.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Answer evaluation:</b> <br />
Note that the answer rules and answer evaluators are matched up in the order in which they are entered, and that the question will not work otherwise.<br />
Use <code>PROCESS_SECTIONS()</code> to determine which sections should be revealed and which should be colored correct (green).<br />
Use <code>$scaffold->openSections($opensection);</code> to specify which sections actually get revealed to students.<br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ProvingTrigIdentities2&diff=23811ProvingTrigIdentities22023-07-18T11:57:02Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Trig/ProvingTrigIdentities.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Proving Trig Identites using a Compound Problem</h2><br />
<br />
[[File:ProvingTrigIdentities2.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to have a multi-part question in which each part is revealed sequentially on its own html page. This has been deprecated because of the new <code>scaffold.pl</code> macro that provides the same functionality in a better way. <br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities2.pg FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities2.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"compoundProblem.pl",<br />
"Parser.pl",<br />
"PGunion.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
BEGIN_PROBLEM();<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We use the <code>compoundProblem.pl</code> macro to generate a multi-part question in which each part is sequentially revealed on its own html page.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->are(t=>"Real");<br />
<br />
#<br />
# Redefine the sin(x) to be e^(pi x)<br />
#<br />
Context()->functions->remove("sin");<br />
package NewFunc;<br />
# this next line makes the function a <br />
# function from reals to reals<br />
our @ISA = qw(Parser::Function::numeric);<br />
sub sin {<br />
shift; my $x = shift;<br />
return CORE::exp($x*3.1415926535);<br />
}<br />
package main;<br />
# Add the new functions to the Context<br />
Context()->functions->add(sin=>{class=>'NewFunc',TeX =>'\sin'});<br />
<br />
<br />
$isProfessor = $studentLogin eq 'professor';<br />
<br />
#<br />
# Set up the compound problem object.<br />
#<br />
$cp = new compoundProblem(<br />
parts => 3,<br />
totalAnswers => 3,<br />
parserValues => 1,<br />
allowReset => $isProfessor,<br />
);<br />
$part = $cp->part;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
if ($part == 1) {<br />
<br />
BEGIN_TEXT<br />
${BBOLD}Part 1 of 3:${EBOLD}<br />
$BR<br />
$BR<br />
${BITALIC}Instructions:${EITALIC} You will need to <br />
submit your answers twice for each part. The first <br />
time you submit your answers they will be checked <br />
for correctness. When your answer is correct, check<br />
the box for ${BITALIC}Go on to next part${EITALIC}<br />
and click the submit button. You will not be able<br />
to go back to previous parts.<br />
$BR<br />
$BR<br />
In this multi-part problem, we will use algebra to verify <br />
the identity<br />
$BCENTER<br />
\( \displaystyle \frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }. \)<br />
$ECENTER<br />
$BR<br />
First, using algebra we may rewrite the equation above as<br />
$BR<br />
$BR<br />
\( \displaystyle \sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot \Big( \)<br />
\{ ans_rule(20) \}<br />
\( \Big) \) <br />
END_TEXT<br />
<br />
ANS( Formula("1-cos(t)")->cmp() );<br />
<br />
}<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Part 1:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
if ($part == 2) {<br />
<br />
BEGIN_TEXT<br />
${BBOLD}Part 2 of 3:${EBOLD}<br />
$BR<br />
$BR<br />
Step 0: <br />
\( <br />
\displaystyle <br />
\frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }.<br />
\)<br />
$BR<br />
$BR<br />
Step 1: <br />
\( \displaystyle<br />
\sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot ( 1 - \cos(t) ).<br />
\)<br />
$BR<br />
$HR<br />
$BR<br />
We may use algebra to rewrite the equation from Step 1 as<br />
$BR<br />
$BR<br />
\( \sin(t) \cdot \big( \)<br />
\{ ans_rule(20) \}<br />
\( \big) = \big(1+\cos(t)\big) \cdot \big(1-\cos(t)\big) \).<br />
END_TEXT<br />
<br />
ANS( Formula("sin(t)")->cmp() );<br />
<br />
}<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Part 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
if ($part == 3) {<br />
<br />
BEGIN_TEXT<br />
${BBOLD}Part 3 of 3:${EBOLD} <br />
$BR<br />
$BR<br />
Step 0: <br />
\( <br />
\displaystyle <br />
\frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }.<br />
\)<br />
$BR<br />
$BR<br />
Step 1: <br />
\( \displaystyle<br />
\sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot ( 1 - \cos(t) ).<br />
\)<br />
$BR<br />
$BR<br />
Step 2:<br />
\( \displaystyle <br />
\sin(t) \sin(t) = (1+\cos(t))(1-\cos(t))<br />
\)<br />
$BR<br />
$HR<br />
$BR<br />
Finally, using algebra we may rewrite the equation from step 2 as<br />
$BR<br />
$BR<br />
\( \sin^2(t) = \)<br />
\{ ans_rule(20) \}<br />
$BR<br />
$BR<br />
which is true since \( \cos^2(t) + \sin^2(t) = 1 \).<br />
Thus, the original identity can be derived <br />
by reversing these steps.<br />
END_TEXT<br />
<br />
ANS( Formula("1-(cos(t))^2")->cmp() );<br />
<br />
}<br />
<br />
<br />
END_PROBLEM();<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Part 3:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ProvingTrigIdentities1&diff=23810ProvingTrigIdentities12023-07-18T11:56:34Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Trig/ProvingTrigIdentities.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Proving Trig Identities</h2><br />
<br />
[[File:ProvingTrigIdentities1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to write a multi-part question in which each new part is revealed only after the previous part is answered correctly. The parts are revealed sequentially on the same html page instead of each part having its own html page. We also cleverly redefine the sine function to require students to simplify their answers when applying well-known trig identities. This example is deprecated because the <code>scaffold.pl</code> macro file provides a better solution.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities1.pg FortLewis/Authoring/Templates/Trig/ProvingTrigIdentities1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->are(t=>"Real");<br />
<br />
#<br />
# Redefine the sin(x) to be e^(pi x)<br />
#<br />
Context()->functions->remove("sin");<br />
package NewFunc;<br />
# this next line makes the function a <br />
# function from reals to reals<br />
our @ISA = qw(Parser::Function::numeric);<br />
sub sin {<br />
shift; my $x = shift;<br />
return CORE::exp($x*3.1415926535);<br />
}<br />
package main;<br />
# Make it work on formulas as well as numbers<br />
#sub cos {Parser::Function->call('cos',@_)} # if uncommented, this line will generate error messages<br />
# Add the new functions to the Context<br />
Context()->functions->add( sin => {class => 'NewFunc', TeX => '\sin'}, );<br />
<br />
<br />
#<br />
# You manually define the answers<br />
#<br />
@answers = ();<br />
$answers[1] = Formula("1-cos(t)");<br />
$answers[2] = Formula("sin(t)");<br />
$answers[3] = Formula("1-(cos(t))^2");<br />
<br />
<br />
#<br />
# Automatic configuration for answer evaluation<br />
#<br />
@ans_eval = ();<br />
@scores = ();<br />
foreach my $i (1..$#answers) {<br />
$ans_eval[$i] = $answers[$i] ->cmp();<br />
$ans_hash[$i] = $ans_eval[$i]->evaluate($inputs_ref->{ANS_NUM_TO_NAME($i)});<br />
$scores[$i] = $ans_hash[$i]->{score};<br />
}<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
${BBOLD}Part 1 of 3:${EBOLD}<br />
$BR<br />
$BR<br />
In this multi-part problem, we will use algebra to verify <br />
the identity<br />
$BCENTER<br />
\( \displaystyle \frac{ \sin(t) }{ 1-\cos(t) } = \frac{ 1+\cos(t) }{ \sin(t) }. \)<br />
$ECENTER<br />
$BR<br />
First, using algebra we may rewrite the equation above as<br />
$BR<br />
$BR<br />
\( \displaystyle \sin(t) = \left( \frac{1+\cos(t)}{\sin(t)} \right) \cdot \Big( \)<br />
\{ ans_rule(20) \}<br />
\( \Big) \) <br />
END_TEXT<br />
Context()->normalStrings;<br />
<br />
ANS( $ans_eval[1] );<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text and Answer Evaluation Part 1:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
if ($scores[1]==1) {<br />
<br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
$PAR<br />
$HR<br />
${BBOLD}Part 2 of 3:${EBOLD} <br />
$BR<br />
$BR<br />
Then, using algebra we may rewrite the equation as<br />
$BR<br />
$BR<br />
\( \sin(t) \cdot \big( \)<br />
\{ ans_rule(20) \}<br />
\( \big) = \big(1+\cos(t)\big) \cdot \big(1-\cos(t)\big) \),<br />
END_TEXT<br />
Context()->normalStrings;<br />
<br />
ANS( $ans_eval[2] );<br />
<br />
} # end if<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Main Text and Answer Evaluation Part 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
if ( ($scores[1]==1) && ($scores[2]==1) ) {<br />
<br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
$PAR<br />
$HR<br />
${BBOLD}Part 3 of 3:${EBOLD} <br />
$BR<br />
$BR<br />
Finally, using algebra we may rewrite the equation as<br />
$BR<br />
$BR<br />
\( \sin^2(t) = \)<br />
\{ ans_rule(20) \}<br />
$BR<br />
$BR<br />
which is true since \( \cos^2(t) + \sin^2(t) = 1 \).<br />
Thus, the original identity can be derived <br />
by reversing these steps.<br />
END_TEXT<br />
Context()->normalStrings;<br />
<br />
ANS( $ans_eval[3] );<br />
<br />
} # end if<br />
<br />
<br />
COMMENT("MathObject version. This is a multi-part problem <br />
in which the next part is revealed only after the previous <br />
part is correct. Prevents students from entering trivial <br />
identities (entering what they were given)");<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Main Text and Answer Evaluation Part 3:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=DomainRange1&diff=23809DomainRange12023-07-18T11:54:14Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/DomainRange.html a newer version of this problem]</p><br />
<br />
<h2>Domain and Range of a Function</h2><br />
<br />
[[File:DomainRange1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to evaluate answers that are inequalities which use different variables.<br />
</p><br />
<!--* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DomainRange1.pg FortLewis/Authoring/Templates/Precalc/DomainRange1.pg]--><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DomainRange1_PGML.pg FortLewis/Authoring/Templates/Precalc/DomainRange1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'contextInequalities.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We must load <code>contextInequalities.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
$f = Compute('sqrt(x-4)');<br />
<br />
Context('Inequalities-Only')->variables->are(x=>'Real');<br />
Context()->flags->set(formatStudentAnswer=>'parsed');<br />
<br />
$domain = Compute('x >= 4');<br />
<br />
# the context needs to change for the range<br />
Context('Inequalities-Only')->variables->are(y=>'Real');<br />
Context()->flags->set(formatStudentAnswer=>'parsed');<br />
$range = Compute('y >= 0');<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We specify the context in a way that requires students to enter their answer using inequalities and the variable x. If we had used <code>Context("Inequalities")</code> instead, then students would also be able to enter answers using interval notation. For more details, please see [http://webwork.maa.org/pod/pg/macros/contextInequalities.html contextInequalities.pl]<br />
</p><br />
<p><br />
We use <code>formatStudentAnswer=>'parsed'</code> and <code>Compute()</code> so that the student's answer are left as fractions rather than reduced to decimals.<br />
</p><br />
<p>For the domain, since the variable is now <tt>y</tt>, we must reset the context and the variable so that students must enter the variable y in their answer.</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Suppose [` f(x) = [$f] `]. Enter inequalities for the<br />
domain and range of [` f `].<br />
<br />
- Domain: [_______]{$domain}<br />
<br />
- Range: [_________________]{$range}<br />
<br />
[@ helpLink('inequalities') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorParametricLines1&diff=23808VectorParametricLines12023-07-18T11:52:53Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/VectorParametricLines.html a newer version of this problem]</p><br />
<br />
<h2>Vector Parametric Lines</h2><br />
<br />
[[File:VectorParametricLines1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to require students to enter a parametrized line that must go through certain points when t=0 and t=1, or allow them to enter an equation for any parametric line through two points.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametricLines1.pg FortLewis/Authoring/Templates/Parametric/VectorParametricLines1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametricLines1_PGML.pg FortLewis/Authoring/Templates/Parametric/VectorParametricLines1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"parserParametricLine.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserVectorUtils.pl</code> which provides the <code>Line()</code> subroutine for a particular parametrization of a line, as well as <code>parserParametricLine.pl</code> which provides a subroutine <code>ParametricLine()</code> that allows students to enter any parametrization.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Vector")->variables->are(t=>"Real");<br />
<br />
$P = non_zero_point3D(-9,9,1);<br />
$V = non_zero_vector3D(-9,9,1);<br />
<br />
$Q = Point($P + $V);<br />
<br />
$particular = Line($P,$V,'t');<br />
$general = ParametricLine($P,$V);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
For the answer which is a particular parametrization through two points at times t=0 and t=1, we use <code>Line()</code>. To allow students to enter any equation for a parametric line through two points, we use <code>ParametricLine()</code> The syntax is fairly self-explanatory.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
(a) Find a vector parametric equation for the <br />
line that goes through the point \( $P \) <br />
when \( t = 0 \) and the point \( $Q \) when<br />
\( t = 1 \).<br />
$BR<br />
\( \vec{L}(t) = \)<br />
\{ ans_rule(30) \}<br />
$BR<br />
$BR<br />
(b) Find any vector parametric equation for the <br />
line that goes through the points \( $P \) and <br />
\( $Q \).<br />
$BR<br />
\( \vec{L}(t) = \)<br />
\{ ans_rule(30) \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $particular->cmp() );<br />
ANS( $general->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorParametric2&diff=23807VectorParametric22023-07-18T11:52:19Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/VectorParametricDerivative.html a newer version of this problem]</p><br />
<br />
<h2>Motion and Velocity with a Parametric Curve</h2><br />
<br />
[[File:VectorParametric2.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to construct a custom answer checker that extracts the component functions from the student's answer and makes some derivative calculations with them.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg FortLewis/Authoring/Templates/Parametric/VectorParametric2.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg FortLewis/Authoring/Templates/Parametric/VectorParametric2_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"AnswerFormatHelp.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Although not necessary for the code below, we load <code>parserVectorUtils.pl</code> because you may want to use some of its methods when you use this template file.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Vector2D");<br />
#Context("Vector"); # for 3d vectors<br />
Context()->variables->are(t=>"Real");<br />
Context()->variables->set(t=>{limits=>[0,5]});<br />
Context()->flags->set( ijk=>0, ijkAnyDimension => 1 );<br />
<br />
$answer = Vector("<2t,(2t)^2>");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We choose not to display the answer using ijk notation. Also, use <code>ijkAnyDimension => 1</code> to require a dimension match between i,j,k vectors and either the student or the correct answer when doing vector operations.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Find a vector parametric function \( \vec{r}(t) \) <br />
for a bug that moves along the parabola \( y = x^2 \) <br />
with velocity \( \vec{v}(t) = \langle 2, 8t \rangle \) <br />
for all \( t \).<br />
$BR<br />
$BR<br />
\( \vec{r}(t) = \) <br />
\{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("vectors") \} <br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
sub mycheck {<br />
my ($correct, $student, $ansHash) = @_;<br />
my $xstu = $student . Vector(1,0);<br />
my $ystu = $student . Vector(0,1);<br />
if ( ($xstu->D('t')==Formula("2")) &&<br />
($ystu->D('t')==Formula("8t")) )<br />
{ return 1; } else { return 0; } <br />
}<br />
<br />
ANS( $answer->cmp( checker=>~~&mycheck ) );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
Use dot products of the student answer with the vectors <code>Vector(1,0)</code> and <code>Vector(0,1)</code> to get the components <code>$xstu</code> and <code>$ystu</code> of the student answer. Then, we can differentiate the components just like any MathObject formula. Notice that the argument to <code>cmp( checker => ~~&mycheck )</code> is our subroutine that is a custom answer checker.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorParametric1&diff=23806VectorParametric12023-07-18T11:51:05Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/VectorParametricFunction.html a newer version of this problem]</p><br />
<br />
<h2>A Vector Parametric Curve in the Plane</h2><br />
<br />
[[File:VectorParametric1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask students for a vector parametric curve through two points and allows them to specify the time interval.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric1.pg FortLewis/Authoring/Templates/Parametric/VectorParametric1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/VectorParametric1_PGML.pg FortLewis/Authoring/Templates/Parametric/VectorParametric1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"parserMultiAnswer.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Since it is a vector parametric curve, we will want vector utilities from <code>parserVectorUtils.pl</code>. Since we will need to check multiple answer blanks that depend upon each other, we use <code>parserMultiAnswer.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Vector2D");<br />
#Context("Vector"); # for 3D vectors<br />
Context()->variables->are(t=>"Real");<br />
Context()->variables->set(t=>{limits=>[0,5]});<br />
Context()->flags->set( ijk=>0 );<br />
<br />
$a = random(2,5,1);<br />
$Q = Point($a,$a**2);<br />
<br />
<br />
$multians = MultiAnswer(Vector("<t,t**2>"),0,$a)->with(<br />
singleResult => 1,<br />
<br />
checker => sub {<br />
<br />
my ($correct,$student,$self) = @_; # get the parameters<br />
my ($f,$x1,$x2) = @{$student}; # extract student answers<br />
if ( <br />
( ($f . i)**2 == ($f . j) )<br />
&& ($f->eval(t=>$x1) == Vector("<0,0>")) <br />
&& ($f->eval(t=>$x2) == Vector("<$a,$a**2>")) <br />
) { <br />
return 1; <br />
} elsif (<br />
( ($f . i)**2 == ($f . j) )<br />
&& ($f->eval(t=>$x1) == Vector("<0,0>")) <br />
) {<br />
$self->setMessage(3,"Your right endpoint is not correct."); <br />
return 0; <br />
} elsif (<br />
( ($f . i)**2 == ($f . j) )<br />
&& ($f->eval(t=>$x2) == Vector("<$a,$a**2>")) <br />
) {<br />
$self->setMessage(2,"Your left endpoint is not correct."); <br />
return 0; <br />
} elsif (<br />
( ($f . i)**2 == ($f . j) )<br />
) {<br />
$self->setMessage(2,"Your left endpoint is not correct."); <br />
$self->setMessage(3,"Your right endpoint is not correct."); <br />
return 0;<br />
} else { return 0; }<br />
<br />
<br />
}<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
The student's vector-valued function is stored in <code>$f</code>. To get the x- and y-components of the students answer we dot it with the standard basis vectors using <code>$f . i</code> and <code>$f . j</code>. Note: If you want to differentiate the component functions in the student's answer, you'll need to use a different method as <code>($f . i)->D('t')</code> will generate errors since the dot product does not get evaluated. Another problem given in this section describes how to extract formulas from the components of the student's answer, which can then be differentiated. Notice that we have given the students helpful feedback messages about which endpoints are incorrect.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Find a vector parametric equation for the parabola<br />
\( y = x^2 \) from the origin to the point <br />
\( $Q \) using \( t \) as a parameter.<br />
$BR<br />
$BR<br />
\( \vec{r}(t) = \) <br />
\{$multians->ans_rule(20)\} <br />
for <br />
\{$multians->ans_rule(5)\} <br />
\( \leq t \leq \) <br />
\{$multians->ans_rule(5)\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $multians->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT(); <br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Spacecurve1&diff=23805Spacecurve12023-07-18T11:50:30Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SpaceCurve.html a newer version of this problem]</p><br />
<br />
<h2>A Parametric Curve in Space</h2><br />
<br />
[[File:Spacecurve1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask a parametric curve question with three answer blanks and use MultiAnswer to check the answer.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1_PGML.pg FortLewis/Authoring/Templates/Parametric/Spacecurve1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'parserMultiAnswer.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Since we will have multiple answer blanks that depend on each other, we need to use <code>parserMultiAnswer.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(t=>"Real");<br />
Context()->variables->set(t=>{limits=>[0,10]});<br />
<br />
$a = random(-5,-2,1);<br />
$x = Formula("$a * t**2");<br />
$y = Formula("0");<br />
$z = Formula("t");<br />
<br />
$multians = MultiAnswer($x, $y, $z)->with(<br />
singleResult => 1,<br />
checker => sub {<br />
my ( $correct, $student, $self ) = @_;<br />
my ( $xstu, $ystu, $zstu ) = @{$student};<br />
return 0 unless $xstu->isFormula;<br />
if (($xstu==$a*$zstu**2) && ($ystu==0)) {<br />
return 1;<br />
} else {<br />
return 0;<br />
}<br />
}<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We use <code>singleResult =&gt; 1</code> since it doesn't make sense to say that <code>x(t)</code> is correct but <code>z(t)</code> is incorrect since they depend on one another. First, we check that the student hasn't fed us a bogus constant solution such as <code>x=y=z=0</code> by requiring the x-coordinate to be a formula (not a constant) via <code>return 0 unless $xstu->isFormula;</code>. Then, we check that the student's answers satisfy the parametric equation.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Find a parametrization of the curve [` x = [$a] z^2 `]<br />
in the [`xz`]-plane. Use [` t `] as the<br />
parameter for all of your answers.<br />
<br />
- [` x(t) = `] [______________]{$multians}<br />
- [` y(t) = `] [______________]{$multians}<br />
- [` z(t) = `] [______________]{$multians}<br />
<br />
[@ helpLink('formulas') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Notice that we use <code>$multians</code> in each answer blank because they results in the three answers are dependent on each other.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=SurfaceGraph1&diff=23804SurfaceGraph12023-07-18T11:49:53Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SurfaceGraph.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Graphing a Parametric Surface in 3D</h2><br />
<br />
[[File:SurfaceGraph1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to make an interactive graph of a parametric surface that is displayed using the LiveGraphics3D Java applet. It is deprecated because Java is no longer universally supported on all web browsers and platforms.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/SurfaceGraph1 FortLewis/Authoring/Templates/Parametric/SurfaceGraph1/SurfaceGraph1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"LiveGraphicsParametricSurface3D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>LiveGraphicsParametricSurface3D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
Context()->variables->are(x=>"Real",y=>"Real",z=>"Real",u=>"Real",v=>"Real");<br />
<br />
$plot = ParametricSurface3D(<br />
Fx => Formula("3*cos(u)*sin(v)"),<br />
Fy => Formula("3*sin(u)*sin(v)"),<br />
Fz => Formula("3*cos(v)"),<br />
uvar => 'u', # theta<br />
vvar => 'v', # phi<br />
umin => 0,<br />
umax => 2*pi,<br />
vmin => 0,<br />
vmax => pi,<br />
usamples => 15,<br />
vsamples => 15,<br />
axesframed => 1,<br />
xaxislabel => "X",<br />
yaxislabel => "Y",<br />
zaxislabel => "Z",<br />
mesh => 0,<br />
outputtype => 4,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{ <br />
Live3Ddata(<br />
$plot,<br />
image => "sphere.png", <br />
size => [400,400],<br />
tex_size => 600,<br />
tex_center => 1,<br />
scale => 1.1,<br />
);<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We generate a string of plot data using <code>ParametricSurface3D()</code>. <br />
</p><br />
<p><br />
Setting <code>outputtype</code> to something other than 4 will require you to read the source code of <code>LiveGraphicsParametricSurface3D.pl</code> and familiarize yourself with the details of the <code>LiveGraphics3D</code> java applet. For more information on how to work with the string of plot data, see Martin Kraus's [http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/ LiveGraphics3D homepage], and the excellent article by Jonathan Rogness and Martin Kraus [http://mathdl.maa.org/mathDL/55/?pa=content&sa=viewDocument&nodeId=1143&pf=1 Constructing Mathlets Quickly Using LiveGraphics3D].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=SpacecurveGraph1&diff=23803SpacecurveGraph12023-07-18T11:48:25Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/SpaceCurve.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Interactive Graph of a Parametric Curve in 3D Space</h2><br />
<br />
[[File:SpacecurveGraph1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to make an interactive graph of a parametric curve in 3D space that is displayed using the LiveGraphics3D Java applet. It is deprecated because Java is no longer universally supported on all web browsers and platforms.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/SpacecurveGraph1 FortLewis/Authoring/Templates/Parametric/SpacecurveGraph1/SpacecurveGraph1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"LiveGraphicsParametricCurve3D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macro file <code>LiveGraphicsParametricCurve3D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(x=>"Real",y=>"Real",z=>"Real",t=>"Real");<br />
<br />
$plot = ParametricCurve3D(<br />
Fx => Formula("t*cos(t)"),<br />
Fy => Formula("t*sin(t)"),<br />
Fz => Formula("t"),<br />
tvar => "t",<br />
tmin => 0,<br />
tmax => 10,<br />
tsamples => 50,<br />
axesframed => 1,<br />
xaxislabel => "X",<br />
yaxislabel => "Y",<br />
zaxislabel => "Z",<br />
outputtype => 4,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We generate a string of plot data using <code>ParametricCurve()</code>. <br />
</p><br />
<p><br />
Setting <code>outputtype</code> to something other than 4 will require you to read the source code of <code>LiveGraphicsParametricCurve3D.pl</code> and familiarize yourself with the details of the <code>LiveGraphics3D</code> java applet. For more information on how to work with the string of plot data, see Martin Kraus's [http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/ LiveGraphics3D homepage], and the excellent article by Jonathan Rogness and Martin Kraus [http://mathdl.maa.org/mathDL/55/?pa=content&sa=viewDocument&nodeId=1143&pf=1 Constructing Mathlets Quickly Using LiveGraphics3D].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{ <br />
Live3Ddata(<br />
$plot,<br />
image => "spiral.png", <br />
size => [400,400],<br />
tex_size => 600,<br />
tex_center => 1,<br />
scale => 1.1,<br />
);<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
To display the string of plot data <code>$plot</code>, we use the <code>Live3Ddata()</code> routine provided by the macro <code>LiveGraphics3D.pl</code>, which is loaded automatically.<br />
</p><br />
<p><br />
After you construct the graph you like, <b>don't forget to take a screen shot of it and make an image file such as <code>spiral.png</code> that will be used in the pdf hardcopy.</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=SeriesTest1&diff=23802SeriesTest12023-07-18T11:45:27Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/SeriesTest.html a newer version of this problem]</p><br />
<br />
<h2>Requiring Students to Justify Series Tests</h2><br />
<br />
[[File:SeriesTest1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to require students to justify series tests.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/SeriesTest1.pg FortLewis/Authoring/Templates/Sequences/SeriesTest1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/SeriesTest1_PGML.pg FortLewis/Authoring/Templates/Sequences/SeriesTest1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"unionTables.pl",<br />
"parserPopUp.pl",<br />
"PGgraders.pl",<br />
"parserMultiAnswer.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>unionTables.pl</code> to create a table in which answer blanks are stacked on top of each other to form a fraction. We use <code>PGgraders.pl</code> to give partial credit incrementally. We use <code>parserMultiAnswer.pl</code> for the fraction answer so that we can accept two correct answers, depending on how much a student has simplified their answer.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->are(n=>"Real");<br />
<br />
$a = random(2,9,1);<br />
$b = random(2,9,1);<br />
$c = random(5,20,1);<br />
$d = random(3,9,1);<br />
$e = random(2,9,1);<br />
<br />
$dm1 = $d - 1;<br />
$dm2 = $d - 2;<br />
<br />
<br />
# TeX<br />
$series = "\sum_{n=$c}^{\infty} \frac{$a n + $b}{$c n^{$d} + $e}";<br />
$fraction = "\lim_{n\to\infty} \frac{a_n}{b_n} = \lim_{n\to\infty}";<br />
<br />
$num1 = Formula("$a n^$d + $b n^$dm1");<br />
$den1 = Formula("$c n^$d + $e");<br />
<br />
$num2 = Formula("$a + $b/n");<br />
$den2 = Formula("$c + $e/(n^$d)"); <br />
<br />
$multians = MultiAnswer($num1, $den1)->with(<br />
singleResult => 0,<br />
checker => sub {<br />
my ( $correct, $student, $ansHash ) = @_;<br />
my ( $stu1, $stu2 ) = @{$student}; <br />
<br />
if (($num1 == $stu1 && $den1 == $stu2) ||<br />
($num2 == $stu1 && $den2 == $stu2) ) {<br />
return [1,1];<br />
} elsif (($num1 == $stu1 && $den2 == $stu2) || <br />
($num2 == $stu1 && $den1 == $stu2)) {<br />
$ansHash->setMessage(1,"Check your algebra");<br />
$ansHash->setMessage(2,"Check your algebra");<br />
return [0,0];<br />
} elsif ($num1 == $stu1 || $num2 == $stu1) {<br />
return [1,0];<br />
} elsif ($den1 == $stu2 || $den2 == $stu2) {<br />
return [0,1];<br />
} else {<br />
return [0,0];<br />
}<br />
}<br />
);<br />
<br />
<br />
$limit = Formula("$a/$c");<br />
$popup = PopUp(["Choose","Converges","Diverges","Inconclusive"],"Converges");<br />
<br />
<br />
# <br />
# Display the fraction and answer blanks nicely<br />
#<br />
Context()->texStrings;<br />
if ($displayMode eq 'TeX') {<br />
$showfraction =<br />
"\[ $fraction ".$multians->ans_rule(10).$multians->ans_rule(10)." \]";<br />
} else {<br />
$showfraction =<br />
ColumnTable(<br />
"\( \displaystyle $fraction \)",<br />
$multians->ans_rule(20).$BR.$HR.$multians->ans_rule(20),<br />
indent => 0, separation => 10, valign => "MIDDLE"<br />
);<br />
}<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We use the MultiAnswer object <code>$multians</code> to allow students to enter one of two correct answers. We could have also accomplished this using two custom answer checkers.<br />
</p><br />
<p><br />
We display the answerblanks nicely as a fraction in HTML and TeX modes by how we constructed <code>$showfraction</code>. <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Use the limit comparison test to determine whether <br />
\( \displaystyle \sum_{n=$c}^{\infty} a_n = $series \) <br />
converges or diverges.<br />
$BR<br />
$BR<br />
(a) Choose a series \( \displaystyle \sum_{n=$c}^\infty b_n \) <br />
with terms of the form \( \displaystyle b_n = \frac{1}{n^p} \) <br />
and apply the limit comparison test.<br />
Write your answer as a fully reduced fraction.<br />
For \( n \geq $c \), <br />
$showfraction<br />
$BR<br />
(b) Evaluate the limit in the previous part. Enter \( \infty \) <br />
as ${BITALIC}infinity${EITALIC} and \( -\infty \) <br />
as ${BITALIC}-infinity.${EITALIC} If the limit does not exist, <br />
enter ${BITALIC}DNE.${EITALIC}<br />
$BR$SPACE<br />
\( \displaystyle \lim_{n\to\infty} \frac{a_{n}}{b_{n}} \, \) = <br />
\{ ans_rule(20) \}<br />
$BR<br />
$BR<br />
(c) By the limit comparison test, does the series<br />
converge, diverge, or is the test inconclusive?<br />
\{ $popup->menu() \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers=1;<br />
<br />
install_problem_grader(~~&custom_problem_grader_fluid);<br />
<br />
$ENV{'grader_numright'} = [2,4];<br />
$ENV{'grader_scores'} = [0.4,1];<br />
$ENV{'grader_message'} = "You can earn " .<br />
"40% partial credit for 2 - 3 correct answers.";<br />
<br />
ANS( $multians->cmp() );<br />
ANS( $limit->cmp() );<br />
ANS( $popup->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
We use the problem grader fluid to give partial credit incrementally: 0% for 0-1 correct answers, 40% for 2-3 correct answers, and full credit for 4 correct answers.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ExplicitSequence1&diff=23801ExplicitSequence12023-07-18T11:44:55Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/ExplicitSequence.html a newer version of this problem]</p><br />
<br />
<h2>Sequences with Explicit Formulas</h2><br />
<br />
[[File:ExplicitSequence1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to evaluate answers that are (possibly alternating) sequences with explicit formulas.<br />
</p><br />
<!--* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/ExplicitSequence1.pg FortLewis/Authoring/Templates/Sequences/ExplicitSequence1.pg]--><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/ExplicitSequence1_PGML.pg FortLewis/Authoring/Templates/Sequences/ExplicitSequence1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros('PGstandard.pl','MathObjects.pl','PGML.pl','PGcourse.pl');<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Numeric');<br />
Context()->variables->are(n=>'Real');<br />
<br />
$answer = Compute("(-1)^n / n!");<br />
$answer->{test_points} = [[1],[2],[3],[4],[5],[6]];<br />
<br />
$sequence = 'a_0=1, a_1 = -1, a_2 = \frac{1}{2}, a_3 = -\frac{1}{6}'<br />
. 'a_4 = \frac{1}{24}, a_5 = -\frac{1}{120}, \ldots';<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We set the test points to be positive integers to avoid errors when evaluating the answer. Even if you expect students to enter answers such as <code>cos(pi * n) / n!</code>, you should still restrict the domain to positive integers, because some students may simplify this to <code>(-1)^n / n!</code> and receive errors because the answer checker is substituting things such as <code>n=0.5</code> into their formula.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Find a formula for [` n^{th} `] term of the sequence [` [$sequence] `].<br />
<br />
[` a_n = `] [__________________]{$answer}<br />
<br />
[@ helpLink('formulas') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=RecursiveSequence1&diff=23800RecursiveSequence12023-07-18T11:44:13Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/RecursiveSequence.html a newer version of this problem]</p><br />
<br />
<h2>Sequences and Recursively Defined Functions</h2><br />
<br />
[[File:RecursiveSequence1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to add a named function to the context and use it to ask students to come up with a recursive formula.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/RecursiveSequence1.pg FortLewis/Authoring/Templates/Sequences/RecursiveSequence1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/RecursiveSequence1_PGML.pg FortLewis/Authoring/Templates/Sequences/RecursiveSequence1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserFunction.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We will be defining a new named function and adding it to the context, and the easiest way to do this is using <code>parserFunction.pl</code>. There is a more basic way to add functions to the context, which is explained in example 2 at<br />
[http://webwork.maa.org/wiki/AddingFunctions AddingFunctions]<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->are(n=>"Real");<br />
parserFunction(f => "sin(pi^n)+e");<br />
<br />
$fn = Formula("3 f(n-1) + 2");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We define a new named function <code>f</code> as something the student is unlikely to guess. The named function <code>f</code> is, in some sense, just a placeholder since the student will enter expressions involving <code>f(n-1)</code>, WeBWorK will interpret it internally as <code>sin(pi^(n-1))+e</code>, and the only thing the student sees is <code>f(n-1)</code>. If the <br />
recursion has an closed-form solution (e.g., the Fibonacci numbers are given by f(n) = (a^n - (1-a)^n)/sqrt(5) where a = (1+sqrt(5))/2) and you want to allows students to enter the closed-form solution, it would be good to define f using that explicit solution in case the student tries to answer the question by writing out the explicit solution (a^n - (1-a)^n)/sqrt(5) instead of using the shorthand f(n).<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
The current value \( f(n) \) is three <br />
times the previous value, plus two. Find<br />
a recursive definition for \( f(n) \). <br />
Enter \( f_{n-1} \) as \( f(n-1) \).<br />
$BR<br />
\( f(n) \) = \{ ans_rule(20) \} <br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We should tell students to use function notation rather than subscript notation so that they aren't confused about syntax.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers=1;<br />
<br />
ANS( $fn->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
<br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=AnswerOrderedList1&diff=23799AnswerOrderedList12023-07-18T11:43:41Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/AnswerOrderedList.html a newer version of this problem]</p><br />
<br />
<h2>Answer is an Ordered List</h2><br />
<br />
[[File:AnswerOrderedList1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to write a question in which the answer is an ordered list, such as a sequence of numbers.<br />
</p><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/AnswerOrderedList1_PGML.pg FortLewis/Authoring/Templates/Sequences/AnswerOrderedList1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
@seq = ();<br />
$seq[0] = 1;<br />
$seq[1] = 1;<br />
foreach my $i (2..6) {<br />
$seq[$i] = $seq[$i-1] + $seq[$i-2];<br />
}<br />
<br />
$answer_string = join(', ',@seq);<br />
$answer_cmp = Compute("$answer_string")->cmp(ordered=>1);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We create an empty array <code>@seq</code> and then fill it with scalars using direct assignment and a foreach loop. Since the entries in the array <code>@seq</code> do not have commas between them, we create a Perl string <code>$answer</code> that joins the entries of the array <code>@seq</code> by a comma followed by a space <code>", "</code>. Then, we make this string a MathObject by putting <code>Compute()</code> around it.<br />
</p><br />
<p><br />
Since the answer is a MathObject List, which is by default unordered, we must specify that the answer checker use <code>ordered=&gt;1</code><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
If [` s_1 = [$seq[0]] `], [` s_2 = [$seq[1]] `], and<br />
[` s_n = s_{n-1} + s_{n-2} `], find the first seven<br />
terms of this sequence, including [` s_1 `] and<br />
[` s_2 `]. Enter your answer as a comma separated<br />
list of numbers.<br />
<br />
Sequence = [_____]{$answer_cmp}<br />
<br />
[@ helpLink('numbers') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Graph3DCylindrical1&diff=23798Graph3DCylindrical12023-07-18T10:33:12Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/CylindricalGraph3D.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Interactive Graphs of Functions in Cylindrical Coordinates</h2><br />
<br />
[[File:Graph3DCylindrical1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to make an interactive graph of a function in cylindrical coordinates that is displayed using the LiveGraphics3D Java applet. It is deprecated because Java is no longer universally supported on all web browsers and platforms.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalcMV/Graph3DCylindrical1 FortLewis/Authoring/Templates/DiffCalcMV/Graph3DCylindrical1/Graph3DCylindrical1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"PGcourse.pl",<br />
"LiveGraphicsCylindricalPlot3D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>LiveGraphicsCylindricalPlot3D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(x=>"Real",y=>"Real",r=>"Real",t=>"Real");<br />
<br />
$a = random(2,4,1);<br />
<br />
$plot = CylindricalPlot3D(<br />
function => Formula("$a*cos((r^2)/4)"),<br />
rvar => "r",<br />
tvar => "t",<br />
rmin => 0,<br />
rmax => 6,<br />
tmin => 0,<br />
tmax => 2*pi,<br />
rsamples => 20,<br />
tsamples => 15,<br />
axesframed => 1,<br />
xaxislabel => "X",<br />
yaxislabel => "Y",<br />
zaxislabel => "Z",<br />
outputtype => 4,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We generate a string of plot data using <code>CylindricalPlot3D()</code>.<br />
</p><br />
<p><br />
Setting <code>outputtype</code> to something other than 4 will require you to read the source code of <code>LiveGraphicsCylindricalPlot3D.pl</code> and familiarize yourself with the details of the <code>LiveGraphics3D</code> java applet. For more information on how to work with the string of plot data, see Martin Kraus's [http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/ LiveGraphics3D homepage], and the excellent article by Jonathan Rogness and Martin Kraus [http://mathdl.maa.org/mathDL/55/?pa=content&sa=viewDocument&nodeId=1143&pf=1 Constructing Mathlets Quickly Using LiveGraphics3D].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{ <br />
Live3Ddata(<br />
$plot,<br />
image => "bell-shape.png", <br />
size => [400,400],<br />
tex_size => 600,<br />
tex_center => 1,<br />
scale => 1.1,<br />
);<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
To display the string of plot data <code>$plot</code>, we use the <code>Live3Ddata()</code> routine provided by the macro <code>LiveGraphics3D.pl</code>, which is loaded automatically.<br />
</p><br />
<p><br />
After you construct the graph you like, <b>don't forget to take a screen shot of it and make an image file such as <code>bell-shape.png</code> that will be used in the pdf hardcopy.</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Graph3DRectangular1&diff=23797Graph3DRectangular12023-07-18T10:32:31Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/RectangularGraph3D.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Interactive Graph of a Function in Rectangular Coordinates in 3D</h2><br />
<br />
[[File:Graph3DRectangular1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to use the LiveGraphics3D Java applet to display an interactive graph of a function in rectangular coordinates. It is deprecated because Java is no longer universally supported on all web browsers and platforms.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalcMV/Graph3DRectangular1 FortLewis/Authoring/Templates/DiffCalcMV/Graph3DRectangular1/Graph3DRectangular1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
<br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserPopUp.pl",<br />
"LiveGraphicsRectangularPlot3D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>LiveGraphicsRectangularPlot3D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
Context()->variables->are(x=>"Real",y=>"Real",r=>"Real",s=>"Real",t=>"Real");<br />
<br />
$a = - random(-1,1,2);<br />
<br />
$plot = RectangularPlot3DRectangularDomain(<br />
function => Formula("t^2+$a*s^2"),<br />
xvar => "s",<br />
yvar => "t",<br />
xmin => -2,<br />
xmax => 2,<br />
ymin => -2,<br />
ymax => 2,<br />
xsamples => 10,<br />
ysamples => 10,<br />
axesframed => 1,<br />
xaxislabel => "S",<br />
yaxislabel => "T",<br />
zaxislabel => "Z",<br />
outputtype => 4,<br />
);<br />
<br />
if ( $a == -1) {<br />
$im = "hyperbolic-paraboloid.png";<br />
$pop = PopUp(<br />
["Choose","Paraboloid","Hyperbolic paraboloid"],<br />
"Hyperbolic paraboloid");<br />
} else {<br />
$im = "paraboloid.png";<br />
$pop = PopUp(<br />
["Choose","Paraboloid","Hyperbolic paraboloid"],<br />
"Paraboloid");<br />
}<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We generate a string of plot data using <code>RectangularPlot3DRectangularDomain()</code>. <br />
</p><br />
<p><br />
Setting <code>outputtype</code> to something other than 4 will require you to read the source code of <code>LiveGraphicsRectangularPlot3D.pl</code> and familiarize yourself with the details of the <code>LiveGraphics3D</code> java applet. For more information on how to work with the string of plot data, see Martin Kraus's [http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/ LiveGraphics3D homepage], and the excellent article by Jonathan Rogness and Martin Kraus [http://mathdl.maa.org/mathDL/55/?pa=content&sa=viewDocument&nodeId=1143&pf=1 Constructing Mathlets Quickly Using LiveGraphics3D].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
The graph below is called a <br />
\{ $pop->menu() \}<br />
$PAR<br />
$BCENTER<br />
\{ <br />
Live3Ddata(<br />
$plot,<br />
image => $im, <br />
size => [400,400],<br />
tex_size => 600,<br />
tex_center => 1,<br />
scale => 1.1,<br />
);<br />
\}<br />
$ECENTER<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
To display the string of plot data <code>$plot</code>, we use the <code>Live3Ddata()</code> routine provided by the macro <code>LiveGraphics3D.pl</code>, which is loaded automatically.<br />
</p><br />
<p><br />
After you construct the graph you like, <b>don't forget to take a screen shot of it and make image files such as <code>hyperbolic-paraboloid.png</code> and <code>paraboloid.png</code> that will be used in the pdf hardcopy.</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $pop->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ImplicitPlane1&diff=23796ImplicitPlane12023-07-18T10:30:39Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffCalcMV/ImplicitPlane.html a newer version of this problem]</p><br />
<br />
<h2>Answer is an Equation for a Line or Plane</h2><br />
<br />
[[File:ImplicitPlane1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to define an answer that is a line or plane.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalcMV/ImplicitPlane1.pg FortLewis/Authoring/Templates/DiffCalcMV/ImplicitPlane1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalcMV/ImplicitPlane1_PGML.pg FortLewis/Authoring/Templates/DiffCalcMV/ImplicitPlane1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'parserImplicitPlane.pl',<br />
'parserVectorUtils.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
); <br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
<br />
* The <tt>parserVectorUtils.pl</tt> macro is used for the <tt>non_zero_point3D</tt> function below.<br />
* The <tt>parserImplicitPlane.pl</tt> macro includes the context and the <tt>ImplicitPlane</tt> function to parse and create implicit planes. <br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('ImplicitPlane');<br />
Context()->variables->are(x=>'Real',y=>'Real', z=> 'Real');<br />
<br />
$A = non_zero_point3D(-5,5,1);<br />
$N = non_zero_vector3D(-5,5,1);<br />
<br />
$answer1 = ImplicitPlane($A,$N);<br />
$answer2 = ImplicitPlane('4x+3y=12');<br />
$answer3 = ImplicitPlane('x=3');<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
The first answer is a standard mulitivariable calculus question. There are several different ways to specify the input to <code>ImplicitPlane</code>, which are detailed in the [http://webwork.maa.org/pod/pg/macros/parserImplicitPlane.html POD documentation]. It is also possible to do some more complicated manipulations with the vectors and points, which is detailed in the [http://webwork.maa.org/wiki/ImplicitPlane problem techniques section].<br />
</p><br />
<p><br />
When the <code>ImplicitPlane</code> context has only two variables, it rephrases error messages in terms of lines. If you want students to be able to enter an equation for a line in the most general form, or if you have a vertical line to check (or just a constant equation such as <code>x=3</code>), you can use the <code>ImplicitPlane</code> context to reliably check these answers. <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
a. Enter an equation for the plane through the point [` [$A] `] and perpendicular to [` [$N] `].<br />
<br />
+ [______________]{$answer1}<br />
<br />
b. Enter an equation for the line in the [` xy `]-plane with [` x `]-intercept [` 3 `] and [` y `]-intercept [` 4 `].<br />
<br />
+ [______________]{$answer2}<br />
<br />
c. Enter an equation for the vertical line in the [` xy `]-plane through the point [` (3,1) `].<br />
<br />
+ [______________]{$answer3}<br />
<br />
[@ helpLink('equation') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=DoubleIntegral1&diff=23795DoubleIntegral12023-07-18T10:29:55Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/DoubleIntegral.html a newer version of this problem]</p><br />
<br />
<h2>Setting up a Double Integral</h2><br />
<br />
[[File:DoubleIntegral1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to allow students to set up a double integral and integrate in either order.<br />
</p><br />
<!-- * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalcMV/DoubleIntegral1.pg FortLewis/Authoring/Templates/IntegralCalcMV/DoubleIntegral1.pg] --><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalcMV/DoubleIntegral1_PGML.pg FortLewis/Authoring/Templates/IntegralCalcMV/DoubleIntegral1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserMultiAnswer.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Since there are multiple answer blanks that are dependent upon each other, we use <code>parserMultiAnswer.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Numeric');<br />
Context()->variables->are(<br />
x => 'Real',<br />
dx => 'Real',<br />
y => 'Real',<br />
dy => 'Real'<br />
);<br />
Context()->flags->set(reduceConstants => 0);<br />
<br />
#<br />
# limits of integration<br />
#<br />
$a = random(1, 5, 1);<br />
$b = $a + random(1, 4, 1);<br />
do { $c = random(1, 5, 1); } until ($c != $a);<br />
do { $d = $c + random(1, 4, 1); } until ($d != $b);<br />
<br />
#<br />
# integrand and volume<br />
#<br />
$f = Formula('x*y');<br />
$V = Formula("($b^2-$a^2) * ($d^2-$c^2) / 4");<br />
<br />
#<br />
# differentials and limits of integration<br />
#<br />
# Case 0, element 0 of each array below, is<br />
# if the order of integration is dx dy<br />
#<br />
# Case 1, element 1 of each array below, is<br />
# if the order of integration is dy dx<br />
#<br />
# 'id' and 'od' stand for inner and outer differential<br />
#<br />
@id = (Formula('dx'), Formula('dy')); # (case 0, case 1)<br />
@od = (Formula('dy'), Formula('dx')); # (case 0, case 1)<br />
#<br />
# A = outer integral, lower limit<br />
# B = outer integral, upper limit<br />
# C = inner integral, lower limit<br />
# D = inner integral, upper limit<br />
#<br />
@A = (Formula("$c"), Formula("$a")); # (case 0, case 1)<br />
@B = (Formula("$d"), Formula("$b")); # (case 0, case 1)<br />
@C = (Formula("$a"), Formula("$c")); # (case 0, case 1)<br />
@D = (Formula("$b"), Formula("$d")); # (case 0, case 1)<br />
<br />
$multians = MultiAnswer($f, $id[0], $od[0], $A[0], $B[0], $C[0], $D[0])->with(<br />
singleResult => 1,<br />
checker => sub {<br />
my ($correct, $student, $self) = @_;<br />
my ($fstu, $idstu, $odstu, $Astu, $Bstu, $Cstu, $Dstu) = @{$student};<br />
if (<br />
(<br />
$f == $fstu<br />
&& $id[0] == $idstu<br />
&& $od[0] == $odstu<br />
&& $A[0] == $Astu<br />
&& $B[0] == $Bstu<br />
&& $C[0] == $Cstu<br />
&& $D[0] == $Dstu<br />
)<br />
|| ($f == $fstu<br />
&& $id[1] == $idstu<br />
&& $od[1] == $odstu<br />
&& $A[1] == $Astu<br />
&& $B[1] == $Bstu<br />
&& $C[1] == $Cstu<br />
&& $D[1] == $Dstu)<br />
)<br />
{<br />
return 1;<br />
} elsif (<br />
(<br />
$f == $fstu<br />
&& $id[0] == $idstu<br />
&& $od[0] == $odstu<br />
&& ($A[0] != $Astu || $B[0] != $Bstu)<br />
&& $C[0] == $Cstu<br />
&& $D[0] == $Dstu<br />
)<br />
|| ($f == $fstu<br />
&& $id[1] == $idstu<br />
&& $od[1] == $odstu<br />
&& ($A[1] != $Astu || $B[1] != $Bstu)<br />
&& $C[1] == $Cstu<br />
&& $D[1] == $Dstu)<br />
|| ($f == $fstu<br />
&& $id[0] == $idstu<br />
&& $od[0] == $odstu<br />
&& $A[0] == $Astu<br />
&& $B[0] == $Bstu<br />
&& ($C[0] != $Cstu || $D[0] != $Dstu))<br />
|| ($f == $fstu<br />
&& $id[1] == $idstu<br />
&& $od[1] == $odstu<br />
&& $A[1] == $Astu<br />
&& $B[1] == $Bstu<br />
&& ($C[1] != $Cstu || $D[1] != $Dstu))<br />
)<br />
{<br />
$self->setMessage(1, 'Check your limits of integration.');<br />
return 0.94;<br />
} elsif (<br />
(<br />
$f == $fstu<br />
&& $id[0] == $idstu<br />
&& $od[0] == $odstu<br />
&& ($A[0] != $Astu || $B[0] != $Bstu)<br />
&& ($C[0] != $Cstu || $D[0] != $Dstu)<br />
)<br />
|| ($f == $fstu<br />
&& $id[1] == $idstu<br />
&& $od[1] == $odstu<br />
&& ($A[1] != $Astu || $B[1] != $Bstu)<br />
&& ($C[1] != $Cstu || $D[1] != $Dstu))<br />
)<br />
{<br />
$self->setMessage(1, 'Check your limits of integration and order of integration.');<br />
return 0.47;<br />
} else {<br />
return 0;<br />
}<br />
}<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
There are two separate cases: integrating with respect to <code>dx dy</code> (which we call case 0) or with respect to <code>dy dx</code> (which we call case 1). The zeroth and first entries in each of the arrays <code>@id, @od, @A, @B, @C, @D</code> hold the values for case 0 and case 1, respectively. We used constant limits of integration to keep this example easy to follow, but we encourage you to write questions over non-rectangular regions.<br />
</p><br />
<p><br />
The <code>$multians</code> object has been compartmentalized, so you shouldn't need to change it unless you want to fiddle with the weighted score for each answer blank (by changing the return values). The return values are set so that the percentages come out nicely.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Set up a double integral in rectangular coordinates<br />
for calculating the volume of the solid under the<br />
graph of the function [` f(x,y) = [$f] `] over the<br />
region [` [$a] \leq x \leq [$b] `] and [` [$c] \leq y \leq [$d] `].<br />
<br />
_Instructions:_<br />
Please enter the integrand in the first answer box.<br />
Depending on the order of integration you choose,<br />
enter _dx_ and _dy_<br />
in either order into the second and third answer boxes<br />
with only one _dx_ or _dy_ in each box.<br />
Then, enter the limits of<br />
integration and evaluate the integral to find the volume.<br />
<br />
[`` \int_A^B \int_C^D ``]<br />
[___________]{$multians} [_____]{$multians} [_____]{$multians}<br />
<br />
A = [_____________]{$multians}<br />
B = [_____________]{$multians}<br />
C = [_____________]{$multians}<br />
D = [_____________]{$multians}<br />
<br />
Volume = [___________________________]{$V}<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
The only interesting thing to note here is that you must use <code>$multians</code> for each answer blank (except the last one, which is independent.)<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
COMMENT('Allows integration in either order. Uses PGML.');<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorFieldGraph3D1&diff=23794VectorFieldGraph3D12023-07-18T10:29:19Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.html a newer version of this problem]</p><br />
<br />
<h2>Deprecated: Graphing a Vector Field in Space</h2><br />
<br />
[[File:VectorFieldGraph3D1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to make an interactive graph of a vector field displayed with the LiveGraphics3D Java applet. This example is deprecated because it uses Java, which is not universally supported by all web browsers.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph3D1 FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph3D1/VectorFieldGraph3D1.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"PGcourse.pl",<br />
"LiveGraphicsVectorField3D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>LiveGraphicsVectorField3D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
Context()->variables->are(x=>"Real",y=>"Real",z=>"Real");<br />
<br />
$plot = VectorField3D(<br />
Fx => Formula("x"),<br />
Fy => Formula("y"),<br />
Fz => Formula("z"),<br />
xvar => 'x',<br />
yvar => 'y',<br />
zvar => 'z',<br />
xmin => -1,<br />
xmax => 1,<br />
ymin => -1,<br />
ymax => 1,<br />
zmin => -1,<br />
zmax => 1,<br />
xsamples => 4,<br />
ysamples => 4,<br />
zsamples => 4,<br />
axesframed => 1,<br />
xaxislabel => "X",<br />
yaxislabel => "Y",<br />
zaxislabel => "Z",<br />
vectorcolor => "RGBColor[0.0,0.0,1.0]",<br />
vectorscale => 0.2,<br />
vectorthickness => 0.01,<br />
outputtype => 4,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
The <code>VectorField3D()</code> routine returns a string of plot data consisting of a list of line segments (the vectors) along with other plot options. The arguments <code>RGBColor[a,b,c]</code> are numbers a, b, and c between 0 and 1 inclusive. You can uniformly scale all of the vectors in the vector field by the same amount using <code>vectorscale</code>. The <code>outputtype</code> feature controls how much of the string of plot data is generated, and setting it equal to 4 generates all of the plot information necessary to be displayed.<br />
</p><br />
<p><br />
Setting <code>outputtype</code> to something other than 4 will require you to read the source code of <code>LiveGraphicsVectorField3D.pl</code> and familiarize yourself with the details of the <code>LiveGraphics3D</code> java applet. For more information on how to work with the string of plot data, see Martin Kraus's [http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/ LiveGraphics3D homepage], and the excellent article by Jonathan Rogness and Martin Kraus [http://mathdl.maa.org/mathDL/55/?pa=content&sa=viewDocument&nodeId=1143&pf=1 Constructing Mathlets Quickly Using LiveGraphics3D].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
$BCENTER<br />
\{ <br />
Live3Ddata(<br />
$plot,<br />
image => "exploding-vector-field.png", <br />
size => [400,400],<br />
tex_size => 600,<br />
tex_center => 1,<br />
scale => 1.25,<br />
);<br />
\}<br />
$ECENTER<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
To display the string of plot data <code>$plot</code>, we use the <code>Live3Ddata()</code> routine provided by the macro <code>LiveGraphics3D.pl</code>, which is automatically loaded by <code>LiveGraphicsVectorField3D.pl</code>.<br />
</p><br />
<p><br />
After you construct the vector field you like, <b>don't forget to take a screen shot of it and make an image file such as <code>exploding-vector-field.png</code> that will be used in the pdf hardcopy.</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorOperations1&diff=23793VectorOperations12023-07-18T10:28:31Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/VectorOperations.html a newer version of this problem]</p><br />
<br />
<h2>Vector Operations</h2><br />
<br />
[[File:VectorOperations1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to extract the components of a constant vector, take dot and cross products of vectors, find the length of a vector, construct a unit vector, and check whether the student's answer is parallel to or in the same direction as another vector.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc FortLewis/Authoring/Templates/VectorCalc/VectorOperations1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc/VectorOperations1_PGML.pg FortLewis/Authoring/Templates/VectorCalc/VectorOperations1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserVectorUtils.pl",<br />
"unionLists.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserVectorUtils.pl</code> to have access to functions on vectors like <code>norm</code> and <code>unit</code>. Since this question has many parts, we use <code>unionLists.pl</code> to display it nicely.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Vector");<br />
<br />
$U = non_zero_vector3D(-9,9,1);<br />
$V = non_zero_vector3D(-9,9,1);<br />
<br />
# value works only for vectors of constants<br />
@Uarray = $U->value; <br />
$Ucomp2 = $Uarray[1];<br />
<br />
$UdotV = $U . $V;<br />
$UcrossV = $U x $V;<br />
$Vlength = norm( $V );<br />
$Vunit = unit($V);<br />
<br />
#<br />
# Prevent students from entering the dot and <br />
# cross products, and the vector functions<br />
# norm and unit.<br />
#<br />
Context()->operators->undefine(".","><");<br />
Context()->functions->disable("Vector");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We use <code>non_zero_vector3D(low,high,increment)</code> to randomly generate some vectors. Calling <code>$U-&gt;value</code> returns a (Perl) array of numbers. (Note that <code>-&gt;value</code> does not work on a vector whose components are non-constant formulas.) MathObjects defines the operators <code> . </code> and <code>x</code> to be the dot product and cross product when they occur between two vectors (that is, these operations are overloaded). The functions <code>norm</code> and <code>unit</code> calculate the length of a vector and a unit vector in the same direction. We undefine the dot and cross product as well as the functions norm and unit so that students cannot enter them in their answers. <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Suppose \( \vec{u} = $U \) and \( \vec{v} = $V \). <br />
\{ BeginList('OL', type=>'A') \}<br />
<br />
$ITEM The second component of \( \vec{u} \) is <br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM \( \vec{u} \cdot \vec{v} = \) <br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM \( \vec{u} \times \vec{v} = \) <br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM \( \left|\left| \vec{v} \right|\right| = \) <br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM Enter a unit vector in the direction of \( \vec{v} \).<br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM Enter a vector parallel to \( \vec{v} \).<br />
\{ ans_rule(20) \}<br />
<br />
$ITEMSEP<br />
$ITEM Enter a vector in the same direction as \( \vec{v} \).<br />
\{ ans_rule(20) \}<br />
<br />
\{ EndList('OL') \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
<br />
ANS( $Ucomp2->cmp() );<br />
ANS( $UdotV->cmp() );<br />
ANS( $UcrossV->cmp() );<br />
ANS( $Vlength->cmp() );<br />
ANS( $Vunit->cmp() );<br />
ANS( $V->cmp( parallel=>1 ) );<br />
ANS( $V->cmp( parallel=>1, sameDirection=>1 ) );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
In the last two answers we set flags for checking whether the student's answer is parallel to or in the same direction as the correct answer. Notice that both flags <code>parallel=&gt;1, sameDirection=&gt;1</code> must be set in the last answer.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=GeneralSolutionODE1&diff=23792GeneralSolutionODE12023-07-18T10:27:43Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffEq/GeneralSolutionODE.html a newer version of this problem]</p><br />
<br />
<h2>General Solutions to ODEs with Arbitrary Constants</h2><br />
<br />
[[File:GeneralSolutionODE1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to write a custom answer checker for ODEs questions where the answer is an equation of the form <code>y = c1 f1(x) + c2 f2(x) + c3 f3(x)</code> for some arbitrary constants <code>c1, c2, c3</code>.<br />
</p><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffEq/GeneralSolutionODE1_PGML.pg FortLewis/Authoring/Templates/DiffEq/GeneralSolutionODE1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros('PGstandard.pl','MathObjects.pl','PGML.pl',<br />
'parserAssignment.pl','PGcourse.pl');<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserAssignment.pl</code> to require student answers to be of the form <code>y = ...</code>.<br />
Please see the POD documentation [http://webwork.maa.org/pod/pg/macros/parserAssignment.html parserAssignment.pl].<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
'MathObjects.pl','PGML.pl',<br />
'parserAssignment.pl','PGcourse.pl');<br />
<br />
TEXT(beginproblem());<br />
$showPartialCorrectAnswers = 1;<br />
<br />
Context('Numeric');<br />
Context()->variables->add(<br />
c1=>'Real',c2=>'Real',c3=>'Real',y=>'Real',<br />
);<br />
Context()->variables->set(<br />
c1=>{limits=>[2,4]},<br />
c2=>{limits=>[2,4]},<br />
c3=>{limits=>[2,4]}<br />
);<br />
Context()->flags->set(<br />
formatStudentAnswer=>'parsed',<br />
reduceConstants=>0,<br />
reduceConstantFunctions=>0,<br />
);<br />
parser::Assignment->Allow;<br />
<br />
$a = list_random(2,3,5,6,7,8);<br />
<br />
# char poly (r-1)(r^2 + $a)<br />
<br />
$answer = Compute("y = c1 e^x + c2 cos(sqrt($a) x) + c3 sin(sqrt($a) x)");<br />
<br />
$cmp = $answer->cmp( checker => sub {<br />
<br />
my ( $correct, $student, $answerHash ) = @_;<br />
my $stu = Formula($student->{tree}{rop});<br />
<br />
#################################<br />
# Check for arbitrary constants<br />
#<br />
Value->Error("Is your answer the most general solution?")<br />
if (<br />
Formula($stu->D('c1'))==Formula(0) ||<br />
Formula($stu->D('c2'))==Formula(0) ||<br />
Formula($stu->D('c3'))==Formula(0)<br />
);<br />
<br />
# Linear independence (Wronskian)<br />
my $x = Real(1.43);<br />
<br />
my $a11 = $stu->eval('c1'=>1,'c2'=>0,'c3'=>0,x=>$x,y=>0);<br />
my $a12 = $stu->eval('c1'=>0,'c2'=>1,'c3'=>0,x=>$x,y=>0);<br />
my $a13 = $stu->eval('c1'=>0,'c2'=>0,'c3'=>1,x=>$x,y=>0);<br />
<br />
my $a21 = $stu->D('x')->eval('c1'=>1,'c2'=>0,'c3'=>0,x=>$x,y=>0);<br />
my $a22 = $stu->D('x')->eval('c1'=>0,'c2'=>1,'c3'=>0,x=>$x,y=>0);<br />
my $a23 = $stu->D('x')->eval('c1'=>0,'c2'=>0,'c3'=>1,x=>$x,y=>0);<br />
<br />
my $a31 = $stu->D('x','x')->eval('c1'=>1,'c2'=>0,'c3'=>0,x=>$x,y=>0);<br />
my $a32 = $stu->D('x','x')->eval('c1'=>0,'c2'=>1,'c3'=>0,x=>$x,y=>0);<br />
my $a33 = $stu->D('x','x')->eval('c1'=>0,'c2'=>0,'c3'=>1,x=>$x,y=>0);<br />
<br />
Value->Error("Your functions are not linearly independent or your answer is not complete")<br />
if (($a11*($a22*$a33-$a32*$a23)+$a13*($a21*$a32-$a31*$a22)) == ($a12*($a21*$a33-$a31*$a23)));<br />
<br />
<br />
# Check that the student answer is a solution to the DE<br />
my $stu1 = Formula($stu->D('x'));<br />
my $stu2 = Formula($stu->D('x','x'));<br />
my $stu3 = Formula($stu->D('x','x','x'));<br />
return ($stu3 + $a * $stu1) == ($stu2 + $a * $stu);<br />
<br />
});<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Add the arbitrary constants <code>c1, c2, c3</code> to the context as variables so that we can<br />
evaluate them later. Set the domain of function evaluation on these variables to something<br />
sensible. Use <code>parser::Assignment->Allow;</code> to allow equation answers of the form <br />
<code>y = ...</code>. <br />
</p><br />
<p>For the <code>checker</code>, we use <code>my $stu = Formula($student->{tree}{rop});</code> to get the right side of the <br />
student answer (to get the left side, we could have used <code>lop</code> for the left operand).<br />
Use <code>Formula($stu->D('c1'))==Formula(0)</code> to check that the student actually has <br />
<code>c1</code> in their answer.<br />
</p><br />
<p><br />
We substitute numerical values that the student is unlikely to choose for <code>c1, c2, c3</code> and<br />
then apply the Wronskian test for independence. Normally, we would check to see if the Wronskian<br />
was zero, but zero level tolerance in WeBWorK is much more stringent than non-zero level tolerance. <br />
So, we rearrange the terms of the Wronskian == 0 equation so that there are nonzero terms on both sides<br />
of the equation, and as a result we get a more reliable answer checker.<br />
</p><br />
<p><br />
Finally, we take several derivatives of the student answer and use them to check that the student <br />
answer actually satisfies the differential equation. Again, instead of checking (left side of ODE) == 0,<br />
we rearrange the terms of the differential equation to be of the form (some nonzero function) == (some other nonzero function)<br />
in order to get a more reliable answer checker.<br />
</p><br />
<br />
<br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Find the general solution to<br />
[` y^{\,\prime\prime\prime} - y^{\,\prime\prime} + [$a] y^{\,\prime} - [$a] y = 0 `].<br />
<br />
In your answer, use [` c_1, c_2 `] and [` c_3 `] to denote arbitrary constants and [` x `]<br />
the independent variable. Your answer should be an equation of the form [`y = \ldots`] and<br />
you should enter [` c_1 `] as [| c1 |]*,<br />
[` c_2 `] as [| c2 |]*, and<br />
[` c_3 `] as [| c3 |]*.<br />
<br />
[_________________________________]{$cmp}<br />
<br />
[@ helpLink('equations') @]*<br />
END_PGML<br />
<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Give students detailed instructions about the format<br />
of the answer that is expected.<br />
</p><br />
</td><br />
</tr><br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=HeavisideStep1&diff=23791HeavisideStep12023-07-18T10:27:10Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffEq/HeavisideStep.html a newer version of this problem]</p><br />
<br />
<h2>Using the Heaviside Step Function</h2><br />
<br />
[[File:HeavisideStep1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to add a the Heaviside step function <code>step(x)</code>, which takes the value 1 if x &gt; 0, and the value 0 if x &le; 0, to the context. It also shows how to add a named function <code>u(x)</code> to the context that has a reliable answer checker and can stand in for the Heaviside step function when the student answer is a function.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffEq/HeavisideStep1.pg FortLewis/Authoring/Templates/DiffEq/HeavisideStep1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffEq/HeavisideStep1_PGML.pg FortLewis/Authoring/Templates/DiffEq/HeavisideStep1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
"parserFunction.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserFunction.pl</code> to make adding a named function to the context easier.<br />
Please see the POD documentation [http://webwork.maa.org/pod/pg/macros/parserFunction.html parserFunction.pl].<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(t=>"Real");<br />
Context()->functions->add(<br />
step => {<br />
class => 'Parser::Legacy::Numeric',<br />
perl => 'Parser::Legacy::Numeric::do_step'<br />
},<br />
);<br />
<br />
$a = 3;<br />
<br />
$ftex = "5 u(t-$a)";<br />
<br />
$fstep = Formula("5*step(t-$a)");<br />
<br />
$answer1 = List($fstep->eval(t=>2),$fstep->eval(t=>3),$fstep->eval(t=>4));<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup 1:</b> <br />
We add the step function to the context with the name <code>step</code>. The function <code>step(t)</code> is the Heaviside function and takes the value 1 when t &gt; 0, and the value 0 when t &le; 0. We will use the function <code>step</code> when evaluating the Heaviside function to obtain an answer that is a number.<br />
</p><br />
<p><br />
For more details on adding the Heaviside function to the context, see the forum discussion on the [http://webwork.maa.org/moodle/mod/forum/discuss.php?d=458 Heaviside step function]<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Let \( u(t) \) be the Heaviside step function <br />
defined by<br />
\( \displaystyle<br />
u(t) =<br />
\left\lbrace<br />
\begin{array}{lcl}<br />
0 && \mbox{ if } x \leq 0, \\<br />
1 && \mbox{ if } x > 0.<br />
\end{array}<br />
\right.<br />
\)<br />
$BR<br />
$BR<br />
(a) Evaluate the function \( $ftex \) when <br />
\( t \) is \(2\), \(3\), and \(4\) and enter <br />
your answers as a comma separated list.<br />
$BR<br />
\{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("numbers") \} <br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text 1:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers=1;<br />
<br />
ANS( $answer1->cmp(ordered=>1) );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation 1:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(t=>"Real");<br />
Context()->functions->add(<br />
step => {<br />
class => 'Parser::Legacy::Numeric',<br />
perl => 'Parser::Legacy::Numeric::do_step'<br />
},<br />
);<br />
<br />
parserFunction("u(t)" => "step(t)");<br />
$f = Formula("5 u(t-$a)");<br />
<br />
$answer2 = $f->with(<br />
limits=>[$a-5,$a+5], <br />
test_at => [[$a-1],[$a],[$a+0.0000001],[$a+1]],<br />
num_points=>10,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup 2:</b><br />
We reset the context using <code>Context("Numeric")</code> and add the function <code>step(t)</code> as before. The reason for resetting the context is that in part (a) of the question we don't want to allow students to type in <code>u(2),u(3),u(4)</code> and get the right answer, because we want students to evaluate the Heaviside function themselves.<br />
</p><br />
<p><br />
Using a different method for adding functions to the context, we add the named function <code>u(t)</code> using <code>parserFunction</code> and make it identical to the function <code>step(t)</code>. The reason for adding <code>u(t)</code> to the context is that students will then be able to enter it as a named function in their answer.<br />
</p><br />
<p><br />
Since answers are checked numerically by comparing the student answer to the correct answer at several randomly points in the domain (the default is 5 points) in an interval (the default is [-1,1]), the function <code>step(t) = u(t)</code> is not very robust when checking answers using these defaults. For example, if a student types in the answer <code>u(t-0.1)</code> and the correct answer is <code>u(t)</code>, there is a good chance that the student's answer will be marked correct, since the probability that a test point was chosen in the interval <code>(0,0.1)</code> is much less than 100%. Also, if the correct answer were <code>u(t-5)</code>, then a student could enter the answer <code>0</code> and be marked correct because the correct answer is identically zero on the interval <code>[-1,1]</code>.<br />
</p><br />
<p><br />
To make the answer checking robust, in <code>$answer2</code> we specify a larger domain centered at <code>$a</code> using <code>limits</code>, we require four of the test points always be used, and that there should be 10 test points total (the four we specified and six others generated at random). Notice that we used the construction <code>$f->with(...)</code> to do this (using <code>$f->{test_at} = [[1],[2]]</code> would generate an error because the functions we added to the context aren't "blessed" with enough permissions to modify <code>$f</code> in that way).<br />
</p><br />
<p><br />
In part (b), since the students never actually see the values of the function <code>u(t)</code>, we could have defined the function as <br />
<pre><br />
parserFunction("u(t)" => <br />
"1.5 * sin(e*t) + 5*pi/3 + arctan(t)"<br />
);<br />
</pre><br />
If we had defined <code>u(t)</code> this way, we would not have had to add the function <code>step(t)</code> to the context and we could have used the defaults for the answer checker. Notice that the function <code>u(t)</code> is never zero, is not constant, is differentiable, and takes moderately sized values, which makes its answer checking very robust using the defaults for the answer checker. Further, because of the arctangent, it is not periodic and so <code>u(t)-u(t-a)</code> should never be identically zero. Also, the formula for <code>u(t)</code> is not something students are likely to input as an answer out of nowhere. The function <code>u(t)</code> is great as a named function that stands in for the Heaviside function when the answer is a function. However, if the answer is a number obtained by evaluating the Heaviside function, then <code>step(t)</code> should be used or the function <code>u(t)</code> should be properly defined as the Heaviside function for obvious reasons. <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
$BR<br />
$BR<br />
(b) Suppose the answer is the function \( $ftex \).<br />
$BR<br />
\{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("formulas") \} <br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
ANS( $answer2->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=RowOperations1&diff=23790RowOperations12023-07-18T10:26:03Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/RowOperations.html a newer version of this problem]</p><br />
<br />
<h2>Row Operations</h2><br />
<br />
[[File:RowOperations1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask students to compute the result of elementary row operations.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/RowOperations1.pg FortLewis/Authoring/Templates/LinAlg/RowOperations1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/RowOperations1_PGML.pg FortLewis/Authoring/Templates/LinAlg/RowOperations1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGcourse.pl",<br />
);<br />
$showPartialCorrectAnswers = 0;<br />
TEXT(beginproblem()); <br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
do {<br />
<br />
$A = Matrix([<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
]);<br />
<br />
} until (($A->row(1) != $A->row(2)) && <br />
($A->row(1) != $A->row(3)) && <br />
($A->row(2) != $A->row(3)));<br />
<br />
$k = random(2,9,1);<br />
<br />
$op = "R_{1} + $k R_{2} \rightarrow R_{1}";<br />
<br />
$answer = Matrix([<br />
$A->row(1) + $k*($A->row(2)),<br />
$A->row(2),<br />
$A->row(3),<br />
]);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Construct a matrix with three distinct rows.<br />
Create a string <code>$op</code> of Tex code that describes the row operation.<br />
Use <code>$A->row(i)</code> to extract the ith row of the matrix A as a MathObject.<br />
Use <code>$A->row(1) + $k*($A->row(2))</code> to perform the row operation and place it into the first row of the answer matrix.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Give the result of applying the row operation \( $op \) to the given matrix.<br />
$BR<br />
$BR<br />
\( $A {\displaystyle\mathop{\longrightarrow}^{$op}} \)<br />
\{ $answer->ans_array \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
<br />
ANS( $answer->cmp() );<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=MatrixCustomAnswerChecker1&diff=23789MatrixCustomAnswerChecker12023-07-18T10:25:28Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixCustomAnswerChecker.html a newer version of this problem]</p><br />
<br />
<h2>Matrices and Custom Answer Checkers</h2><br />
<br />
[[File:MatrixCustomAnswerChecker1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to use a multianswer answer checker to evaluate an open-ended question about matrices.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixCustomAnswerChecker1.pg FortLewis/Authoring/Templates/LinAlg/MatrixCustomAnswerChecker1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixCustomAnswerChecker1_PGML.pg FortLewis/Authoring/Templates/LinAlg/MatrixCustomAnswerChecker1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserMultiAnswer.pl",<br />
"AnswerFormatHelp.pl",<br />
"PGcourse.pl",<br />
);<br />
$showPartialCorrectAnswers = 0;<br />
TEXT(beginproblem()); <br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
$A = Matrix([[1,1],[0,1]]);<br />
$B = Matrix([[1,0],[1,1]]);<br />
<br />
$multians = MultiAnswer($A, $B)->with(<br />
singleResult => 1,<br />
checker => sub {<br />
my ( $correct, $student, $answerHash ) = @_;<br />
my @s = @{$student};<br />
$s0 = Matrix($s[0]); <br />
$s1 = Matrix($s[1]);<br />
return $s0 * $s1 != $s1 * $s0;<br />
}<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Construct two matrices <code>$A</code> and <code>$B</code> that do not commute and therefore serve as a correct answer.<br />
Use a <code>$multians</code> object with a custom answer checker subroutine.<br />
The answer checker uses <code>my ( $correct, $student, $answerHash ) = @_;</code> to grab the inputs (the correct answer, the student answer, and the answer hash table info).<br />
Then, put the student's two answers into an array <code>@s</code> using <code>my @s = @{$student};</code>.<br />
Make sure the student's first matrix <code>$s[0]</code> is converted to a MathObject matrix <code>$s0</code> using <code>$s0 = Matrix($s[0]);</code> and similarly for the student's second matrix.<br />
The return value, which is boolean, is the truth value of the statement <code>$s0 * $s1 != $s1 * $s0</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Give an example of two \( 2 \times 2 \) matrices \( A \) and \( B \)<br />
such that \( AB \ne BA \).<br />
$BR<br />
$BR<br />
\( A = \)<br />
\{ $multians->ans_array(5) \}<br />
$BR<br />
$BR<br />
\( B = \)<br />
\{ $multians->ans_array(5) \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Make sure that <b>both</b> answer arrays are called as methods on the <code>$multians</code> object (i.e., <code>$multians->ans_array(5)</code> should be called for each answer array.<br />
Note that <code>ans_array(w)</code> produces an answer array of boxes each <code>w</code> characters wide.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
install_problem_grader(~~&std_problem_grader);<br />
<br />
ANS( $multians->cmp() );<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=MatrixOperations1&diff=23788MatrixOperations12023-07-18T10:24:53Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixOperations.html a newer version of this problem]</p><br />
<br />
<h2>Matrix Operations</h2><br />
<br />
[[File:MatrixOperations1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to assess whether a student knows whether two matrices can be multiplied and, when the matrix product exists, what the dimensions of a matrix product are.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixOperations1_PGML.pg FortLewis/Authoring/Templates/LinAlg/MatrixOperations1_PGML.pg]<br />
* More problems like this in the OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/Hope/Multi1/02-01-Matrix-operations/ Hope/Multi1/02-01-Matrix-operations/]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"parserPopUp.pl",<br />
"AnswerFormatHelp.pl",<br />
"PGcourse.pl",<br />
);<br />
$showPartialCorrectAnswers = 0;<br />
TEXT(beginproblem()); <br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We use <code>parserPopUp.pl</code> for the multiple choice part of the question.<br />
Use <code>$showPartialCorrectAnswers = 0;</code> to withhold feedback (we will use an all-or-nothing answer grader).<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
$A = Matrix([<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
]);<br />
<br />
$B = Matrix([<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
[non_zero_random(-5,5,1),non_zero_random(-5,5,1),non_zero_random(-5,5,1)],<br />
]);<br />
<br />
$popup = PopUp(['Choose','True','False'],'False');<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Create two 2 by 3 matrices and a true/false popup.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Let <br />
\[ A = $A,\]<br />
\[ B = $B.\]<br />
If possible, compute the following. <br />
If an answer does not exist, enter ${BBOLD}DNE${EBOLD}.<br />
$BR<br />
$BR<br />
\( AB = \)<br />
\{ ans_box(3,30).$SPACE.AnswerFormatHelp('matrices') \}<br />
$BR<br />
$BR<br />
\( BA = \)<br />
\{ ans_box(3,30).$SPACE.AnswerFormatHelp('matrices') \}<br />
$BR<br />
$BR<br />
\{ $popup->menu \} True or False: For any two matrices <br />
\( A \) and \( B \), both of the products \( AB \) and \( BA \) <br />
are always defined.<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Use <code>ans_box(rows,cols)</code> so that students must find the matrix product dimensions themselves, if the matrix product exists.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
install_problem_grader(~~&std_problem_grader);<br />
<br />
ANS( ($A * $B)->cmp() );<br />
ANS( Compute('DNE')->cmp() );<br />
ANS( $popup->cmp );<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
Use the standard problem grader, which awards full credit only when all answers are correct and zero credit otherwise. Although it would have been better coding practice to construct the matrix product <code>$A * $B</code> in the Setup section, we did it in the answer section just to show you that it was possible to break "the rules". Standard matrix operations such as <code>+, -, *</code> can be used whenever the matrix operation makes sense.<br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=MatrixAnswer2&diff=23787MatrixAnswer22023-07-18T10:24:20Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixAnswer2.html a newer version of this problem]</p><br />
<br />
<br />
<br />
<h2>Matrix Answer 2</h2><br />
<br />
[[File:MatrixAnswer2.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to collect matrix answers using one textbox for the entire matrix a student enters.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2.pg FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2_PGML.pg FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2_PGML.pg]<br />
<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGcourse.pl",<br />
);<br />
<br />
TEXT(beginproblem()); <br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
$example1 = Matrix([[1,2,3],[4,5,6]]);<br />
$example2 = $example1->column(1);<br />
$example3 = $example1->row(1);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup 1:</b> <br />
We construct a 2 by 3 matrix and extract its first column and first row.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
The purpose of this question is to show you the syntax needed to enter <br />
matrices in WeBWorK when there is only one answer box for entering a matrix <br />
(which is not obvious) <br />
or when there are multiple answer boxes for entering a matrix (which is obvious).<br />
The examples below should be self-explanatory, so you can jump to them if you want;<br />
however, a detailed explanation follows if you want to read more.<br />
$BR<br />
$BR<br />
Matrices use square brackets to enclose items in lists. <br />
A matrix with one row, such as a row vector, is a comma separated list enclosed by square brackets.<br />
A matrix with more than one row or a column vector is a comma separated list of lists, where each list <br />
uses square brackets to enclose its items.<br />
Your answers must use square brackets to enclose each row in a matrix or in a<br />
column vector. Also, a pair of square brackets is needed to enclose<br />
a matrix with more than one row (e.g., a \( 2 \times 3 \) matrix<br />
and a \( 2 \times 1 \) column vector have multiple rows so they need extra <br />
square brackets, but a \( 1 \times 3 \) row vector has only one row so it does<br />
not need extra square brackets). Your answers may have spaces and line breaks in them, <br />
such as <br />
$PAR<br />
$BCENTER<br />
[ [1, 2, 3], $BR [4, 5, 6] ]<br />
$ECENTER<br />
$BR<br />
$BR<br />
Enter the matrix \( $example1 \) as \{ $example1->string \}<br />
$BR<br />
\{ ans_box(3,30) \}<br />
$BR<br />
$BR<br />
Enter the column vector \( $example2 \) as \{ $example2->string \}<br />
$BR<br />
\{ ans_box(3,30) \}<br />
$BR<br />
$BR<br />
Enter the row vector \( $example3 \) as \{ $example3->string \}<br />
$BR<br />
\{ ans_box(3,30) \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text 1:</b><br />
Use <code>$matrix->string</code> to get the string representation of the matrix (i.e., the string answer the student needs to type in) and <code>ans_box(rows,cols)</code> to create a re-sizable text box for the student to enter their answer.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $example1->cmp() );<br />
ANS( $example2->cmp() );<br />
ANS( $example3->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation 1:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context('Matrix');<br />
<br />
$example1 = Matrix([[1,2,3],[4,5,6]]);<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Setup 2:</b><br />
Reset the context by calling <code>Context('Matrix');</code> because the matrix answer checker gets confused when the <code>ans_box</code> and <code>ans_array</code> methods are co-mingled.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
$BR<br />
$BR<br />
Entering a matrix using multiple answer blanks is straightforward -- <br />
just put each matrix entry into its own answer blank.<br />
$BR<br />
Enter the matrix \( $example1 \) with one matrix entry per answer box.<br />
$BR<br />
\{ $example1->ans_array \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
ANS( $example1->cmp() );<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation 2:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=MatrixAnswer1&diff=23786MatrixAnswer12023-07-18T10:23:31Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixAnswer1.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer is a Matrix 1</h2><br />
<br />
[[File:MatrixAnswer1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to evaluate answers that are matrices.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixAnswer1.pg FortLewis/Authoring/Templates/LinAlg/MatrixAnswer1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixAnswer1_PGML.pg FortLewis/Authoring/Templates/LinAlg/MatrixAnswer1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Matrix");<br />
<br />
$A = Matrix([<br />
[random(-5,5,1),random(-5,5,1),random(-5,5,1)],<br />
[random(-5,5,1),random(-5,5,1),random(-5,5,1)],<br />
]);<br />
<br />
$B = Matrix([random(-5,5,1),random(-5,5,1),random(-5,5,1)]);<br />
<br />
$answer = $A * ($B->transpose);<br />
<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Use <code>Context("Matrix");</code>.<br />
MathObject matrices are constructed using the <code>Matrix()</code> constructor.<br />
The matrix A has two rows and three columns, and is constructed by <code>[ [row 1 entries], [row 2 entries] ]</code>, and this construction generalizes in the obvious way.<br />
If a matrix has only one row, such as B, then it is entered as <code>[row 1 entries]</code> and <b>not</b> as <code>[ [row 1 entries] ]</code>.<br />
If <code>$B = Matrix([a,b,c]);</code>, then the matrix <code>$B->transpose</code> is equivalent to <code>Matrix([[a],[b],[c]]);</code> which has an outer pair of brackets enclosing all of the rows, where each row encloses its single element with brackets.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Suppose<br />
\[<br />
A = $A <br />
\ \ \mbox{and} \ \<br />
B = $B.<br />
\]<br />
Evaluate the following matrix product.<br />
$BR<br />
$BR<br />
\( A B^T = \)<br />
\{ $answer->ans_array(5) \}<br />
\{ AnswerFormatHelp("matrices") \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Use the <code>->ans_array(width)</code> method on the MathObject matrix <code>$answer</code> to produce an array of answer boxes each with a specified character width.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $answer->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
Use standard MathObject answer evaluation.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
${PAR}SOLUTION:${PAR}<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ChemicalReaction1&diff=23785ChemicalReaction12023-07-18T10:22:39Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/ChemicalReaction.html a newer version of this problem]</p><br />
<br />
<h2>Chemical Reactions</h2><br />
<br />
[[File:ChemicalReaction1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how ask questions about chemical reactions.<br />
</p><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/ChemicalReaction1_PGML.pg FortLewis/Authoring/Templates/Misc/ChemicalReaction1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"PGunion.pl",<br />
"MathObjects.pl",<br />
"PGML.pl",<br />
"contextReaction.pl",<br />
"PGcourse.pl",<br />
);<br />
<br />
TEXT(beginproblem()); # uncomment<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Load <code>contextReaction.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Reaction");<br />
<br />
@reactants = ();<br />
@products = ();<br />
<br />
$reactants[0] = Formula("2C_2H_6 + 7O_2");<br />
$products[0] = Formula("4CO_2 + 6H_2O");<br />
<br />
$reactants[1] = Formula("6CO_2 + 6O_2");<br />
$products[1] = Formula("C_6 H_12 O_6 + 6 O_2");<br />
<br />
$reactants[2] = Formula("3 Ca Cl_2 + 2 Na_3 PO_4");<br />
$products[2] = Formula("Ca_3 (PO_4)_2 + 6 Na Cl");<br />
<br />
# variations on 2NaOH + MgCl_2 --> 2NaCl + Mg(OH)_2<br />
$a = list_random('Li','Na','K');<br />
$b = list_random('F','Cl','Br');<br />
<br />
# Use ${b}_2 instead of $b_2 below so that Perl knows the <br />
# variable name is $b = ${b} and not $b_2 = ${b_2}.<br />
$reactants[3] = Formula("2 $a OH + Mg ${b}_2"); <br />
$products[3] = Formula("2 $a $b + Mg (OH)_2");<br />
<br />
$num_choices = $#reactants;<br />
<br />
$i = random(0,$num_choices,1);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We create a couple of arrays <code>@reactants</code> and <code>@products</code> and fill them with some examples of balanced chemical equations. The second and third examples show that groupings, such as for <code>(OH)_2</code> are necessary. The third example shows how you could randomize a chemical reaction question. In particular, note that <code>${b}_2</code> is needed instead of <code>$b_2</code> so that Perl interprets the variable as <code>$b</code> with a subscript of 2 instead of a variable named <code>$b_2</code> with no subscript.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
[` [$reactants[ $i ]] \longrightarrow `] [_____________________________]{$products[ $i ]}<br />
<br />
Enter a subscript using an underscore, such as [| H_2 O |]* for [` \mathrm{H_2 O} `].<br />
END_PGML<br />
<br />
COMMENT('MathObject version. Uses PGML.');<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Note that we uses spaces around <code>$i</code> in things like <code>$reactants[ $i ]</code> and <code>$products[ $i ]</code>. This is a work around for a known PGML bug as of June 2015 (the bug will likely get fixed very soon).<br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
* [http://webwork.maa.org/pod/pg/macros/contextReaction.html POD documentation for contextReaction.pl]<br />
* [http://webwork.maa.org/moodle/mod/forum/discuss.php?d=449 WeBWorK forum discussion about chemical reactions]<br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=VectorFieldGraph2D1&diff=23784VectorFieldGraph2D12023-07-18T10:21:38Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/VectorFieldGraph2D.html a newer version of this problem]</p><br />
<br />
<h2>Graphing a Vector Field in the Plane</h2><br />
<br />
[[File:VectorFieldGraph2D1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to graph a vector field in the plane.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph2D1.pg FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph2D1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph2D1_PGML.pg FortLewis/Authoring/Templates/VectorCalc/VectorFieldGraph2D1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGgraphmacros.pl",<br />
"VectorField2D.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
$refreshCachedImages = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>VectorField2D.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context()->variables->add(y=>"Real");<br />
<br />
#<br />
# Create a graph canvas<br />
#<br />
$gr = init_graph(-5,-5,5,5,grid=>[10,10],axes=>[0,0],pixels=>[400,400]);<br />
$gr->lb('reset');<br />
foreach my $j (1..4) {<br />
$gr->lb( new Label(-4.7, $j, $j,'black','center','middle'));<br />
$gr->lb( new Label(-4.7, -$j,-$j,'black','center','middle'));<br />
$gr->lb( new Label( $j,-4.7, $j,'black','center','middle'));<br />
$gr->lb( new Label( -$j,-4.7,-$j,'black','center','middle'));<br />
}<br />
$gr->lb( new Label(4.7,0.2,'x','black','center','middle'));<br />
$gr->lb( new Label(0.2,4.7,'y','black','center','middle'));<br />
<br />
<br />
VectorField2D(<br />
graphobject => $gr,<br />
Fx => Formula("x/(x^2+y^2)"),<br />
Fy => Formula("y/(x^2+y^2)"),<br />
xvar => "x",<br />
yvar => "y",<br />
xmin => -5,<br />
xmax => 5,<br />
ymin => -5,<br />
ymax => 5,<br />
xsamples => 10,<br />
ysamples => 10,<br />
vectorcolor => "blue",<br />
vectorscale => 1.5,<br />
vectorthickness => 2,<br />
xavoid=>0,<br />
yavoid=>0,<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We create a blank graph canvas and add labels to it. Then, using the <code>VectorField2D()</code> subroutine, we specify the formula for the vector field and its parameters. The values for <code>xsamples</code> and <code>ysamples</code> were chosen so that the tails of the vectors would be on lattice points (this routine automatically adds one to the samples values, which is usually what you want since there are 11 integers between -5 and 5 including endpoints). You can uniformly rescale the length of all the vectors in the vector field by setting <code>vectorscale</code> to a different value (natural length is 1). You can avoid one point with coordinates (xavoid,yavoid) where the vector field may be undefined.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
This is a velocity vector field for an explosion at the origin <br />
that decreases in speed the farther the distance is from the origin.<br />
$PAR<br />
$BCENTER<br />
\{ image(insertGraph($gr),width=>400,height=>400,tex_size=>700) \}<br />
$ECENTER<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=PolarGraph1&diff=23783PolarGraph12023-07-18T10:19:32Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Parametric/PolarGraph.html a newer version of this problem]</p><br />
<br />
<h2>Graphing a Parametric or Polar Curve</h2><br />
<br />
[[File:PolarGraph1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to graph a parametric curve or polar curve with a shading (a filled region).<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/PolarGraph1.pg FortLewis/Authoring/Templates/Parametric/PolarGraph1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/PolarGraph1_PGML.pg FortLewis/Authoring/Templates/Parametric/PolarGraph1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGgraphmacros.pl",<br />
"AnswerFormatHelp.pl",<br />
"unionTables.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
$refreshCachedImages = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We use <code>PGgraphmacros.pl</code> to generate the graph, and <code>unionTables.pl</code> to put the text and the graph side-by-side. We should set <code>$refreshCachedImages = 1;</code> so that changes in the graph will show up (not get stuck by old images in the browser cache).<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->are(t=>"Real");<br />
<br />
$gr = init_graph(-1.1,-1.1,1.1,1.1,axes=>[0,0],size=>[300,300]);<br />
<br />
#<br />
# Define some useful colors<br />
#<br />
$gr->new_color("lightblue", 198,217,253); # RGB<br />
$gr->new_color("darkblue", 77,137,249);<br />
$gr->new_color("lightred", 255,127,127);<br />
$gr->new_color("darkred", 255, 55, 55);<br />
$gr->new_color("lightorange", 255,204,127);<br />
$gr->new_color("darkorange", 255, 153, 0);<br />
$gr->new_color("lightgreen", 187, 255, 153); <br />
$gr->new_color("darkgreen", 0, 208, 0);<br />
<br />
#<br />
# For a polar curve r = f(t),<br />
# x = r cos(t) = f(t) cos(t)<br />
# y = r sin(t) = f(t) sin(t)<br />
#<br />
$x = Formula("cos(5*t) * cos(t)");<br />
$y = Formula("cos(5*t) * sin(t)");<br />
<br />
<br />
$f = new Fun( $x->perlFunction, $y->perlFunction, $gr );<br />
$f->domain(0,3.14);<br />
$f->steps(90);<br />
$f->weight(2);<br />
$f->color('darkgreen');<br />
<br />
$gr->fillRegion([0.5,0.1,'lightgreen']);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We initialize a graph object named <code>$gr</code>. We define several new named colors which you can use if you want. We construct MathObjects formulas <code>$x</code> and <code>$y</code> for the x- and y-coordinates in terms of the parameter t. Then, we pass these formulas to the <code>Fun</code> routine, converting them to perl subroutines via <code>-&gt;perlFunction</code>, and attach them to the graph object <code>$gr</code>. Then, we set some of the options for the graph of the parametric curve <code>$f</code>. Finally, we fill the region enclosing the point <code>(0.5,0.1)</code> with the color light green.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{<br />
ColumnTable(<br />
"Find the area enclosed by one petal of the <br />
rose curve \( r = f(\theta) = \cos(5\theta) \).<br />
$BR<br />
$BR<br />
Area = ".<br />
ans_rule(20).$SPACE.<br />
AnswerFormatHelp("numbers")<br />
,<br />
$BCENTER.<br />
image( insertGraph($gr), width=>300, height=>300 ).<br />
$PAR.<br />
"Graph of \( r = \cos(5\theta) \)".<br />
$ECENTER<br />
,<br />
indent => 0, separation => 30, valign => "TOP"<br />
); <br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We use the <code>ColumnTable(column 1, column 2, options)</code> to put the text and graph side-by-side. We join (Perl) strings <code>" "</code> to common PG commands like <code>ans_rule(20)</code> using the string concatenation operator <code> . </code> which is a period. Notice that the commas between column 1, column 2, and the options do not have any periods before them.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
# intentionally incorrect<br />
ANS( Compute("pi")->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Volume3&diff=23782Volume32023-07-18T10:17:09Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/VolumeOfRevolution.html a newer version of this problem]</p><br />
<br />
<h2>A Question That Provides Credit Only When All Answers Are Correct</h2><br />
<br />
[[File:Volume3.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask students to set up a volume of solids of revolution integral in which all parts must be correct for the student to receive any credit.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume3.pg FortLewis/Authoring/Templates/IntegralCalc/Volume3.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume3_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/Volume3_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGunion.pl",<br />
"answerHints.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
install_problem_grader(~~&std_problem_grader);<br />
<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We install the standard problem grader, which is an all-or-nothing grader.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(<br />
x=>"Real", dx=>"Real",<br />
y=>"Real", dy=>"Real"<br />
);<br />
<br />
$f = Compute("x");<br />
$g = Compute("x^2");<br />
<br />
$upper = Real("1");<br />
$lower = Real("0");<br />
# answers below are intentionally wrong<br />
$int = Compute("( pi x - pi x^2 ) dx");<br />
$vol = Compute("pi"); <br />
<br />
<br />
#<br />
# Display the answer blanks properly in different modes<br />
#<br />
Context()->texStrings;<br />
if ($displayMode eq 'TeX') {<br />
$integral =<br />
'Volume = \(\displaystyle' . <br />
'\int_{'. <br />
ans_rule(4). '}^{'. <br />
ans_rule(4). '}'. <br />
ans_rule(30). ' = '.<br />
ans_rule(10). <br />
'\)';<br />
} else {<br />
$integral =<br />
BeginTable(center=>0).<br />
Row([<br />
'Volume = \(\displaystyle\int\)',<br />
ans_rule(4).$BR.$BR.<br />
ans_rule(4),<br />
ans_rule(30).$SPACE.' = '.$SPACE.<br />
ans_rule(10),<br />
],separation=>2).<br />
EndTable();<br />
}<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Notice that we use <code>ans_rule(width)</code> for all of the answer blanks.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Set up and evaluate an integral for the volume<br />
of the solid of revolution obtained by rotating<br />
the region bounded by \( y = $f \) and \( y = $g \)<br />
about the \(x\)-axis.<br />
$BR<br />
$BR<br />
$integral<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
The standard problem grader automatically provides a message to students that says the grading will be all or nothing.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
ANS( $upper->cmp() );<br />
ANS( $lower->cmp() );<br />
ANS( $int->cmp()<br />
->withPostFilter(AnswerHints( <br />
Formula("pi x - pi x^2 dx") => "Don't forget to multiply every <br />
term in the integrand by dx",<br />
Formula("pi x - pi x^2") => "Don't forget the differential dx", <br />
Formula("(pi x^2 - pi x)*dx") => "Is the parabola above the line?",<br />
Formula("pi x^2 - pi x") => "Is the parabola above the line?",<br />
))<br />
);<br />
ANS( $vol->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
<br />
COMMENT('MathObject version. Gives full credit only <br />
if all answers are correct.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Volume2&diff=23781Volume22023-07-18T10:16:48Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/VolumeOfRevolution.html a newer version of this problem]</p><br />
<br />
<h2>A Question with Weighted Answer Blanks and a Credit Answer</h2><br />
<br />
[[File:Volume2.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to construct a volume of solids of revolution question that allows students to set up the integral and earn partial credit, or to answer just the final question for full credit.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume2.pg FortLewis/Authoring/Templates/IntegralCalc/Volume2.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume2_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/Volume2_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGunion.pl",<br />
"answerHints.pl",<br />
"weightedGrader.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
install_weighted_grader();<br />
<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>weightedGrader.pl</code> and install it. Customized answer hints for particular kinds of student answers are provided by <code>answerHints.pl</code>. We load <code>PGunion.pl</code> to get macros for formatting tables that will be used to get the answer blanks into the limits of integration.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(<br />
x=>"Real", dx=>"Real",<br />
y=>"Real", dy=>"Real"<br />
);<br />
<br />
$f = Compute("x");<br />
$g = Compute("x^2");<br />
<br />
$upper = Real("1");<br />
$lower = Real("0");<br />
# answers below are intentionally wrong<br />
$int = Compute("( pi x - pi x^2 ) dx");<br />
$vol = Compute("pi"); <br />
<br />
@weights = (5,5,40,50);<br />
<br />
#<br />
# Display the answer blanks properly in different modes<br />
#<br />
Context()->texStrings;<br />
if ($displayMode eq 'TeX') {<br />
$integral =<br />
'Volume = \(\displaystyle' . <br />
'\int_{'. <br />
NAMED_ANS_RULE("lowerlimit",4). '}^{'. <br />
NAMED_ANS_RULE("upperlimit",4). '}'. <br />
NAMED_ANS_RULE("integrand",30). ' = '.<br />
ans_rule(10). <br />
'\)';<br />
} else {<br />
$integral =<br />
BeginTable(center=>0).<br />
Row([<br />
'Volume = \(\displaystyle\int\)',<br />
NAMED_ANS_RULE("upperlimit",4).$BR.$BR.<br />
NAMED_ANS_RULE("lowerlimit",4),<br />
NAMED_ANS_RULE("integrand",30).$SPACE.' = '.$SPACE.<br />
ans_rule(10),<br />
],separation=>2).<br />
EndTable();<br />
}<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
Notice that for the final answer (volume) we use <code>ans_rule(width)</code>, while for the answer blanks that involve setting up the integral we use <code>NAMED_ANS_RULE(name,width)</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Set up and evaluate an integral for the volume<br />
of the solid of revolution obtained by rotating<br />
the region bounded by \( y = $f \) and \( y = $g \)<br />
about the \(x\)-axis.<br />
$BR<br />
$BR<br />
$integral<br />
END_TEXT<br />
TEXT(MODES(TeX=>"",HTML=><br />
"${PAR}${BITALIC}${BBOLD}Note:${EBOLD} <br />
You can earn <br />
$weights[0]${PERCENT} for the upper limit of integration,<br />
$weights[1]${PERCENT} for the lower limit of integration,<br />
$weights[2]${PERCENT} for the integrand, and<br />
$weights[3]${PERCENT} for the finding the volume.<br />
If you find the correct volume, you will get full credit<br />
no matter what your other answers are.<br />
${EITALIC}"));<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
In HTML mode, we add an explanation of how the question will be graded, pointing out that full credit can be earned if the volume calculation is correct.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
NAMED_WEIGHTED_ANS( "upperlimit" => $upper->cmp(), $weights[0] );<br />
NAMED_WEIGHTED_ANS( "lowerlimit" => $lower->cmp(), $weights[1] );<br />
NAMED_WEIGHTED_ANS( "integrand" => $int->cmp()<br />
->withPostFilter(AnswerHints( <br />
Formula("pi x - pi x^2 dx") => "Don't forget to multiply every <br />
term in the integrand by dx",<br />
Formula("pi x - pi x^2") => "Don't forget the differential dx", <br />
Formula("(pi x^2 - pi x)*dx") => "Is the parabola above the line?",<br />
Formula("pi x^2 - pi x") => "Is the parabola above the line?",<br />
)),<br />
$weights[2]<br />
);<br />
CREDIT_ANS( $vol->cmp(), ["upperlimit","lowerlimit","integrand"], $weights[3] );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
Notice that we use <code>NAMED_WEIGHTED_ANS( "name" => $answer->cmp()->withPostFilter(), weight)</code> for the questions that have named answer blanks above. For the final answer, which can provide full credit, we use <code>CREDIT_ANS( $answer->cmp(), ["name1", "name2", ...], weight)</code> for this answer to provide credit for the answers with names in the list <code>["name1", "name2", ...]</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
<br />
COMMENT('MathObject version. Weights each answer blank separately, <br />
and the last answer provides full credit for all other answer blanks.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=Volume1&diff=23780Volume12023-07-18T10:16:27Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/VolumeOfRevolution.html a newer version of this problem]</p><br />
<br />
<br />
<h2>A Question with Weighted Answer Blanks</h2><br />
<br />
[[File:Volume1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask students to set up and evaluate an integral for calculating the volume of a solid of revolution. Each answer blank is weighted.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume1.pg FortLewis/Authoring/Templates/IntegralCalc/Volume1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/Volume1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/Volume1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGunion.pl",<br />
"answerHints.pl",<br />
"weightedGrader.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
install_weighted_grader();<br />
<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>weightedGrader.pl</code> and install it. We load <code>answerHints.pl</code> to give student feedback on particular incorrect answers. We load <code>PGunion.pl</code> so that we can construct tables in HTML mode that will make the answer blanks for the limits of integration appear at the top and bottom of the integral symbol.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(<br />
x=>"Real", dx=>"Real",<br />
y=>"Real", dy=>"Real"<br />
);<br />
<br />
$f = Compute("x");<br />
$g = Compute("x^2");<br />
<br />
$upper = Real("1");<br />
$lower = Real("0");<br />
# answers below are intentionally wrong<br />
$int = Compute("( pi x - pi x^2 ) dx");<br />
$vol = Compute("pi"); <br />
<br />
@weights = (5,5,40,50);<br />
<br />
#<br />
# Display the answer blanks properly in different modes<br />
#<br />
Context()->texStrings;<br />
if ($displayMode eq 'TeX') {<br />
$integral =<br />
'Volume = \(\displaystyle' . <br />
'\int_{'. <br />
NAMED_ANS_RULE("lowerlimit",4). '}^{'. <br />
NAMED_ANS_RULE("upperlimit",4). '}'. <br />
NAMED_ANS_RULE("integrand",30). ' = '.<br />
NAMED_ANS_RULE("volume",10). <br />
'\)';<br />
} else {<br />
$integral =<br />
BeginTable(center=>0).<br />
Row([<br />
'Volume = \(\displaystyle\int\)',<br />
NAMED_ANS_RULE("upperlimit",4).$BR.$BR.<br />
NAMED_ANS_RULE("lowerlimit",4),<br />
NAMED_ANS_RULE("integrand",30).$SPACE.' = '.$SPACE.<br />
NAMED_ANS_RULE("volume",10),<br />
],separation=>2).<br />
EndTable();<br />
}<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
To keep the code that needs to be modified compartmentalized, we define the functions involved, the limits of integration, the integrand, the volume, and an array of weights (which sum to 100) for each of these answers.<br />
</p><br />
<p><br />
The code for correctly displaying the answer blanks creates <code>$integral</code> which will be displayed correctly both in TeX and HTML modes. Notice that it uses <code>NAMED_ANS_RULE(name,width)</code> for all of the answer blanks instead of <code>ans_rule(width)</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Set up and evaluate an integral for the volume<br />
of the solid of revolution obtained by rotating<br />
the region bounded by \( y = $f \) and \( y = $g \)<br />
about the \(x\)-axis.<br />
$BR<br />
$BR<br />
$integral<br />
END_TEXT<br />
TEXT(MODES(TeX=>"",HTML=><br />
"${PAR}${BITALIC}${BBOLD}Note:${EBOLD} <br />
You can earn <br />
$weights[0]${PERCENT} for the upper limit of integration,<br />
$weights[1]${PERCENT} for the lower limit of integration,<br />
$weights[2]${PERCENT} for the integrand, and<br />
$weights[3]${PERCENT} for the finding the volume.<br />
${EITALIC}"));<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We use the mode-specific <code>$integral</code> to display the integral and answer blanks correctly. In <code>TEXT()</code> we specify for the students how the answer will be graded (weightedGrader.pl does not do this automatically, as some other graders do.)<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
NAMED_WEIGHTED_ANS( "upperlimit" => $upper->cmp(), $weights[0] );<br />
NAMED_WEIGHTED_ANS( "lowerlimit" => $lower->cmp(), $weights[1] );<br />
NAMED_WEIGHTED_ANS( "integrand" => $int->cmp()<br />
->withPostFilter(AnswerHints( <br />
Formula("pi x - pi x^2 dx") => "Don't forget to multiply every <br />
term in the integrand by dx",<br />
Formula("pi x - pi x^2") => "Don't forget the differential dx", <br />
Formula("(pi x^2 - pi x)*dx") => "Is the parabola above the line?",<br />
Formula("pi x^2 - pi x") => "Is the parabola above the line?",<br />
)),<br />
$weights[2]<br />
);<br />
NAMED_WEIGHTED_ANS( "volume" => $vol->cmp(), $weights[3] );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
The answer evaluator we use is <code>NAMED_WEIGHTED_ANS( name => $answer->cmp()->withPostFilter(), weight)</code> instead of using <code>ANS( $answer->cmp()->withPostFilter() )</code>. Providing customized answer hints for students is a very good idea, because the whole point of this homework exercise it to learn how to set up this integral using proper notation. If we just wanted to ask for the volume, we could have done it using only one answer blank.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
<br />
COMMENT('MathObject version. Weights each answer blank separately.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
We include a comment to the instructor to let them know how the question is being graded.<br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=LimitsOfIntegration1&diff=23779LimitsOfIntegration12023-07-18T10:15:20Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/LimitsOfIntegration.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer Blanks in the Limits of Integration</h2><br />
<br />
[[File:LimitsOfIntegration1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to put answer blanks into the limits of integration.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/LimitsOfIntegration1.pg FortLewis/Authoring/Templates/IntegralCalc/LimitsOfIntegration1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/LimitsOfIntegration1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/LimitsOfIntegration1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<p style="background-color:#ffffcc;padding:30px;border:black 1px dashed;"><br />
The approach given on this page has certain disadvantages in terms of the "reading order" of the content for screen reader users due to the manner in which visual formatting using tables is achieved.<br><br />
<strong>Another, CSS based approach can be found in [https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4767]</strong> and allows keeping a more natural "reading" order to the content.<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"PGunion.pl",<br />
"answerHints.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We must use <code>PGunion.pl</code> for table formatting commands we will use to put the answer blanks in the limits of integration. We use <code>answerHints.pl</code> to help guide students toward the correct answer.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->are(<br />
x=>"Real", dx=>"Real",<br />
t=>"Real", dt=>"Real"<br />
);<br />
<br />
$fpx = Formula("sin(x)"); <br />
$fpt = Formula("sin(t)"); <br />
<br />
#<br />
# Display the answer blanks properly in different modes<br />
#<br />
Context()->texStrings;<br />
if ($displayMode eq 'TeX') {<br />
$integral =<br />
'\(\displaystyle f(x) = '.<br />
ans_rule(4). <br />
'+ \int_{t = '. <br />
ans_rule(4). <br />
'}^{t = '. <br />
ans_rule(4).<br />
'}'. <br />
ans_rule(20).<br />
'\)';<br />
} else {<br />
$integral =<br />
BeginTable(center=>0).<br />
Row([<br />
'\(f(x)=\)'.$SPACE.ans_rule(4).$SPACE.'\(+\displaystyle\int\)',<br />
'\( t = \)'.ans_rule(4).$BR.$BR.'\( t = \)'.ans_rule(4),<br />
ans_rule(20)],separation=>2).<br />
EndTable();<br />
}<br />
Context()->normalStrings;<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
The block of code that puts the answer blanks into the exponents correctly in HTML and TeX modes probably does not need to be modified.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Find a formula for the function \(f(x)\) such that <br />
\( \displaystyle f'(x)= $fpx \) and \( f(2)=5 \).<br />
$BR<br />
$BR<br />
$integral<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
To display the integral with answer blanks in the limits of integration properly, we insert it using <code>$integral</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( Compute("5")->cmp() );<br />
ANS( Compute("x")->cmp() );<br />
ANS( Compute("2")->cmp() );<br />
ANS( Compute("$fpt * dt")->cmp()<br />
->withPostFilter(AnswerHints( <br />
Formula("$fpx") => "Are you using the correct variable?",<br />
Formula("$fpx*dx") => "Are you using the correct variable?",<br />
Formula("$fpt") => "Don't forget the differential dt", <br />
))<br />
);<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
We use <code>AnswerHints</code> to guide the students to the correct answer.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
<br />
COMMENT('MathObject version');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=IndefiniteIntegrals1&diff=23778IndefiniteIntegrals12023-07-18T10:13:12Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/IndefiniteIntegrals.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Indefinite Integrals and General Antiderivatives</h2><br />
<br />
[[File:IndefiniteIntegrals1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to check answers that are indefinite integrals or general antiderivatives.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/IndefiniteIntegrals1.pg FortLewis/Authoring/Templates/IntegralCalc/IndefiniteIntegrals1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/IndefiniteIntegrals1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/IndefiniteIntegrals1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'parserFormulaUpToConstant.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$specific = Formula("e^x");<br />
<br />
$general = FormulaUpToConstant("e^x");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b><br />
Examples of specific and general antiderivatives:<br />
<ul><br />
<li>Specific antiderivatives: <code>e^x, e^x + pi</code></li><br />
<li>General antiderivatives: <code>e^x + C, e^x + C - 3, e^x + K</code></li><br />
</ul><br />
</p><br />
<p><br />
The specific antiderivative is an ordinary formula, and we check this answer, we will specify that it be a formula evaluated up to a constant (see the Answer Evaluation section below). For the general antiderivative, we use the <code>FormulaUpToConstant()</code> constructor provided by <code>parserFormulaUpToConstant.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
+ Enter a specific antiderivative for [` e^x `]: [____________]{$specific->cmp(upToConstant=>1)}<br />
<br />
+ Enter the most general antiderivative for [` e^x `]: [____________]{$general}<br />
<br />
[@ helpLink('formulas') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=GraphShading1&diff=23777GraphShading12023-07-18T10:12:33Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/GraphShading.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Dynamically Generated Graphs With Filled Regions (Shading)</h2><br />
<br />
[[File:GraphShading1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to create a dynamically generated graph with a shaded region.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/GraphShading1.pg FortLewis/Authoring/Templates/GraphShading1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/GraphShading1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/GraphShading1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
"PGgraphmacros.pl",<br />
"unionTables.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
$refreshCachedImages = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Dynamically generated graphs require <code>PGgraphmacros.pl</code>, and we will use <code>unionTables.pl</code> to put the text and the graph side-by-side in two columns. It is important to set <code>$refreshCachedImages = 1</code> if you want the image to be generated and delivered every time the page is refreshed, otherwise a cached image may be used.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$a = random(0,3,1);<br />
$f = Formula("sqrt(x)+$a");<br />
<br />
$answer = Compute("(2/3) * (4^(3/2) - 1) + 3*$a");<br />
<br />
#<br />
# Graph canvas<br />
#<br />
$gr = init_graph(-5,-5,5,5,grid=>[10,10],axes=>[0,0],pixels=>[300,300]);<br />
<br />
#<br />
# Graph labels<br />
#<br />
$gr->lb('reset');<br />
foreach my $j (1..4) {<br />
$gr->lb( new Label(-4.7, $j, $j,'black','center','middle'));<br />
$gr->lb( new Label(-4.7, -$j,-$j,'black','center','middle'));<br />
$gr->lb( new Label( $j,-4.7, $j,'black','center','middle'));<br />
$gr->lb( new Label( -$j,-4.7,-$j,'black','center','middle'));<br />
}<br />
$gr->lb( new Label(4.7,0.2,'x','black','center','middle'));<br />
$gr->lb( new Label(0.2,4.7,'y','black','center','middle'));<br />
<br />
<br />
#<br />
# Define new graph colors<br />
#<br />
$gr->new_color("lightblue", 214,230,244); # RGB<br />
$gr->new_color("darkblue", 100,100,255);<br />
$gr->new_color("lightgreen",156,215,151); <br />
$gr->new_color("darkgreen", 0, 86, 34);<br />
$gr->new_color("lightred", 245,234,229); # light red-purple<br />
$gr->new_color("darkred", 159, 64, 16); # red-brown<br />
<br />
<br />
#<br />
# Choose colors<br />
#<br />
$light = "lightblue";<br />
$dark = "darkblue";<br />
<br />
#<br />
# Graph the function and the filled region<br />
#<br />
add_functions($gr,<br />
"$f for x in <0,5> using color:$dark and weight:2");<br />
$gr->moveTo(1,$a+1);<br />
$gr->lineTo(1,0,$dark,2);<br />
$gr->lineTo(4,0,$dark,2);<br />
$gr->lineTo(4,$a+2,$dark,2);<br />
$gr->fillRegion([1.1,0.1,$light]<br />
);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
For more details on the graph object <code>$gr</code>, see the help documents for graphs in the [[IndexOfProblemTechniques|index of problem techniques]].<br />
</p><br />
<p><br />
We defined more colors than are actually used so that you have some options to choose from.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{<br />
ColumnTable(<br />
"Use the graph to find the area of the shaded<br />
region under \( f(x) = $f \).<br />
$BR<br />
$BR<br />
Area = " . <br />
ans_rule(20).$SPACE.<br />
AnswerFormatHelp("numbers")<br />
,<br />
image( insertGraph($gr),height=>300,width=>300,tex_size=>800 ).<br />
$BR.$BCENTER.<br />
$BR.<br />
"Graph of \( y = f(x) \)".<br />
$ECENTER<br />
,<br />
indent => 0, separation => 30, valign => "TOP"<br />
)<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We use a two column format provided by <code>ColumnTable(first column, second column, options)</code>. In each column, we use the string concatenation operator <code>.</code> quite a bit to join together strings and other methods because the entire ColumnTable is inside Perl mode curly braces <code>\{ \}</code>. To make the separation between the columns easier to read, we have put two commas on their own lines. Notice that there is no period before any of the commas. <br />
</p><br />
<p><br />
Using a <code>ColumnTable</code> is best because in HTML mode the text and graph will be side by side, while in the PDF output the columns will be stacked on top of each other so that the text is on top of the graph. Pay attention to the size of your graph in HTML and in PDF output, and make it big enough to read easily in either format.<br />
</p><br />
<p><br />
Many existing questions generate image files with larger dimensions than necessary, but scale them down so as to be unreadable in HTML and PDF output, which makes them hard or impossible to use. If you have the time to make a graph, take the extra time to make it an appropriate size in both HTML and PDF output.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $answer->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=RiemannSums1&diff=23776RiemannSums12023-07-18T10:11:49Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/IntegralCalc/RiemannSums.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Dynamically Generated Graphs with Riemann Sums</h2><br />
<br />
[[File:RiemannSums1.png|400px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to make dynamically generated graphs with shaded (filled) Riemann sums.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/RiemannSums1.pg FortLewis/Authoring/Templates/IntegralCalc/RiemannSums1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/IntegralCalc/RiemannSums1_PGML.pg FortLewis/Authoring/Templates/IntegralCalc/RiemannSums1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"PGchoicemacros.pl",<br />
"PGgraphmacros.pl",<br />
"MathObjects.pl",<br />
"weightedGrader.pl",<br />
"unionTables.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
install_weighted_grader();<br />
<br />
$refreshCachedImages = 1;<br />
$showPartialCorrectAnswers = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
# Construct a graph for the left endpoint Riemann sum,<br />
# define the function to be graphed, and add it to the graph<br />
$graphL = init_graph(-1,-1,9,9,ticks=>[10,10],axes=>[0,0],pixels=>[250,250]);<br />
$graphL->lb('reset');<br />
foreach my $i (1..8) {<br />
$graphL->lb( new Label($i,-0.5,$i, 'black','center','middle'));<br />
$graphL->lb( new Label(-0.5,$i,$i, 'black','center','middle'));<br />
}<br />
$graphL->lb(new Label ( 8.5,0.25,'x','black','center','middle'));<br />
$graphL->lb(new Label ( 0.25,8.5,'y','black','center','middle'));<br />
<br />
<br />
$c = random(8,12,1); # a constant for scaling the function<br />
$f = FEQ("x**2/$c for x in <-1,9> using color:blue and weight:2");<br />
$ftex = "\frac{x^2}{$c}";<br />
# the parentheses around $fRefL are necessary<br />
($fRefL) = plot_functions( $graphL, $f );<br />
<br />
<br />
# Generate arrays of x and y values for the Riemann sum.<br />
# There are n+1 entries in each array so that we can use<br />
# only one pair of arrays for both the left and the right <br />
# endpoint Riemann sums.<br />
$a = random(2,4,1); # left endpoint of interval<br />
$b = $a+2; # right endpoint of interval<br />
$n = 4; # number of rectangles<br />
$deltax = ($b - $a)/$n;<br />
foreach $k (0..$n) { $x[$k] = $a + $k * $deltax; }<br />
foreach $k (0..$n) { $y[$k] = &{$fRefL->rule}($x[$k]); }<br />
<br />
<br />
# Graph the left endpoint Riemann sum<br />
$lightblue = $graphL->im->colorAllocate(148,201,255);<br />
$darkblue = $graphL->im->colorAllocate(100,100,255);<br />
# Create arrays of pixel references for x and y values<br />
foreach $k (0..$n) {<br />
$xpixL[$k] = $graphL->ii($x[$k]);<br />
$ypixL[$k] = $graphL->jj($y[$k]);<br />
}<br />
$xaxisL = $graphL->jj(0);<br />
# Plot the rectangles in the Riemann sum<br />
foreach $k (0..$n-1) {<br />
$graphL->im->filledRectangle($xpixL[$k],$ypixL[$k],$xpixL[$k+1],$xaxisL,$lightblue);<br />
$graphL->im->rectangle($xpixL[$k],$ypixL[$k],$xpixL[$k+1],$xaxisL,$darkblue);<br />
}<br />
<br />
<br />
<br />
<br />
# Construct a graph for the right endpoint Riemann sum<br />
$graphR = init_graph(-1,-1,9,9,ticks=>[10,10],axes=>[0,0],pixels=>[250,250]);<br />
$graphR->lb('reset');<br />
foreach my $i (1..8) {<br />
$graphR->lb( new Label($i,-0.5,$i, 'black','center','middle'));<br />
$graphR->lb( new Label(-0.5,$i,$i, 'black','center','middle'));<br />
}<br />
$graphR->lb(new Label ( 8.5,0.25,'x','black','center','middle'));<br />
$graphR->lb(new Label ( 0.25,8.5,'y','black','center','middle'));<br />
<br />
# the parentheses around $fRefR are necessary<br />
($fRefR) = plot_functions( $graphR, $f );<br />
<br />
<br />
# Graph the right endpoint Riemann sum<br />
$lightblue = $graphR->im->colorAllocate(148,201,255);<br />
$darkblue = $graphR->im->colorAllocate(100,100,255);<br />
# Create arrays of pixel references for x and y values<br />
foreach $k (0..$n) {<br />
$xpixR[$k] = $graphR->ii($x[$k]);<br />
$ypixR[$k] = $graphR->jj($y[$k]);<br />
}<br />
$xaxisR = $graphR->jj(0);<br />
# Plot the rectangles in the Riemann sum<br />
foreach $k (1..$n) {<br />
$graphR->im->filledRectangle($xpixR[$k-1],$ypixR[$k],$xpixR[$k],$xaxisR,$lightblue);<br />
$graphR->im->rectangle($xpixR[$k-1],$ypixR[$k],$xpixR[$k],$xaxisR,$darkblue);<br />
}<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{<br />
ColumnTable(<br />
"Suppose \( \displaystyle f(x) = $ftex \).".<br />
$BR.<br />
$BR.<br />
"(a) The rectangles in the graph on the left illustrate <br />
a left endpoint Riemann sum for \( f(x) \) on the <br />
interval \( $a \leq x \leq $b \). The value of this <br />
left endpoint Riemann sum is ".<br />
NAMED_ANS_RULE('optional1',30). <br />
", and it is an ".<br />
NAMED_POP_UP_LIST('optional2',['?','overestimate of',<br />
'equal to','underestimate of','there is ambiguity']).<br />
" the area of the region enclosed by <br />
\(\displaystyle y = f(x) \), the x-axis, and the <br />
vertical lines \(x = $a\) and \(x = $b\).".<br />
$BR.<br />
$BR.<br />
"(b) The rectangles in the graph on the right illustrate <br />
a right endpoint Riemann sum for \( f(x) \) on the <br />
interval \( $a \leq x \leq $b \). The value of this <br />
right endpoint Riemann sum is ".<br />
NAMED_ANS_RULE('optional3',30).<br />
", and it is an ".<br />
NAMED_POP_UP_LIST('optional4',['?','overestimate of',<br />
'equal to','underestimate of','there is ambiguity']).<br />
" the area of the region enclosed by <br />
\(\displaystyle y = f(x) \), the x-axis, and the <br />
vertical lines \(x = $a\) and \(x = $b\)."<br />
,<br />
$BCENTER.<br />
BeginTable(1).<br />
AlignedRow( <br />
[image( insertGraph($graphL), height=>250, width=>250, tex_size=>450 ),<br />
image( insertGraph($graphR), height=>250, width=>250, tex_size=>450 )]<br />
).<br />
TableSpace(5,0).<br />
AlignedRow(<br />
["Left endpoint Riemann sum",<br />
"Right endpoint Riemann sum"]<br />
).<br />
EndTable().<br />
$ECENTER<br />
,<br />
indent => 0, separation => 30, valign => "TOP"<br />
);<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$LeftRiemannSum = 0;<br />
foreach $k (0..$n-1) { $LeftRiemannSum = $LeftRiemannSum + $y[$k]; }<br />
$LeftRiemannSum = Real("$deltax * $LeftRiemannSum");<br />
NAMED_WEIGHTED_ANS('optional1',$LeftRiemannSum->cmp(),45);<br />
<br />
NAMED_WEIGHTED_ANS('optional2',str_cmp("underestimate of"),5);<br />
<br />
$RightRiemannSum = 0;<br />
foreach $k (1..$n) { $RightRiemannSum = $RightRiemannSum + $y[$k]; }<br />
$RightRiemannSum = Real("$deltax * $RightRiemannSum");<br />
NAMED_WEIGHTED_ANS('optional3',$RightRiemannSum->cmp(),45);<br />
<br />
NAMED_WEIGHTED_ANS('optional4',str_cmp("overestimate of"),5);<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
(A) The left endpoint Riemann sum is <br />
\( f($x[0]) \cdot 0.5 + f($x[1]) \cdot 0.5 + \cdots + f($x[$n-1]) \cdot 0.5<br />
= ( $y[0] + $y[1] + \cdots + $y[7] ) \cdot 0.5 = $LeftRiemannSum.\)<br />
$BR<br />
$BR<br />
(B) The right endpoint Riemann sum is <br />
\( f($x[1]) \cdot 0.5 + f($x[2]) \cdot 0.5 + \cdots + f($x[$n]) \cdot 0.5<br />
= ( $y[1] + $y[2] + \cdots + $y[$n] ) \cdot 0.5 = $RightRiemannSum.\)<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=LinearApprox1&diff=23775LinearApprox12023-07-18T10:11:02Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffCalc/LinearApprox.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Linear Approximation With Answer Hints</h2><br />
<br />
[[File:LinearApprox1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to ask a linear approximation question in which the answer is an equation and students receive customized answer hints.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/LinearApprox1.pg FortLewis/Authoring/Templates/DiffCalc/LinearApprox1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/LinearApprox1_PGML.pg FortLewis/Authoring/Templates/DiffCalc/LinearApprox1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
"answerHints.pl",<br />
"parserAssignment.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserAssignment.pl</code> to require students to enter their answer as an equation of the form <code>y=...</code>. We load <code>answerHints.pl</code> to provide customized answer hints, particularly for those students who enter the slope of the line instead of the equation of the line.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric")->variables->add(y=>"Real");<br />
parser::Assignment->Allow;<br />
<br />
$a = random(2,5,1);<br />
$aa = $a**2;<br />
$a2 = 2 * $a;<br />
<br />
$f = Compute("sqrt(x)");<br />
<br />
$answer = Compute("y = $a + (1/$a2) * (x-$aa)");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We have to tell the context that we are allowing the assignment of a variable to a formula.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Find the linear approximation to \( f(x) = $f \)<br />
at \( x = $aa \). Your answer should be an <br />
equation in the variables \( x \) and \( y \).<br />
$BR<br />
$BR<br />
\{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("equations") \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $answer->cmp() <br />
->withPostFilter(AnswerHints( <br />
[Formula("1/$a2"),Formula("y=1/$a2")] => <br />
["Your answer should be an equation for a non-horizontal line.",<br />
replaceMessage=>1],<br />
))<br />
);<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
We use answer hints to remind students to enter an equation for a line, not just the slope of the line.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT("MathObject version.");<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=AnswerWithUnits1&diff=23774AnswerWithUnits12023-07-18T10:10:07Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffCalc/AnswerWithUnits.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer is a Number or Formula with Units</h2><br />
<br />
[[File:AnswerWithUnits1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to require students to enter units with their answers.<br />
</p><br />
<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1_PGML.pg FortLewis/Authoring/Templates/DiffCalc/AnswerWithUnits1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'parserNumberWithUnits.pl',<br />
'parserFormulaWithUnits.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We load <code>parserNumberWithUnits.pl</code> and <code>parserFormulaWithUnits.pl</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Numeric')->variables->are(t=>'Real');<br />
<br />
$h = Formula('-16 t^2 + 16');<br />
$v = $h->D('t');<br />
$v1 = $v->eval(t=>1);<br />
$a = $v->D('t');<br />
<br />
$answer1 = FormulaWithUnits("$v",'ft/s');<br />
$answer2 = NumberWithUnits("$v1",'ft/s');<br />
$answer3 = FormulaWithUnits("$a",'ft/s^2');<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We use the differentiation operator <code>-&gt;D('t')</code> and the evaluation method <code>-&gt;eval()</code> to construct the derivative and evaluate it as a function. If we were writing several questions like this with different height functions, using the differentiation and evaluation methods would really speed up the writing.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Suppose the height of a falling object, in feet above the ground, is given by<br />
[` h(t) = [$h] `] for [` t \geq 0 `], where time is measured in seconds.<br />
<br />
a. What is the velocity of the object? [______________]{$answer1}<br />
<br />
b. What is the velocity of the object when it hits the ground? [______________]{$answer2}<br />
<br />
c. What is the acceleration of the object? Include units in your answer. [______________]{$answer3}<br />
<br />
Note: use units in all answers. [@ helpLink('units') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Don't forget to use <code>helpLink("units")</code> so your students will have access to the complete list of units that WeBWorK understands.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
COMMENT('Uses PGML.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=DifferentiateFunction1&diff=23773DifferentiateFunction12023-07-18T10:09:30Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/DiffCalc/DifferentiateFunction.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Differentiating and Evaluating a Function</h2><br />
<br />
[[File:DifferentiateFunction1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to create a function using MathObjects, differentiate it, and evaluate it.<br />
</p><br />
<!--* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/DifferentiateFunction1.pg FortLewis/Authoring/Templates/DiffCalc/DifferentiateFunction1.pg] --><br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/DiffCalc/DifferentiateFunction1_PGML.pg FortLewis/Authoring/Templates/DiffCalc/DifferentiateFunction1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT(); <br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Numeric')->variables->add(k=>'Real');<br />
Context()->flags->set(<br />
reduceConstants=>0, # no decimals<br />
reduceConstantFunctions=>1, # combine 4+5*2?<br />
formatStudentAnswer=>'parsed', # no decimals<br />
);<br />
<br />
$a = random(6,9,1);<br />
$k = random(3,5,1);<br />
<br />
$f = Formula('k x^2');<br />
$fx = $f->D('x');<br />
<br />
$ans1 = $fx;<br />
$ans2 = $fx->substitute(k=>$k); <br />
$ans3 = $fx->substitute(x=>$a*pi,k=>$k);<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b><br />
The partial differentiation operator is <code>-&gt;D('x')</code>. <br />
</p><br />
<p><br />
The main difference between <code>eval()</code> and <code>substitute()</code> is<br />
* <code>eval()</code> returns a Real (a number)<br />
* <code>substitute()</code> returns a Formula<br />
Since plugging a particular number <code>$k</code> into the Formula <code>$f</code> returns a Formula <code>$k x</code>, if we had used the eval method <code>$ans2 = $fx->eval(k=>$k);</code> instead of the substitute method, we would get errors because <code>$k x</code> is a Formula, not a Real. Note: You cannot use eval or substitute to perform function composition, i.e., you can only plug in numbers, not formulas.<br />
</p><br />
<p><br />
When the answer is a constant, we can use either the eval method, in which case the answer would be a Real, or the substitute method, in which case the answer would be a constant Formula. If you use the eval method, <code>$ans3 = $fx->eval(x=>$a*pi,k=>$k);</code> the answer will be a Real and will display as a single number in decimal format. If you use the substitute method instead, you have more control over how the answer will be displayed. In particular, the context flag<br />
<code>reduceConstants</code> controls whether the answer will be reduced to a single number in decimal format, the flag <code>reduceConstantFunctions</code> controls whether or not expressions such as <code>4+5*2</code> are reduced to <code>14</code>, and setting the context flag <code>formatStudentAnswer=>'parsed'</code> will prevent the student's answer from being reduced to a single number in decimal format and will also display <code>pi</code> instead of <code>3.14159...</code><br />
</p><br />
<p> <br />
For more details, see [http://webwork.maa.org/wiki/Eval%28%29vs.substitute%28%29 eval versus substitute], [http://webwork.maa.org/wiki/FormattingCorrectAnswers:_NumbersAndFormulas formatting correct answers], and [http://webwork.maa.org/wiki/ConstantsInProblems constants in problems].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Suppose [` f(x) = [$f] `] where [` k `] is a constant.<br />
<br />
a. [` f ' (x) = `] [_______________]{$ans1}<br />
<br />
b. If [` k = [$k] `] then [` f ' (x) = `] [_______________]{$ans2}<br />
<br />
c. If [` k = [$k] `] then [` f ' ([$a]\pi) = `] [_______________]{$ans3}<br />
<br />
[@ helpLink('formulas') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
COMMENT('Uses PGML.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=PointAnswers1&diff=23772PointAnswers12023-07-18T10:08:31Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/PointAnswers.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer is a Point or a List of Points</h2><br />
<br />
[[File:PointAnswers1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to evaluate answers that are points or lists of points.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/PointAnswers1.pg FortLewis/Authoring/Templates/Precalc/PointAnswers1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/PointAnswers1_PGML.pg FortLewis/Authoring/Templates/Precalc/PointAnswers1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'contextLimitedPoint.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We only need to load <code>contextLimitedPoint.pl</code> if we want to prevent operations between points.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('LimitedPoint');<br />
<br />
$f = Compute('x^2-1');<br />
<br />
$xint = List( Point('(1,0)'), Point('(-1,0)') );<br />
$yint = List( Point('(0,-1)') );<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We could have used <code>Context("Point");</code> instead, which <br />
would allow mathematical operations between points (such as adding<br />
points as if they were vectors). The x-intercepts are clearly a<br />
list of points. We used a list with only one element for the y-intercepts<br />
so that a student who mistakenly enters two points will be told<br />
their second point is incorrect. If we did not use a list for<br />
the y-intercepts, a student who enters two points would be given<br />
an error message instead.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Enter the [`x`]-intercept(s) and [`y`]-intercept(s)<br />
of [` y = [$f] `]. Enter a point as [` (a,b) `],<br />
including the parentheses. If there is more<br />
than one correct answer, enter a comma<br />
separated list of points.<br />
<br />
+ [`x`]-intercept(s): [_________________]{$xint}<br />
<br />
+ [`y`]-intercept(s): [_________________]{$yint}<br />
<br />
[@ helpLink('points') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Be sure to tell students the proper syntax for how to enter their answers.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=AnswerUpToMultiplication1&diff=23771AnswerUpToMultiplication12023-07-18T10:07:44Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/StringOrOtherType.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer is a Function up to Multiplication by a Nonzero Constant</h2><br />
<br />
[[File:AnswerUpToMultiplication1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to <br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1_PGML.pg FortLewis/Authoring/Templates/Precalc/AnswerUpToMultiplication1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 40%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
<br />
TEXT(beginproblem()); <br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context('Numeric');<br />
<br />
$sol_str = '(x-2)*(x+1)';<br />
<br />
$ans = Compute($sol_str)->cmp(checker => sub {<br />
my ( $correct, $student, $self ) = @_;<br />
my $context = Context()->copy;<br />
return 0 if $student == 0;<br />
$context->flags->set(no_parameters=>0);<br />
$context->variables->add('C0'=>'Parameter');<br />
my $c0 = Formula($context,'C0');<br />
$student = Formula($context,$student);<br />
$correct = Formula($context,"$c0 * $sol_str");<br />
return $correct == $student;<br />
});<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
<p><br />
We use a local context with an adaptive parameter to check the answer. For more on adaptive parameters, see [http://webwork.maa.org/wiki/AdaptiveParameters AdaptiveParameters]. This builds a custom checker that checks if the student answer is a parameter <code>C0</code> multiple of the correct answer in <code>$sol_str</code>.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Find a quadratic equation in terms of the variable<br />
[` x `] with roots [` -1 `] and [` 2 `].<br />
<br />
[` y = `] [______________]{$ans}<br />
<br />
[@ helpLink('formulas') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=StringOrOtherType1&diff=23770StringOrOtherType12023-07-18T10:06:33Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/StringOrOtherType.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Answer is a String, or a Number, or a Function, etc.</h2><br />
<br />
[[File:StringOrOtherType1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to prevent error messages from appearing when an answer may be one of several data types.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/StringOrOtherType1.pg FortLewis/Authoring/Templates/Precalc/StringOrOtherType1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/StringOrOtherType1_PGML.pg FortLewis/Authoring/Templates/Precalc/StringOrOtherType1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$y = random(0,4,1);<br />
<br />
if ($y < 4) {<br />
$answer = String("none");<br />
} else {<br />
$answer = Formula("2*x");<br />
}<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
There are several predefined strings, such as <code>NONE, DNE, INF, INFINITY</code>. If you need another string added to the context, see [http://webwork.maa.org/wiki/StringsInContext strings in context].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
Is there a line through the points \( (0,0) \), <br />
\( (1,2) \), and \( (2,$y) \)? If there is, <br />
the equation for this line. If not, enter<br />
${BITALIC}NONE${EITALIC}.<br />
$BR<br />
$BR<br />
\( y = \) \{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("formulas") \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $answer->cmp( typeMatch=>Formula("x") ) );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
When <code>$answer = Formula("2*x")</code> and a student enters the string <code>NONE</code>, they will not get any error message because when the answer checker expects a formula and gets a string it is set up not to balk. However, when <code>$answer = String("none")</code> and a student enters the formula <code>2x</code>, they will get an error message. This is because the answer checker is expecting a string and gets a formula, and when this happens it balks. <br />
We must use <code>typeMatch=>Formula("x")</code> so that in the event the answer is a string, no error message will appear.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
${PAR}SOLUTION:${PAR}<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=TableOfValues1&diff=23769TableOfValues12023-07-18T10:05:58Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/TableOfValues.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Fill in a Table of Values for a Function</h2><br />
<br />
[[File:TableOfValues1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to create a table with answer blanks in it.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/TableOfValues1.pg FortLewis/Authoring/Templates/Precalc/TableOfValues1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/TableOfValues1_PGML.pg FortLewis/Authoring/Templates/Precalc/TableOfValues1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$f = Formula("3^(-x)");<br />
<br />
@answer = ();<br />
foreach my $i (0..2) {<br />
$answer[$i] = $f->eval(x=>$i);<br />
}<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
We create an empty array <code>@answer</code> and use a foreach loop to simplify filling it with values.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
If \( f(x) = $f \), fill in the table of values with numbers.<br />
\{ AnswerFormatHelp("numbers") \}<br />
$PAR<br />
$BCENTER<br />
\{ <br />
begintable(5) .<br />
row( "\(x = \)", "0", "1", "2" ) .<br />
row( "\(f(x) = \)", ans_rule(5), ans_rule(5), ans_rule(5) ) .<br />
endtable(); <br />
\}<br />
$ECENTER<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
Notice that the table is inside a Perl code block <code>\{ \}</code> and that there are periods at the end of each line (after each of the subroutines <code>begintable(num cols)</code> and <code>row( )</code>) except for the last line. These periods are Perl's string concatenation operator.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
foreach my $i (0..2) {<br />
ANS( $answer[$i]->cmp() );<br />
}<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
${PAR}SOLUTION:${PAR}<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=ScalingTranslating1&diff=23768ScalingTranslating12023-07-18T10:05:18Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/ScalingTranslating.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Scaling and Translating Functions</h2><br />
<br />
[[File:ScalingTranslating1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to add a named function to the context and use it to asses whether students know their graph transformations.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/ScalingTranslating1_PGML.pg FortLewis/Authoring/Templates/Precalc/ScalingTranslating1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
"parserFunction.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We must load <code>parserFunction.pl</code> so that we can add a named function to the context.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
parserFunction(f => "sin(e*x)+5.5*pi");<br />
<br />
$answer = Formula("f(x-2) + 1");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
The <code>parserFunction</code> method allows us to add a named function to the context. We can define this function however we want, so we chose a function whose formula the students will not guess, whose domain is all real numbers, and which will have no issues during answer evaluation. Once a named function is added to the context, you can use it like you would any other named function.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
A function \( f(x) \) is shifted to the right<br />
\( 2 \) units and up \( 1 \) unit. Find a formula <br />
for this shifted function in terms of the function<br />
\( f(x) \).<br />
$BR<br />
$BR<br />
Answer = \{ ans_rule(20) \}<br />
\{ AnswerFormatHelp("formulas") \}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS( $answer->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
${PAR}SOLUTION:${PAR}<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=FunctionDecomposition1&diff=23767FunctionDecomposition12023-07-18T10:04:28Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/FunctionDecomposition.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Function Decomposition</h2><br />
<br />
[[File:FunctionDecomposition1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to check student answers that are a composition of functions.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1.pg FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1_PGML.pg FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1_PGML.pg]<br />
<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th style="width: 50%"> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
'PGstandard.pl',<br />
'MathObjects.pl',<br />
'answerComposition.pl',<br />
'PGML.pl',<br />
'PGcourse.pl'<br />
);<br />
TEXT(beginproblem());<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
We need to include the macros file <code>answerComposition.pl</code>, which provides an answer checker that determines if two functions compose to form a given function. This can be used in problems where you ask a student to break a given function into a composition of two simpler functions, neither of which is allowed to be the identity function.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
Context()->variables->add(u=>"Real");<br />
<br />
$a = random(2,9,1);<br />
<br />
$f = Formula("sqrt(u)");<br />
$g = Formula("x^2+$a");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML<br />
Express the function [` y = \sqrt{ x^2 + [$a] } `]<br />
as a composition [` y = f(g(x)) `] of two simpler<br />
functions [` y = f(u) `] and [` u = g(x) `].<br />
<br />
+ [` f(u) = `] [_______________]<br />
<br />
+ [` g(x) = `] [_______________]<br />
<br />
[@ helpLink('formula') @]*<br />
END_PGML<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
$showPartialCorrectAnswers = 1;<br />
<br />
COMPOSITION_ANS( $f, $g, vars=>['u','x'], showVariableHints=>1);<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
We use the <code>COMPOSITION_ANS()</code> routine to evaluate both answer blanks. It is possible to use the same variable for both answer blanks. See [http://webwork.maa.org/pod/pg/macros/answerComposition.html answerComposition.pl] for more options and details.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
BEGIN_PGML_SOLUTION<br />
Solution explanation goes here.<br />
END_PGML_SOLUTION<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabphttps://webwork.maa.org/mediawiki_new/index.php?title=DynamicGraph1&diff=23766DynamicGraph12023-07-18T10:03:32Z<p>Pstaabp: add historical tag and give links to newer problems.</p>
<hr />
<div>{{historical}}<br />
<br />
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/DynamicGraph.html a newer version of this problem]</p><br />
<br />
<br />
<h2>Dynamically Generated Graph</h2><br />
<br />
[[File:DynamicGraph1.png|300px|thumb|right|Click to enlarge]]<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This PG code shows how to create a dynamically generated graph with labels that is appropriately sized and positioned.<br />
</p><br />
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DynamicGraph1.pg FortLewis/Authoring/Templates/Precalc/DynamicGraph1.pg]<br />
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DynamicGraph1_PGML.pg FortLewis/Authoring/Templates/Precalc/DynamicGraph1_PGML.pg]<br />
<br />
<br clear="all" /><br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<br />
<!-- Problem tagging section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeeeee;border:black 1px dashed;"><br />
[http://webwork.maa.org/wiki/Tagging_Problems Problem tagging data]<br />
</td><br />
<td style="background-color:#eeeeee;padding:7px;"><br />
<p><br />
<b>Problem tagging:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Initialization section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddffdd;border:black 1px dashed;"><br />
<pre><br />
DOCUMENT();<br />
<br />
loadMacros(<br />
"PGstandard.pl",<br />
"MathObjects.pl",<br />
"AnswerFormatHelp.pl",<br />
"PGgraphmacros.pl",<br />
"unionTables.pl",<br />
);<br />
<br />
TEXT(beginproblem());<br />
<br />
$refreshCachedImages = 1;<br />
</pre><br />
</td><br />
<td style="background-color:#ddffdd;padding:7px;"><br />
<p><br />
<b>Initialization:</b><br />
Dynamically generated graphs require <code>PGgraphmacros.pl</code>, and we will use <code>unionTables.pl</code> to put the text and the graph side-by-side in two columns. It is important to set <code>$refreshCachedImages = 1</code> if you want the image to be generated and delivered every time the page is refreshed, otherwise a cached image may be used.<br />
</p><br />
</td><br />
</tr><br />
<br />
<br />
<!-- Setup section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
Context("Numeric");<br />
<br />
$a = random(2,3,1); # left x-intercept<br />
$b = random(2,4,2); # right x-intercept<br />
$c = random(5,6,1); # y-intercept<br />
<br />
$k = -($c)/($a * $b);<br />
<br />
$A = $k;<br />
$B = $k*($a - $b);<br />
$C = -($k * $a * $b);<br />
<br />
#<br />
# Graph canvas<br />
#<br />
$gr = init_graph(-5,-1,5,9,axes=>[0,0],grid=>[10,10],size=>[300,300]);<br />
$gr -> lb('reset');<br />
<br />
#<br />
# Graph labels and functions<br />
#<br />
$gr -> lb(new Label ( 4.5,0,'x','black','left','bottom'));<br />
$gr -> lb(new Label ( 0.25,8.5,'y','black','left','bottom'));<br />
$gr -> lb(new Label ( 0.25,$c,'y = f(x)','black','left','bottom'));<br />
foreach my $i (1..4) {<br />
$gr -> lb(new Label ( $i,-0.5, $i,'black','center','middle'));<br />
$gr -> lb(new Label (-$i,-0.5,-$i,'black','center','middle'));<br />
}<br />
foreach my $j (1..8) {<br />
$gr -> lb(new Label (-4.5,$j,$j,'black','center','middle'));<br />
}<br />
add_functions($gr, "$A*x**2+$B*x+$C for x in <-5,5> using color:blue and weight:2");<br />
</pre><br />
</td><br />
<td style="background-color:#ffffcc;padding:7px;"><br />
<p><br />
<b>Setup:</b> <br />
For more details on the graph object <code>$gr</code>, see the help documents for graphs in the [[IndexOfProblemTechniques|index of problem techniques]].<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Main text section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffdddd;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_TEXT<br />
\{<br />
ColumnTable(<br />
"Use the graph to find the missing values. <br />
There may be more than one correct answer, <br />
in which case you should enter your answers<br />
as a comma separated list. If there are no<br />
correct answers, enter ${BITALIC}NONE.${EITALIC}<br />
$BR<br />
$BR<br />
(a) \( f(0) = \) " . <br />
ans_rule(7).$SPACE.<br />
AnswerFormatHelp("numbers").<br />
"$BR<br />
$BR<br />
(b) \( f \big( \) ".ans_rule(7)." \( \big) = 0 \). ".<br />
AnswerFormatHelp("numbers")<br />
,<br />
image(insertGraph($gr), width=>300, height=>300, tex_size=>700).<br />
$BR.$BCENTER.<br />
$BR.<br />
"Graph of \( y = f(x) \)".<br />
$ECENTER<br />
,<br />
indent => 0, separation => 30, valign => "TOP"<br />
)<br />
\}<br />
END_TEXT<br />
Context()->normalStrings;<br />
</pre><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
<b>Main Text:</b><br />
We use a two column format provided by <code>ColumnTable(first column, second column, options)</code>. In each column, we use the string concatenation operator <code>.</code> quite a bit to join together strings and other methods because the entire ColumnTable is inside Perl mode curly braces <code>\{ \}</code>. To make the separation between the columns easier to read, we have put two commas on their own lines. Notice that there is no period before any of the commas. <br />
</p><br />
<p><br />
Using a <code>ColumnTable</code> is best because in HTML mode the text and graph will be side by side, while in the PDF output the columns will be stacked on top of each other so that the text is on top of the graph. Pay attention to the size of your graph in HTML and in PDF output, and make it big enough to read easily in either format.<br />
</p><br />
<p><br />
Many existing questions generate image files with larger dimensions than necessary, but scale them down so as to be unreadable in HTML and PDF output, which makes them hard or impossible to use. If you have the time to make a graph, take the extra time to make it an appropriate size in both HTML and PDF output.<br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Answer evaluation section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#eeddff;border:black 1px dashed;"><br />
<pre><br />
<br />
$showPartialCorrectAnswers = 1;<br />
<br />
ANS(List($c)->cmp() );<br />
<br />
ANS(List(-$a,$b)->cmp() );<br />
</pre><br />
<td style="background-color:#eeccff;padding:7px;"><br />
<p><br />
<b>Answer Evaluation:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
<!-- Solution section --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ddddff;border:black 1px dashed;"><br />
<pre><br />
Context()->texStrings;<br />
BEGIN_SOLUTION<br />
${PAR}SOLUTION:${PAR}<br />
Solution explanation goes here.<br />
END_SOLUTION<br />
Context()->normalStrings;<br />
<br />
COMMENT('MathObject version.');<br />
<br />
ENDDOCUMENT();<br />
</pre><br />
<td style="background-color:#ddddff;padding:7px;"><br />
<p><br />
<b>Solution:</b><br />
</p><br />
</td><br />
</tr><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Top]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]</div>Pstaabp