Referencemath (Page 1)

<math>

A math expression

<math> is a Math component that defines a symbolic or numerical math expression that can be rendered and used in computations.

Attributes and Properties

Attributes for <math>

Highlighted (3)

integer. Default value: 3. Number of significant digits to display when rendering this number.

keyword. Input format.

ValueDescription
text (default)Plain-text math notation (e.g., x^2 + 1).
latexLaTeX-formatted math (e.g., x^{2} + 1).
simplify

keyword. Level of simplification applied to the expression.

ValueDescription
none (default)No simplification is applied.
fullFully simplify the expression.
numbersSimplify numeric subexpressions only, leaving symbolic structure intact.
numbersPreserveOrderLike numbers, but does not reorder commutative operands.
normalizeOrderReorder commutative operands into a canonical form without simplifying values.
Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

integer. Default value: 2. Number of decimal places to display when rendering this number.

integer. Default value: 3. Number of significant digits to display when rendering this number.

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Positioning (2)
anchor

point. Default value: \(\left( 0, 0 \right)\). Coordinates of the anchor point used to position this component on a graph.

positionFromAnchor

keyword. Where this component sits relative to its anchor point.

ValueDescription
upperRightPlace the component above and to the right of the anchor point.
upperLeftPlace the component above and to the left of the anchor point.
lowerRightPlace the component below and to the right of the anchor point.
lowerLeftPlace the component below and to the left of the anchor point.
topPlace the component directly above the anchor point.
bottomPlace the component directly below the anchor point.
leftPlace the component directly to the left of the anchor point.
rightPlace the component directly to the right of the anchor point.
center (default)Center the component on the anchor point.
Other (13)
assumptions

math. Default value: \(_\). Assumptions applied when simplifying or comparing.

createIntervals

boolean. Default value: false. Whether range expressions are interpreted as intervals.

createVectors

boolean. Default value: false. Whether tuple-like expressions are interpreted as vectors.

boolean. Default value: true. Whether blanks (placeholders) are visibly rendered.

draggable

boolean. Default value: true. Whether the math component can be dragged on a graph.

boolean. Default value: false. Whether to expand the expression.

textList. Default value: ["f","g"]. Symbols treated as function names when parsing.

layer

number. Default value: 0. Z-order layer index when shown on a graph.

parseScientificNotation

boolean. Default value: false. Whether to parse expressions like 1e3 as scientific notation.

reference. References whose names should be treated as function symbols when parsing.

renderMode

text. Default value: inline. How the math is rendered (e.g. "inline", "display").

boolean. Default value: true. Whether multi-character symbols are split into a product of variables.

boolean. Default value: false. Whether tuple- or list-like math expressions should be treated as unordered for comparison.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <math name="m">

Highlighted (3)
$m.displayDigits

integer. Number of significant digits to display when rendering this number.

$m.format

text. Input format.

$m.simplify

text. Level of simplification applied to the expression.

Number display (5)
$m.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$m.displayDecimals

integer. Number of decimal places to display when rendering this number.

$m.displayDigits

integer. Number of significant digits to display when rendering this number.

$m.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$m.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Positioning (2)
$m.anchor

point. The coordinates where this component is anchored on the graph.

$m.positionFromAnchor

text. Where this component sits relative to its anchor point.

Other (38)
$m.assumptions

math. Assumptions applied when simplifying or comparing.

$m.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$m.columns

[ math ]. The matrix's entries grouped by column.

$m.createIntervals

boolean. Whether range expressions are interpreted as intervals.

$m.createVectors

boolean. Whether tuple-like expressions are interpreted as vectors.

$m.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$m.displayBlanks

boolean. Whether blanks (placeholders) are visibly rendered.

$m.draggable

boolean. Whether the math component can be dragged on a graph.

$m.expand

boolean. Whether to expand the expression.

$m.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$m.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$m.functionSymbols

textList. Symbols treated as function names when parsing.

$m.hidden

boolean. Whether this component is hidden from the rendered output.

boolean. Whether the expression evaluates to a finite number.

boolean. Whether the expression evaluates to any number (including infinities).

latex. The expression rendered as a LaTeX string.

$m.layer

number. Z-order layer index when shown on a graph.

$m.list

[ math ]. The math expression interpreted as a list (its elements).

[ math ]. The math expression interpreted as a matrix (its entries by row and column).

numberList. The size of the math expression as a matrix, as a [numRows, numColumns] list.

