<math>
Examples Page 2
Attribute Example: functionSymbols
By default, Doenet considers and as symbols that represent functions
when they occur in mathematical expressions. To modify or override this default
behavior, or to include additional symbols representing functions, provide the
symbols as a space-separated list within the functionSymbols attribute specification.
If a symbol is not specified as a function, then parentheses after the symbol are interpreted as multiplication.
Attribute Example: referencesAreFunctionSymbols
By default, Doenet considers and as symbols that represent functions
when they occur in mathematical expressions. If the symbol itself is given by a
named reference using $name, the referencesAreFunctionSymbols attribute
alerts Doenet that the value stored in this reference is the function symbol. In the
example above, this could be any one of the five possible symbols that are assigned
in different variants to the reference <select>.
Attribute Example: splitSymbols
By default, letters placed adjacent to one another in a <math> component are separated by Doenet for computations, so xyz is interpreted as , rather than a single variable composed of three letters. To override this default behavior, set the splitSymbols attribute to false.
Attribute Example: displayBlanks
By default, Doenet inserts an underscore when there is a blank space (indicated by an empty set of parentheses in the DoenetML) within a <math>. To override this default behavior, set the displayBlanks attribute to false.
Attribute Example: displayDigits/displayDecimals
By default, maths that are also numbers will be displayed as rounded to three digits or to two decimal places, whichever includes more digits. The displayDigits attribute will change the number of digits, and the displayDecimals attribute will change the number of decimal places.
Note: these display rounding settings do not affect the actual value of the numbers in the expression. All
available digits will be used if the expression is used in another calculation unless one uses the <round>
component to explicitly round numbers.
Disclaimer: Using a <math> component with inexact decimal values is only used in
this example for illustrative purposes; it is not good practice. Note that, in a <math> or
a <number> component, it is better enter the symbolic representation of the irrational
number (i.e., to use , , , etc.) In addition, if
the final desired result is a numerical value, it may also be better to use the <number> component.
Attribute Example: displaySmallAsZero
The default value of the displaySmallAsZero attribute is , which means that maths which
are also numerical values smaller than that value will appear as zero. This behavior can be altered
by changing the value of displaySmallAsZero to a different number, or even setting it to “false”.
Disclaimer: In the above example, if the final desired result is a numerical
value, it may be better practice to use the <number> component.
Attribute Example: padZeros
If the padZeros is set, then maths which are also numbers will be displayed padded with
zeros so that all the digits from the combination of displayDigits and displayDecimals will be shown.
Disclaimer: In the above example, if the final desired result is a numerical value,
it may be better practice to use the <number> component.
Attribute Example: Standard graphical attributes
In this example, the uses of the standard graphical
attributes, anchor, hide, draggable, styleNumber, and layer are
illustrated. Note that the default layer is . Layers greater than will appear
in front of graphical elements on the default layer. Since default styleNumbers
are all somewhat transparent, this effect may not be clearly visible for default styles.
Property Example: Attributes as properties
The <math> attributes listed above are also accessible as properties.
Property Example: unordered
The unordered property returns the boolean value true if the <math> is
considered without regard to order for validation purposes.
Property Example: number
If the value stored in the <math> component can be parsed as
a <number>, the number property returns this value.
Property Example: isNumber/ isNumeric
The isNumber property returns true if the <math> is a number, without any simplification. This implies that the number property of the <math> is equivalent to the <math> itself. (Note, that simplification includes substituting the numerical value of the symbol for pi, so pi returns a false for isNumber.)
The isNumeric property returns true if the <math> evaluates to a number, or simplifies to a number. This implies that the property number returns a value, rather than NaN.
Property Example: latex
The latex property returns the LaTeX of the <math> expression.
Property Example: text
The text property returns the text value of the <math> expression.
Property Example: numDimensions
The numDimensions property returns the number of dimensions of the <math>.
Property Example: vector
If the <math> component is expressed in the form of a tuple, the vector property returns the vector value of the <math>. The vector will also convert a row or column matrix into a vector.
Property Example: matrixSize
When the <math> component involves a matrix, the matrixSize attribute returns the dimensions of the matrix. In this example, math1 involves multiplication of two matrices. This operation is carried out with the expand attribute in the definition of math2. The matrixSize property of math2 returns 2,1 for the 2 rows x 1 column of the resultant matrix.
Property Example: numRows/ numColumns
The numRows and numCols properties return the dimensions of a <math> that takes the form of a matrix.
Property Example: matrix
The matrix property can be used to render the value of a <math> in matrix form, or it can be used with array notation to access a distinct entry within a matrix. It can also be used to convert vectors into matrices.