Mathematical notation recognized by WeBWorK: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== Operators == | == Operators == | ||
Operators recognized by WeBWorK, in order from highest to lowest precedence. | Operators recognized by WeBWorK, in order from highest to lowest precedence. Not all operators are available in all problems. | ||
{|border="1" | {|border="1" | ||
Line 7: | Line 7: | ||
|- | |- | ||
! <code>_</code> | ! <code>_</code> | ||
| 9 || binary || left || Vector and matrix element extraction | | 9 || binary || left || Vector and matrix element extraction | ||
|- | |- | ||
! <code>!</code> | ! <code>!</code> | ||
Line 75: | Line 75: | ||
use strict; | use strict; | ||
use warnings; | use warnings; | ||
BEGIN { | BEGIN { | ||
die "WEBWORK_ROOT not found in environment.\n" | |||
unless exists $ENV{WEBWORK_ROOT}; | |||
} | } | ||
use lib "$ENV{WEBWORK_ROOT}/lib"; | use lib "$ENV{WEBWORK_ROOT}/lib"; | ||
use WeBWorK::CourseEnvironment; | use WeBWorK::CourseEnvironment; | ||
my $ce = new WeBWorK::CourseEnvironment({webwork_dir=>$ENV{WEBWORK_ROOT}}); | my $ce = new WeBWorK::CourseEnvironment({webwork_dir=>$ENV{WEBWORK_ROOT}}); | ||
push @INC, $ce->{pg}{directories}{lib}; | push @INC, $ce->{pg}{directories}{lib}; | ||
require Parser; | require Parser; | ||
my %ops = %{$Parser::Context::Default::context{Full}{operators}}; | my %ops = %{$Parser::Context::Default::context{Full}{operators}}; | ||
print "{|border=\"1\"\n"; | print "{|border=\"1\"\n"; | ||
Line 100: | Line 96: | ||
} | } | ||
print "|}\n"; | print "|}\n"; | ||
--> | |||
== Constants == | |||
== Functions == | |||
In general, functions can be used with or without parentheses. For example, <code>cosx</code>, <code>cos x</code>, and <code>cos(x)</code> are all equivalent. However, using parentheses makes grouping more explicit and are recommended. | |||
;Simple trig functions | |||
* sin() | |||
* cos() | |||
* tan() | |||
* sec() | |||
* csc() | |||
* cot() | |||
InverseTrig => [qw(asin acos atan asec acsc acot | |||
arcsin arccos arctan arcsec arccsc arccot atan2)], | |||
SimpleHyperbolic => [qw(sinh cosh tanh sech csch coth)], | |||
InverseHyperbolic => [qw(asinh acosh atanh asech acsch acoth | |||
arcsinh arccosh arctanh arcsech arccsch arccoth)], | |||
Numeric => [qw(log log10 exp sqrt abs int sgn ln logten)], | |||
Vector => [qw(norm unit)], | |||
Complex => [qw(arg mod Re Im conj)], |
Revision as of 00:09, 5 March 2008
Operators
Operators recognized by WeBWorK, in order from highest to lowest precedence. Not all operators are available in all problems.
Operator | Prec. | Type | Associativity | Description |
---|---|---|---|---|
_
|
9 | binary | left | Vector and matrix element extraction |
!
|
8 | unary | right | Factorial |
^
|
7 | binary | right | Exponentiation |
**
|
7 | binary | right | Exponentiation |
+
|
6 | unary | left | Unary plus (indicates that a value is positive) |
-
|
6 | unary | left | Unary minus (indicates that a value is negative) |
/
|
3 | binary | left | Division |
*
|
3 | binary | left | Multiplication |
.
|
2 | binary | left | Vector dot product |
><
|
2 | binary | left | Vector cross product |
U
|
1.5 | binary | left | Union |
-
|
1 | binary | left | Subtraction |
+
|
1 | binary | left | Addition |
,
|
0 | binary | left | List (vector, set, point, etc.) separator |
Constants
Functions
In general, functions can be used with or without parentheses. For example, cosx
, cos x
, and cos(x)
are all equivalent. However, using parentheses makes grouping more explicit and are recommended.
- Simple trig functions
- sin()
- cos()
- tan()
- sec()
- csc()
- cot()
InverseTrig => [qw(asin acos atan asec acsc acot arcsin arccos arctan arcsec arccsc arccot atan2)],
SimpleHyperbolic => [qw(sinh cosh tanh sech csch coth)], InverseHyperbolic => [qw(asinh acosh atanh asech acsch acoth arcsinh arccosh arctanh arcsech arccsch arccoth)],
Numeric => [qw(log log10 exp sqrt abs int sgn ln logten)],
Vector => [qw(norm unit)],
Complex => [qw(arg mod Re Im conj)],