https://webwork.maa.org/mediawiki_new/api.php?action=feedcontributions&user=PhilipLoewen&feedformat=atomWeBWorK_wiki - User contributions [en]2022-09-26T06:43:39ZUser contributionsMediaWiki 1.34.0https://webwork.maa.org/mediawiki_new/index.php?title=Available_Functions&diff=22526Available Functions2022-01-05T07:46:06Z<p>PhilipLoewen: /* Exponential and Logarithmic Functions */ Clean up.</p>
<hr />
<div>====Mathematical Symbols Available In WeBWorK====<br />
<br />
* + Addition<br />
* - Subtraction<br />
* * Multiplication can also be indicated by a space or juxtaposition, e.g. 2x, 2 x or 2*x, also 2(3+4).<br />
* / Division<br />
* ^ or ** You can use either ^ or ** for exponentiation, e.g. 3^2 or 3**2<br />
* Parentheses: () - You can also use square brackets, [ ], and braces, { }, for grouping, e.g. [1+2]/[3(4+5)]<br />
* Note: 1/2x is evaluated from left to right and means <math>\frac{1}{2}x</math>, which might not have been what you meant.<br />
<br />
====Syntax for entering expressions====<br />
<br />
* '''Use the "Preview Button" to see exactly how your entry looks. E.g. to tell the difference between 1+2/3*4 and (1+2)/(3*4) click the "Preview Button".'''<br />
* Sometimes using the * symbol to indicate multiplication makes things easier to read. For example (1+2)*(3+4) and (1+2)(3+4) are both valid. So are 3*4 and 3 4 (3 space 4, not 34) but using a * makes things clearer.<br />
* Use ('s and )'s to make your meaning clear. You can also use ['s and ]'s and {'s and }'s (except in contexts where those have special meanings, like creating intervals or sets).<br />
* Don't enter 2/4+5 (which is 5.5) when you really want 2/(4+5) (which is 2/9).<br />
* Don't enter 2/3*4 (which is 8/3) when you really want 2/(3*4) (which is 2/12).<br />
* Entering big quotients with square brackets, e.g. [1+2+3+4]/[5+6+7+8], is a good practice.<br />
* Be careful when entering functions. It's always good practice to use parentheses when entering functions. Write sin(t) instead of sint or sin t even though WeBWorK is smart enough to '''usually''' accept sin t or even sint. For example, sin 2t is interpreted as sin(2)t, i.e. (sin(2))*t, so be careful.<br />
* You can enter sin^2(t) as a shortcut although mathematically speaking sin^2(t) is shorthand for (sin(t))^2 (the square of sin of t). (You can enter it as sin(t)^2 or even sint^2, but don't try such things unless you '''really''' understand the precedence of operations. The "sin" operation has highest precedence, so it is performed first, using the next token (i.e. t) as an argument. Then the result is squared.) You can always use the Preview button to see a typeset version of what you entered and check whether what you wrote was what you meant. :-)<br />
* For example 2+3sin^2(4x) will work and is equivalent to 2+3(sin(4x))^2 or 2+3sin(4x)^2. Why does the last expression work? Because things in parentheses are always done first [ i.e. (4x)], next all functions, such as sin, are evaluated [giving sin(4x)], next all exponents are taken [giving sin(4x)^2], next all multiplications and divisions are performed in order from left to right [giving 3sin(4x)^2], and finally all additions and subtractions are performed [giving 2+3sin(4x)^2].<br />
* Is -5^2 positive or negative? It's negative. This is because the square operation is done before the negative sign is applied. Use (-5)^2 if you want to square negative 5.<br />
* When in doubt use parentheses!!! :-)<br />
* The complete rules for the precedence of operations, in addition to the above, are<br />
** Additions and subtractions are performed left to right: 1-2+3 = (1-2)+3 = 2.<br />
** Multiplications and divisions are performed left to right: 2/3*4 = (2/3)*4 = 8/3.<br />
** Exponents are taken right to left: 2^3^4 = 2^(3^4) = 2^81 = a big number.<br />
* '''Use the "Preview Button" to see exactly how your entry looks. E.g. to tell the difference between 1+2/3*4 and [1+2]/[3*4] click the "Preview Button".'''<br />
<br />
====Mathematical Constants Available In WeBWorK====<br />
<br />
* pi This gives 3.14159265358979, e.g. cos(pi) is -1<br />
* e This gives 2.71828182845905, e.g. ln(e*2) is 1 + ln(2)<br />
<br />
====Scientific Notation Available In WeBWorK====<br />
<br />
* 2.1E2 is the same as 210<br />
* 2.1E-2 is the same as .021<br />
<br />
====Interval Notation====<br />
<br />
Some problems require you to enter an interval of real numbers. <br />
* (-2,5) the open interval from -2 to 5, i.e. all real numbers greater than -2 and smaller than 5<br />
* [2,5) the half-open interval containing all real numbers greater than or equal to 2 and smaller than 5<br />
* (-inf, 10] all real numbers less than or equal to 10 (inf stands for infinity)<br />
<br />
====Mathematical Functions Available In WeBWorK====<br />
<br />
Unless otherwise specified, all of the functions listed below are enabled by default. However, sometimes one or more of these functions is disabled for <br />
a particular WeBWorK problem because the instructor wants you to calculate the answer by some means other than just using the function.<br />
<br />
* sqrt(x) -- The square root of x. Also can be written x^(1/2).<br />
* abs(x) -- The absolute value of x. Also can be written |x|.<br />
<br />
=====Exponential and Logarithmic Functions=====<br />
<br />
* ln(x) -- The natural logarithm (logarithm to the base e)<br />
* log(x) -- This is usually the natural logarithm, but some instructors redefine it to mean log to the base 10<br />
* log10(x) -- The logarithm to the base 10<br />
<br />
=====Trigonometric Functions=====<br />
<br />
'''Note''': All of the trigonometric functions use '''radian''' measure.<br />
<br />
* sin(x)<br />
* cos(x)<br />
* tan(x)<br />
* cot(x)<br />
* sec(x) <br />
* csc(x)<br />
<br />
* arcsin(x), asin(x), or sin^-1(x) <br />
* arccos(x), acos(x), or cos^-1(x)<br />
* arctan(x), atan(x), or tan^-1(x)<br />
* arccot(x), acot(x), or cot^-1(x)<br />
* arcsec(x), asec(x), or sec^-1(x)<br />
* arccsc(x), acsc(x), or csc^-1(x)<br />
<br />
=====Hyperbolic Trig Functions=====<br />
<br />
* sinh(x)<br />
* cosh(x)<br />
* tanh(x)<br />
* sech(x)<br />
* csch(x)<br />
* coth(x)<br />
<br />
* arcsinh(x), asinh(x), or sinh^-1(x)<br />
* arccosh(x), acosh(x), or cosh^-1(x)<br />
* arctanh(x), atanh(x), or tanh^-1(x)<br />
* arcsech(x), asech(x), or sech^-1(x)<br />
* arccsch(x), acsch(x), or csch^-1(x)<br />
* arccoth(x), acoth(x), or coth^-1(x)<br />
<br />
=====Other Functions=====<br />
<br />
* n! -- n factorial (defined for nonnegative integers), can also be written as fact(n)<br />
* sgn(x) -- the sign function, either -1 (if x < 0), 0 (if x = 0), or 1 (if x > 0)<br />
<br />
These functions are available for some problems, but may not be enabled for others (for authoring information see [http://webwork.maa.org/wiki/StepFunctions step functions]):<br />
<br />
* step(x) -- the step function (1 if x > 0, 0 otherwise.)<br />
* P(n,k) = n*(n-1)*(n-2)...(n-k+1) the number of ordered sequences of k elements chosen from n elements<br />
<br />
The following functions are not enabled in student answers by default:<br />
<br />
* C(n,k) = "n choose k" the number of unordered sets of k elements chosen from n elements<br />
* ceil(x) The ceiling function that rounds up to the nearest integer<br />
* floor(x) The floor function that rounds down to the nearest integer<br />
* max(x,y) The max function<br />
* min(x,y) The min function<br />
<br />
These can be used in authoring problems if <code>PGauxiliaryFunctions.pl</code> is included in the problem. In order to use P(n,k) and C(n,k), you must be in the [http://webwork.maa.org/wiki/Specialized_contexts IntegerFunctions context].<br />
<br />
[[Category:HelpFiles]]<br />
[[Category:Students]]</div>PhilipLoewenhttps://webwork.maa.org/mediawiki_new/index.php?title=Available_Functions&diff=22525Available Functions2022-01-05T07:43:41Z<p>PhilipLoewen: /* Mathematical Symbols Available In WeBWorK */ Dropped orphaned symbols following the bullet list.</p>
<hr />
<div>====Mathematical Symbols Available In WeBWorK====<br />
<br />
* + Addition<br />
* - Subtraction<br />
* * Multiplication can also be indicated by a space or juxtaposition, e.g. 2x, 2 x or 2*x, also 2(3+4).<br />
* / Division<br />
* ^ or ** You can use either ^ or ** for exponentiation, e.g. 3^2 or 3**2<br />
* Parentheses: () - You can also use square brackets, [ ], and braces, { }, for grouping, e.g. [1+2]/[3(4+5)]<br />
* Note: 1/2x is evaluated from left to right and means <math>\frac{1}{2}x</math>, which might not have been what you meant.<br />
<br />
====Syntax for entering expressions====<br />
<br />
* '''Use the "Preview Button" to see exactly how your entry looks. E.g. to tell the difference between 1+2/3*4 and (1+2)/(3*4) click the "Preview Button".'''<br />
* Sometimes using the * symbol to indicate multiplication makes things easier to read. For example (1+2)*(3+4) and (1+2)(3+4) are both valid. So are 3*4 and 3 4 (3 space 4, not 34) but using a * makes things clearer.<br />
* Use ('s and )'s to make your meaning clear. You can also use ['s and ]'s and {'s and }'s (except in contexts where those have special meanings, like creating intervals or sets).<br />
* Don't enter 2/4+5 (which is 5.5) when you really want 2/(4+5) (which is 2/9).<br />
* Don't enter 2/3*4 (which is 8/3) when you really want 2/(3*4) (which is 2/12).<br />
* Entering big quotients with square brackets, e.g. [1+2+3+4]/[5+6+7+8], is a good practice.<br />
* Be careful when entering functions. It's always good practice to use parentheses when entering functions. Write sin(t) instead of sint or sin t even though WeBWorK is smart enough to '''usually''' accept sin t or even sint. For example, sin 2t is interpreted as sin(2)t, i.e. (sin(2))*t, so be careful.<br />
* You can enter sin^2(t) as a shortcut although mathematically speaking sin^2(t) is shorthand for (sin(t))^2 (the square of sin of t). (You can enter it as sin(t)^2 or even sint^2, but don't try such things unless you '''really''' understand the precedence of operations. The "sin" operation has highest precedence, so it is performed first, using the next token (i.e. t) as an argument. Then the result is squared.) You can always use the Preview button to see a typeset version of what you entered and check whether what you wrote was what you meant. :-)<br />
* For example 2+3sin^2(4x) will work and is equivalent to 2+3(sin(4x))^2 or 2+3sin(4x)^2. Why does the last expression work? Because things in parentheses are always done first [ i.e. (4x)], next all functions, such as sin, are evaluated [giving sin(4x)], next all exponents are taken [giving sin(4x)^2], next all multiplications and divisions are performed in order from left to right [giving 3sin(4x)^2], and finally all additions and subtractions are performed [giving 2+3sin(4x)^2].<br />
* Is -5^2 positive or negative? It's negative. This is because the square operation is done before the negative sign is applied. Use (-5)^2 if you want to square negative 5.<br />
* When in doubt use parentheses!!! :-)<br />
* The complete rules for the precedence of operations, in addition to the above, are<br />
** Additions and subtractions are performed left to right: 1-2+3 = (1-2)+3 = 2.<br />
** Multiplications and divisions are performed left to right: 2/3*4 = (2/3)*4 = 8/3.<br />
** Exponents are taken right to left: 2^3^4 = 2^(3^4) = 2^81 = a big number.<br />
* '''Use the "Preview Button" to see exactly how your entry looks. E.g. to tell the difference between 1+2/3*4 and [1+2]/[3*4] click the "Preview Button".'''<br />
<br />
====Mathematical Constants Available In WeBWorK====<br />
<br />
* pi This gives 3.14159265358979, e.g. cos(pi) is -1<br />
* e This gives 2.71828182845905, e.g. ln(e*2) is 1 + ln(2)<br />
<br />
====Scientific Notation Available In WeBWorK====<br />
<br />
* 2.1E2 is the same as 210<br />
* 2.1E-2 is the same as .021<br />
<br />
====Interval Notation====<br />
<br />
Some problems require you to enter an interval of real numbers. <br />
* (-2,5) the open interval from -2 to 5, i.e. all real numbers greater than -2 and smaller than 5<br />
* [2,5) the half-open interval containing all real numbers greater than or equal to 2 and smaller than 5<br />
* (-inf, 10] all real numbers less than or equal to 10 (inf stands for infinity)<br />
<br />
====Mathematical Functions Available In WeBWorK====<br />
<br />
Unless otherwise specified, all of the functions listed below are enabled by default. However, sometimes one or more of these functions is disabled for <br />
a particular WeBWorK problem because the instructor wants you to calculate the answer by some means other than just using the function.<br />
<br />
* sqrt(x) -- The square root of x. Also can be written x^(1/2).<br />
* abs(x) -- The absolute value of x. Also can be written |x|.<br />
<br />
=====Exponential and Logarithmic Functions=====<br />
<br />
* ln(x) -- The natural logarithm (logarithm to the base e)<br />
* log10(x) -- This is usually the natural log but your professor may have redefined this as log to the base 10<br />
log(y)<br />
<br />
=====Trigonometric Functions=====<br />
<br />
'''Note''': All of the trigonometric functions use '''radian''' measure.<br />
<br />
* sin(x)<br />
* cos(x)<br />
* tan(x)<br />
* cot(x)<br />
* sec(x) <br />
* csc(x)<br />
<br />
* arcsin(x), asin(x), or sin^-1(x) <br />
* arccos(x), acos(x), or cos^-1(x)<br />
* arctan(x), atan(x), or tan^-1(x)<br />
* arccot(x), acot(x), or cot^-1(x)<br />
* arcsec(x), asec(x), or sec^-1(x)<br />
* arccsc(x), acsc(x), or csc^-1(x)<br />
<br />
=====Hyperbolic Trig Functions=====<br />
<br />
* sinh(x)<br />
* cosh(x)<br />
* tanh(x)<br />
* sech(x)<br />
* csch(x)<br />
* coth(x)<br />
<br />
* arcsinh(x), asinh(x), or sinh^-1(x)<br />
* arccosh(x), acosh(x), or cosh^-1(x)<br />
* arctanh(x), atanh(x), or tanh^-1(x)<br />
* arcsech(x), asech(x), or sech^-1(x)<br />
* arccsch(x), acsch(x), or csch^-1(x)<br />
* arccoth(x), acoth(x), or coth^-1(x)<br />
<br />
=====Other Functions=====<br />
<br />
* n! -- n factorial (defined for nonnegative integers), can also be written as fact(n)<br />
* sgn(x) -- the sign function, either -1 (if x < 0), 0 (if x = 0), or 1 (if x > 0)<br />
<br />
These functions are available for some problems, but may not be enabled for others (for authoring information see [http://webwork.maa.org/wiki/StepFunctions step functions]):<br />
<br />
* step(x) -- the step function (1 if x > 0, 0 otherwise.)<br />
* P(n,k) = n*(n-1)*(n-2)...(n-k+1) the number of ordered sequences of k elements chosen from n elements<br />
<br />
The following functions are not enabled in student answers by default:<br />
<br />
* C(n,k) = "n choose k" the number of unordered sets of k elements chosen from n elements<br />
* ceil(x) The ceiling function that rounds up to the nearest integer<br />
* floor(x) The floor function that rounds down to the nearest integer<br />
* max(x,y) The max function<br />
* min(x,y) The min function<br />
<br />
These can be used in authoring problems if <code>PGauxiliaryFunctions.pl</code> is included in the problem. In order to use P(n,k) and C(n,k), you must be in the [http://webwork.maa.org/wiki/Specialized_contexts IntegerFunctions context].<br />
<br />
[[Category:HelpFiles]]<br />
[[Category:Students]]</div>PhilipLoewenhttps://webwork.maa.org/mediawiki_new/index.php?title=Mathematical_notation_-_PGML&diff=22499Mathematical notation - PGML2021-10-28T15:42:54Z<p>PhilipLoewen: /* Math and Variable Substitution */ Spelling correction.</p>
<hr />
<div>__TOC__<br />
== Mathematical Notation ==<br />
<br />
Mathematical notation in PGML can be entered in two different formats: TeX and algebra notation. TeX (or LaTeX) is the format used by most mathematicians to write papers involving mathematics. You can recognize it from its use of backslashes to indicate "commands" and curly braces for grouping. An expression like <code>\sum_{n=1}^\infty a_n</code> is a TeX expression. Algebra notation is the notation used by students to enter their answers, and professors to create MathObjects in the PG problems that they write. You can use whichever form is most convenient for you, and you can even mix the two in the same PGML text block.<br />
<br />
In addition to two types of math input, there are three forms of math output: inline, display-style inline, and display. Inline math tries to use as little vertical space as possible so as to not disrupt the line spacing within a paragraph. So things like summation signs will have their limits presented to the right of the sign rather than over top and underneath it, and fractions will use smaller fonts in the numerator and denominator to make the fraction smaller. Display-style inline math uses more vertical space, so summation limits are shown above and below the summation sign. This often means that more space is used between adjacent lines. Display math places the math on its own line, centered, with some buffering space above and below. And things like the summation limits are handled just like display-style inline.<br />
<br />
Both input forms give you a way to indicate whether you want inline, display-style inline, or display math.<br />
<br />
=== TeX Notation ===<br />
<br />
To enter math in TeX notation, surround it by <code>[`...`]</code> for inline math, <code>[``...``]</code> for display-style inline math, and <code>[```...```]</code> for display math. For example<br />
<br />
This is in-line math: [`\frac{x+1}{x-1}`], and this math is inline display-style: [``\frac{x+1}{x-1}``], and this math is display: [```\frac{x+1}{x-1}```]<br />
<br />
=== Algebra Notation ===<br />
<br />
To enter math in algebra notation, surround it by <code>[: ... :]</code> for inline math, <code>[:: ... ::]</code> for display-style inline math, and <code>[::: ... :::]</code> for display math. For example<br />
<br />
This is in-line math: [:(x+1)/(x-1):], and this math is inline display-style: [::(x+1)/(x-1)::], and this math is display: [:::(x+1)/(x-1):::]<br />
<br />
The algebra notation uses MathObjects to parse the mathematics for display. By default, it uses a special context called the [[Typeset Context]] that includes many more functions and operators than most other contexts. It is designed to allow you to produce sophisticated mathematical output without the need for TeX, if you prefer a simpler notation.<br />
<br />
If you want to use a different context, however, you can select one by putting its name in braces after the closing bracket for the math delimiters.<br />
<br />
This is in the Vector context: [: <1,2,3> :]{"Vector"}<br />
<br />
You can also provide a Context object instead.<br />
<br />
$context = Context("Vector");<br />
BEGIN_PGML<br />
This is also in Vector context: [: <1,2,3> :]{$context}<br />
END_PGML<br />
<br />
Finally, if you want to use the current context rather than the Typeset context, place an asterisk after the delimiter.<br />
<br />
Context("Vector");<br />
BEGIN_PGML<br />
This is also in Vector context: [: <1,2,3> :]*<br />
END_PGML<br />
<br />
== Math and Variable Substitution ==<br />
<br />
MathObjects can produce either a TeX version of themselves, or an algebra string version. In the traditional <code>BEGIN_TEXT/END_TEXT</code> block, you must be careful about how you insert a MathObject so as to produce the proper format. This involves either calling the <code>TeX()</code> method of the MathObject, or setting the Context to produce TeX strings automatically. This is awkward and easy to get wrong.<br />
<br />
PGML, on the other hand, knows how you are using your MathObjects, and produces the proper format automatically. If a MathObject is inserted inside TeX delimiters, its TeX form is used, and if inside algebra delimiters (or not in math mode at all), its algebra form is used. So you should not have to worry about inserting MathObjects into PGML -- it should just work.<br />
<br />
$f = Formula("(x+1)/(x-1)");<br />
<br />
BEGIN_PGML<br />
This is TeX: [`` \int [$f]\,dx ``]<br />
<br />
This is algebra: [:: Int(x,[$f]) ::]<br />
<br />
This is text: [$f]<br />
END_PGML<br />
<br />
Here, the first two should produce properly formatted integrals (one used TeX notation and the other algebra notation). The third one will include <code>(x+1)/(x-1)</code> as a literal algebra string.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>PhilipLoewen