number. The numeric value of the expression (NaN if not a number).

integer. The number of columns when the math expression is interpreted as a matrix.

integer. The number of dimensions if the math expression is interpreted as a vector or matrix.

$m.numListItems

integer. The number of items when the math expression is interpreted as a list.

integer. The number of rows when the math expression is interpreted as a matrix.

$m.parseScientificNotation

boolean. Whether to parse expressions like 1e3 as scientific notation.

$m.renderMode

text. How the math is rendered (e.g. "inline", "display").

$m.rows

[ math ]. The matrix's entries grouped by row.

$m.splitSymbols

boolean. Whether multi-character symbols are split into a product of variables.

$m.text

text. The expression rendered as a plain text string.

$m.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$m.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

boolean. Whether list-like values are treated as unordered.

$m.value

math. The math expression value.

[ math ]. The math expression interpreted as a vector (its components).

$m.x

math. The first component of the math expression when interpreted as a vector.

$m.y

math. The second component of the math expression when interpreted as a vector.

$m.z

math. The third component of the math expression when interpreted as a vector.

Common to all components (4)
$m.doenetML

text. The DoenetML source code that produced this component.

$m.hide

boolean. Whether to hide this component from the rendered output.

$m.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$m.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples Page 1

Example: Named <math> for computations

The <math> component can be used to name and store symbolic math expressions for computations.


Example: How spaces are interpreted in a <math>

Spaces between terms in a <math> component are interpreted as multiplication.


Example: Some common <math> functions and their syntax

Many mathematical functions such as sin(x)\sin(x) and log(x)\log(x) are interpreted by Doenet when nested within a <math> component. In this example, several built-in <math> functions that Doenet will simplify are illustrated with their syntax. Note that the default base when using log(x)\log(x) is ee. For a complete updated listing of supported functions, see the DoenetML Manual.

Attribute Examples

Attribute Example: format

The format attribute specifies how the enclosed math expression is entered, and accepts inputs of either latex or text. The default value for this attribute is text, which corresponds to the syntax that you would naturally type in a typical online calculator. This is illustrated in Part 1 of the example.

If the format is set to latex, the input text can be written in LaTeX and Doenet will interpret and translate this into functional mathematical code. Therefore, as shown in Part 2, it is possible to input the desired expression in latex format and then evaluate it with the simplify attribute.


Attribute Example: simplify = “full” (or just simplify)

The first <math> component defines an unsimplified expression, while the second <math> component references the first expression by name, adds two additional terms, and simplifies the resulting expression.

The simplify attribute has five options:

  1. simplify="none": no simplification.
  2. simplify="full" (or simply simplify by itself): apply all available simplification routines.
    Does not include expanding factored expressions.
  3. simplify="numbers": simplify numerical expressions like 1+2 but not algebraic expressions.
    Permute terms and factors into a canonical order.
  4. simplify="numbersPreserveOrder": simplify numbers but without permuting terms or factors.
  5. simplify="normalizeOrder": permute terms and factors to a standard order but perform no other simplifications.

To include expansion of factored expressions, you can add the expand attribute.

If the simplify attribute is not specified within the <math> component, no simplification occurs (i.e. this is equivalent to specifying simplify="none").


Attribute Example: simplify = “numbers”

When only numerical terms are to be combined, use the simplify="numbers" specification inside the <math> component. Some rearrangement of terms may occur during simplification.


Attribute Example: simplify = “numbersPreserveOrder”

When only numerical terms are to be combined and terms must remain in their original ordering, use the simplify="numbersPreserveOrder" specification inside the <math> component.


Attribute Example: simplify = “normalizeOrder”

To make all terms and factors appear in a standardized order without any further simplifications, use the simplify="normalizeOrder" specification inside the <math> component.


Attribute Example: expand

By default, a <math> will not expand factored expressions.
Specifying the expand attribute will expand the result.


Attribute Example: unordered

The unordered attribute determines how the whether or not comparisons with the <math> require the same order of its subparts. The first <math> is defined without the unordered attribute, so it defaults to unordered="false". The second <math> has unordered="true" specified, so it will match expressions independent of the ordering. The unordered affects both lists, suchs 1,2,31,2,3 or tuples such as (1,2,3)(1,2,3).

An alternative way to specify that ordering doesn’t matter is with the unorderedCompare attribute of <answer>, <award>, <when>, or <boolean>.