<piecewiseFunction>
<piecewiseFunction>
is a Graphical
component that renders a piecewise defined function that can be evaluated and graphed in the same manner
as a <function>
component.
In order to evaluate a piecewiseFunction, the function attribute symbolic
must be
set to false
, to force numerical evaluation.
Disclaimer: currently, piecewise functions cannot be used with the <derivative>
component.
Individual <function>
children need to be differentiated independently. Open and closed
endpoints must also be graphed as independent components (see <endpoint>
.)
Attributes and Properties
Attribute | Type | Values |
---|---|---|
applyStyleToLabel = "…" | boolean | "true" "false" |
displayDecimals = "…" | integer | |
displayDigits = "…" | integer | |
displaySmallAsZero = "…" | number | |
domain = "…" | ||
expand = "…" | text | "true" "false" |
labelIsName = "…" | boolean | "true" "false" |
labelPosition = "…" | text | "upperright" "upperleft" "lowerright" "lowerleft" "top" "bottom" "left" "right" |
layer = "…" | number | |
nearestPointAsCurve = "…" | "true" "false" | |
padZeros = "…" | boolean | "true" "false" |
simplify = "…" | text | "none" "full" "numbers" "numberspreserveorder" |
symbolic = "…" | boolean | "true" "false" |
throughSlopes = "…" | ||
variable = "…" | _variableName | |
variables = "…" | [ _variableName ] | |
xscale = "…" | number | |
yscale = "…" | number |
Property | Type |
---|---|
$p.applyStyleToLabel | boolean |
$p.backgroundColor | text |
$p.disabled | boolean |
$p.displayDecimals | integer |
$p.displayDigits | integer |
$p.displaySmallAsZero | number |
$p.expand | text |
$p.expandSpecified | boolean |
$p.extrema | [ number ] |
$p.fixed | boolean |
$p.fixLocation | boolean |
$p.formula | math |
$p.globalInfimum | [ number ] |
$p.globalMaximum | [ number ] |
$p.globalMinimum | [ number ] |
$p.globalSupremum | [ number ] |
$p.hidden | boolean |
$p.label | label |
$p.labelIsName | boolean |
$p.labelPosition | text |
$p.latex | latex |
$p.layer | number |
$p.maxima | [ number ] |
$p.minima | [ number ] |
$p.numExtrema | number |
$p.numInputs | integer |
$p.numMaxima | number |
$p.numMinima | number |
$p.numOutputs | integer |
$p.padZeros | boolean |
$p.simplify | text |
$p.styleDescription | text |
$p.styleDescriptionWithNoun | text |
$p.symbolic | boolean |
$p.text | text |
$p.textColor | text |
$p.textStyleDescription | text |
$p.variable | _variableName |
$p.variables | [ _variableName ] |
$p.xscale | number |
$p.yscale | number |
Example: A simple three-part <piecewiseFunction>
The <piecewiseFunction>
component is defined by assigning <function>
children
for each distinct region of the function’s domain. The named <piecewiseFunction>
can
then be evaluated in the same manner as the <function>
component using
the $$functionName(input)
evaluation macro.
Note: When using a <piecewiseFunction>
for evaluation, it is necessary to include
the function attribute symbolic="false"
to force numerical evaluation.
Example: Adding endpoints graphically to a <piecewiseFunction>
Doenet only evaluates functions at points strictly in their specified domains. Therefore, in order to locate endpoints of open intervals for graphing, it may be necessary to define a set of base functions with unrestricted domains. In the example shown, the child functions themselves (and therefore the endpoint evaluations) are trivial, but the same method will work for more complex functions as well.
These predefined functions can then be copied into the definition of the <piecewiseFunction>
using the extend
attribute, and the precise domains can be specified for each. This allows for
the single <piecewiseFunction>
to then be used for
- graphing the linear component of the function,
- for correctly rendering the equation of the piecewise function outside the graph, and
- for correct mathematical evaluation at all points in the domain.
Note: When using a <piecewiseFunction>
for evaluation, it is necessary to include the
function attribute symbolic="false"
to force numerical evaluation.
Example: How domains are interpreted
Domains may be specified for the parent <piecewiseFunction>
, and also for all individual child functions. When two domains overlap, the previously defined <function>
governs. Finally, when no domain is specified for a given function, that function assumes the domain not occupied by all of the other defined functions.
Note: When using a <piecewiseFunction>
for evaluation, it is necessary to include the function attribute symbolic="false"
to force numerical evaluation.
Attribute Example: domain
The domain
attribute can be used to specify an overarching domain
for the <piecewiseFunction>
.
Attribute Example: variable/ variables
The variables
attribute changes the overarching variable used for
the <piecewiseFunction>
, but individual <function>
variables may differ.
At this time (update forthcoming), the child functions will still look for a default
independent variable of .
Property Example: minima/ maxima
Local maxima and minima of the <piecewiseFunction>
are rendered with the maxima/minima
properties.