<function>
The following examples illustrate use of the <function> tag attributes (Part 1).
Attributes
Attributes for <function>
Number display (5)
avoidScientificNotationboolean. 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.
Labels (1)
boolean. Default value: false. Whether to use this component's name as its rendered label.
Other (19)
boolean. Default value: false. Whether to apply the function's style to its label.
[ intervalList ]. Restriction of the function's domain to a list of intervals.
boolean. Default value: false. Whether to expand the function's formula.
[ extrema ]. Local extrema (combined minima and maxima) of an interpolated function.
keyword. Position of the function's label.
| Value | Description |
|---|---|
upperRight (default) | Place the label above and to the right of the function curve. |
upperLeft | Place the label above and to the left of the function curve. |
lowerRight | Place the label below and to the right of the function curve. |
lowerLeft | Place the label below and to the left of the function curve. |
top | Place the label directly above the function curve. |
bottom | Place the label directly below the function curve. |
left | Place the label directly to the left of the function curve. |
right | Place the label directly to the right of the function curve. |
number. Default value: 0. Z-order layer index for stacking the function on a graph.
[ extrema ]. Local maxima of an interpolated function.
[ extrema ]. Local minima of an interpolated function.
nearestPointAsCurveboolean. Default value: false. Whether nearest-point queries should treat the function as a curve in the plane rather than a graph y = f(x).
integer. Number of input arguments the function accepts.
numOutputsinteger. Default value: 1. Number of output values the function produces.
keyword. Level of simplification applied to the function's formula.
| Value | Description |
|---|---|
none | No simplification is applied. |
full (default) | Fully simplify the function's formula. |
numbers | Simplify numeric subexpressions only, leaving symbolic structure intact. |
numbersPreserveOrder | Like numbers, but does not reorder commutative operands. |
normalizeOrder | Reorder commutative operands into a canonical form without simplifying values. |
boolean. Default value: true. Whether the function should be evaluated symbolically rather than numerically.
pointList. Points the interpolated function should pass through.
mathList. Slopes the interpolated function should have at each through-point.
_variableName. Name of the function's single input variable.
[ _variableNameList ]. Names of the function's input variables.
number. Default value: 1. Scale factor used along the x-axis.
number. Default value: 1. Scale factor used along the y-axis.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Attribute Examples
Attribute Example: domain
The domain attribute accepts a list of intervals for the domain, with one
interval per variable. At present, DoenetML supports only rectangular domains
specified by the product of these intervals.
For symbolic functions (the default), evaluating at a symbolic point ignores the domain.
Attribute Example: variable/variables
By default, a <function> will be based on the single variable .
Use the variable or variables attribute to create a function based a different variable or multiple variables.
Attribute Example: numInputs
The numInputs will override the number of inputs that would be otherwise be
determined by the variable or variables attribute.
If fewer variables than numInputs are specified, they will be chosen from either
or, depending if numInputs is larger than 4.
Attribute Example: symbolic
A function, by default, is evaluated symbolically. If the symbolic attribute is specified
as false, then the function will be evaluated numerically. Numeric evaluation is more efficient,
but it can only return a number.
If one evaluates using the full syntax of an <evaluate> component (as opposed to
the shortcut evaluation reference $$f(x,y)), then one can use the attributes forceNumeric or forceSymbolic
to force numerical or symbolic evaluation independent of the symbolic attribute.
Attribute Example: simplify
By default, a function will simplify the result of its evaluation.
To reduce or eliminate the simplification, one can specify a different value for simplify.
The simplify attribute has five options:
simplify="none": no simplification.simplify="full"(or simplysimplifyby itself): apply currently available simplification routines.
Does not include expanding factored expressions.simplify="numbers": simplify numerical expressions like1+2but not algebraic expressions.
Permute terms and factors into a canonical order.simplify="numbersPreserveOrder": simplify numbers but without permuting terms or factors.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.
The simplify attribute does not affect the formula itself, only the result after evaluation.
Attribute Example: expand
By default, a function will not expand factored expressions in the result of its evaluation.
Specifying the expand attribute will expand the result.
The expand attribute does not affect the formula itself, only the result after evaluation.
Attribute Example: displayDigits/displayDecimals
By default, numbers in the result of a function evaluation 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.
Attribute Example: displaySmallAsZero
The default value of the displaySmallAsZero attribute is , which means that,
when evaluating a function, 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”.
Attribute Example: padZeros
If the padZeros is set, then numbers will be displayed padded with zeros
so that all the digits from the combination of displayDigits and displayDecimals will be shown.
Attribute Example: minima
One way to specify required features of an interpolated function is set the minima to a list of points that
should be minima of the function.
The minima points can have an empty - or -coordinate, in which case the missing
values will be determined algorithmically.
The attributes xscale and yscale will be used to determine aspects of the minima that
aren’t specified as well as the shape of the function.
If additional features (maxima, extrema, through) of the function are specified,
the function may have additional minima that were not given by the minima attribute.