Difference between revisions of "VariablesOtherThanX"
(added historical tag and gave updated problem link) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/OtherVariables.html a newer version of this problem]</p> |
||
<h2>Variables Other than x in Formulas: PG Code Snippet</h2> |
<h2>Variables Other than x in Formulas: PG Code Snippet</h2> |
||
Line 23: | Line 26: | ||
<p> |
<p> |
||
We need make no changes to the documentation or initialization sections of the problem file. In the set-up section, we add the variable(s) (comma separated) that we need to the Context. If we want to exclude any existing variable(s), we can use <code>are</code> instead of <code>add</code> (e.g., <code>Context()->variables->are(t=>"Real",z=>"Real");</code>). |
We need make no changes to the documentation or initialization sections of the problem file. In the set-up section, we add the variable(s) (comma separated) that we need to the Context. If we want to exclude any existing variable(s), we can use <code>are</code> instead of <code>add</code> (e.g., <code>Context()->variables->are(t=>"Real",z=>"Real");</code>). |
||
+ | </p> |
||
+ | <p> |
||
+ | You can also add variables that are symbols to the context by specifying the TeX parameter, as in |
||
+ | <code>Context()->variables->are('pi'=>['Real', TeX=>'\pi']);</code> |
||
</p> |
</p> |
||
</td> |
</td> |
Latest revision as of 08:52, 28 June 2023
This problem has been replaced with a newer version of this problem
Variables Other than x in Formulas: PG Code Snippet
This code snippet shows the essential PG code to use variables other than x in formulas. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
Context()->variables->add(t=>"Real"); $d = Compute("-16 t^2 + 5 t + 16"); |
We need make no changes to the documentation or initialization sections of the problem file. In the set-up section, we add the variable(s) (comma separated) that we need to the Context. If we want to exclude any existing variable(s), we can use
You can also add variables that are symbols to the context by specifying the TeX parameter, as in
|
BEGIN_TEXT The height of an object thrown upwards with an initial speed of 5ft/s from a height of 16ft is: \{ans_rule(25)\} END_TEXT |
The text and answer sections of the file need not be changed. |
ANS( $d->cmp() ); |
|