Referencefunction (Basic Use)

<function>

<function> is a Math component that defines a mathematical function that can be used for numerical or symbolic evaluation, answer validation, graphing, and other computations within Doenet. There are two main ways to create a function:

  1. Creating a function using a formula
  2. Creating an interpolated function through given points or with specified extrema

Basic Use Examples

The following examples illustrate some of the basic uses of the <function> component.
See the following pages for more complex examples, attributes and properties.


Example: Single variable function defined by a formula

A single variable function can be defined by giving a formula in the variable xx as the child of <function>.
The variable can be changed with the variable attribute.

The function can be evaluated using a macro of the form $$f(x) or rendered on a <graph> using the reference $f.


Example: Vector-valued function of multiple variables

A vector-valued function can be created by giving a vector for the formula.
The variables attribute can specify multiple variables.

The macro notation $$f(x,y) can be used with multiple variables.


Example: Interpolated functions 1

To create an interpolated function, use the attributes maxima, minima, extrema, through and/or throughSlopes. The scales used in the interpolation algorithm are specified by the attributes xscale and yscale.


Example: Interpolated functions 2

In addition to specifying extrema of functions, one can also access the actual extrema of a function with the properties: minima, minimumLocations, minimumValues, maxima, maximumLocations, maximumValues, extrema, extremaLocations, extremaValues.

These properties apply to both interpolated functions and scalar-valued functions of a single variable determined by a formula.