Referencefunction (Attributes 1)

<function>

The following examples illustrate use of the <function> tag attributes (Part 1).

Attributes

Attributes for <function>

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.

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.

ValueDescription
upperRight (default)Place the label above and to the right of the function curve.
upperLeftPlace the label above and to the left of the function curve.
lowerRightPlace the label below and to the right of the function curve.
lowerLeftPlace the label below and to the left of the function curve.
topPlace the label directly above the function curve.
bottomPlace the label directly below the function curve.
leftPlace the label directly to the left of the function curve.
rightPlace 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.

nearestPointAsCurve

boolean. 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.

numOutputs

integer. Default value: 1. Number of output values the function produces.

keyword. Level of simplification applied to the function's formula.

ValueDescription
noneNo simplification is applied.
full (default)Fully simplify the function's formula.
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.

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)
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.

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 xx. 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 x,y,zx,y,z or, x1,x2,,x_1, x_2, \ldots, 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 simply simplify by itself): apply currently available simplification routines.
    Does not include expanding factored expressions.
  • simplify="numbers": simplify numerical expressions like 1+2 but 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 101410^{-14}, 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 xx- or yy-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.