Referencefunction (Attributes 1)

<function>

Attribute Examples Part 1

The following examples illustrate use of the <function> tag attributes.

Attributes

Attributes for <function>
AttributeTypeValues
applyStyleToLabel = "…"boolean"true" "false"
displayDecimals = "…"integer
displayDigits = "…"integer
displaySmallAsZero = "…"number
domain = "…"[ interval ]
expand = "…"text"true" "false"
extrema = "…"[ number ]
labelIsName = "…"boolean"true" "false"
labelPosition = "…"text"upperright" "upperleft" "lowerright" "lowerleft" "top" "bottom" "left" "right"
layer = "…"number
maxima = "…"[ number ]
minima = "…"[ number ]
nearestPointAsCurve = "…""true" "false"
numInputs = "…"integer
numOutputs = "…"integer
padZeros = "…"boolean"true" "false"
simplify = "…"text"none" "full" "numbers" "numberspreserveorder"
symbolic = "…"boolean"true" "false"
through = "…"
throughSlopes = "…"
variable = "…"_variableName
variables = "…"[ _variableName ]
xscale = "…"number
yscale = "…"number

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 macro $$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 atttribute has four 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.

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.