Difference between revisions of "Category:MathObject Classes"

From WeBWorK_wiki
Jump to navigation Jump to search
(Change class file names for better alphabetical listing)
 
(2 intermediate revisions by one other user not shown)
Line 38: Line 38:
 
=== Other Classes ===
 
=== Other Classes ===
   
The <code>pg/macros</code> directory contains a number of extensions to MathObjects, including files that define specialized MathObject types. The ones that begin with <code>parser</code> typically define a new object class. For example, <code>parserParametricLine.pl</code> defines a constructor <code>ParametricLine()</code> for creating a special object that checks if a student's answer is a given parametric line or not, even if it is parameterized differently. These files usually contain documentation within them; see the [http://webwork.maa.org/pod/pg_TRUNK/ POD] documentation for versions that you can read on line.
+
The <code>pg/macros</code> directory contains a number of extensions to MathObjects, including files that define specialized MathObject types. The ones that begin with <code>parser</code> typically define a new object class. For example, <code>parserParametricLine.pl</code> defines a constructor <code>ParametricLine()</code> for creating a special object that checks if a student's answer is a given parametric line or not, even if it is parameterized differently. These files usually contain documentation within them; see the [http://webwork.maa.org/pod/pg POD] documentation for versions that you can read on line.
   
  +
<br>
   
 
[[Category:MathObjects]]
 
[[Category:MathObjects]]

Latest revision as of 17:26, 7 April 2021

MathObject Classes

The MathObjects library defines a number of object classes for various mathematical concepts, such as real numbers, complex numbers, intervals, vectors, points, and so on. To use these objects in a problem you are writing, include MathObjects.pl in your loadMacros() call. For example:

   loadMacros(
     "PGstandard.pl",
     "MathObjects.pl",
     "PGcourse.pl",
   );

Once this is done, there are several ways to create MathObjects in your problem:

  • By calling a constructor function for the type of object you want (e.g., Real(3.5) or Complex("3+4i"))
  • By calling Compute() to parse a string and return the resulting object (e.g., Compute("3+4i"))
  • By calling a method of an existing MathObject that returns another object (e.g., Formula("sin(x)")->eval(x => pi/2))
  • By combining existing MathObjects via mathematical operations (e.g., $x = Formula("x"); $f = $x**2 + 2*$x + 1)

The links in the next section include examples of how to create and use each MathObject class.


The Main MathObject Classes

The following links describe the various classes in more detail:

  • Real -- implements real numbers
  • Infinity -- implements infinity and negative infinity
  • Complex -- implements complex numbers
  • Point -- implements points in [math]{\bf R}^n[/math] and [math]{\bf C}^n[/math]
  • Vector -- implements vectors in [math]{\bf R}^n[/math] and [math]{\bf C}^n[/math]
  • Matrix -- implements matrices over the real and complex numbers
  • List -- implements lists of arbitrary MathObjects
  • Interval -- implements intervals of real numbers
  • Set -- implements finite sets of real numbers
  • Union -- implements unions of intervals or sets
  • String -- implements special words like NONE and DNE
  • Formula -- implements expressions involving one or more variables


Other Classes

The pg/macros directory contains a number of extensions to MathObjects, including files that define specialized MathObject types. The ones that begin with parser typically define a new object class. For example, parserParametricLine.pl defines a constructor ParametricLine() for creating a special object that checks if a student's answer is a given parametric line or not, even if it is parameterized differently. These files usually contain documentation within them; see the POD documentation for versions that you can read on line.