<clampFunction>
<clampFunction> is a Math Operator
that wraps a <function> and limits its output to a closed
interval . Any output below
lowerValue is replaced by lowerValue; any output above upperValue is
replaced by upperValue. The default interval is .
The result is itself a function, so it can be evaluated, graphed, and used
anywhere an ordinary <function> is accepted. Compare with
<clampNumber>, which clamps a single number rather than
a function, and with <wrapFunctionPeriodic>,
which wraps a function’s output instead of clamping it.
Attributes and Properties
Attributes for <clampFunction>
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (1)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (21)
applyStyleToLabelboolean. Default value: false. Whether to apply the function's style to its label.
domain[ intervalList ]. Restriction of the function's domain to a list of intervals.
expandboolean. Default value: false. Whether to expand the function's formula.
extrema[ extrema ]. Local extrema (combined minima and maxima) of an interpolated function.
labelPositionkeyword. 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. |
layernumber. Default value: 0. Z-order layer index for stacking the function on a graph.
number. Default value: 0. Lower bound for the operator's range.
maxima[ extrema ]. Local maxima of an interpolated function.
minima[ 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).
numInputsinteger. Number of input arguments the function accepts.
numOutputsinteger. Default value: 1. Number of output values the function produces.
simplifykeyword. 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. |
symbolicboolean. Default value: true. Whether the function should be evaluated symbolically rather than numerically.
throughpointList. Points the interpolated function should pass through.
throughSlopesmathList. Slopes the interpolated function should have at each through-point.
number. Default value: 1. Upper bound for the operator's range.
variable_variableName. Name of the function's single input variable.
variables[ _variableNameList ]. Names of the function's input variables.
xscalenumber. Default value: 1. Scale factor used along the x-axis.
yscalenumber. 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.
Properties for <clampFunction name="c">
Number display (5)
$c.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$c.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$c.displayDigitsinteger. Number of significant digits to display when rendering this number.
$c.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$c.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$c.labellabel. The label rendered with this component.
$c.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (44)
$c.applyStyleToLabelboolean. Whether to apply the function's style to its label.
$c.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$c.disabledboolean. Whether this component is disabled and cannot be interacted with.
$c.domain[ interval ]. Domain interval(s) of the function.
$c.expandtext. Whether to expand the formula.
$c.expandSpecifiedboolean. Whether to expand the function's formula.
$c.extrema[ number ]. Local extrema (minima + maxima) of the function.
$c.extremumLocations[ number ]. The x-coordinates of the function's local extrema.
$c.extremumValues[ number ]. The values of the function's local extrema.
$c.fixedboolean. Whether this component's value is fixed and cannot be modified.
$c.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$c.formulamath. The symbolic formula of the function produced by this operator.
$c.globalInfimum[ number ]. The global infimum of the function.
$c.globalMaximum[ number ]. The global maximum of the function (if attained).
$c.globalMinimum[ number ]. The global minimum of the function (if attained).
$c.globalSupremum[ number ]. The global supremum of the function.
$c.labelPositiontext. Position of the function's label.
$c.latexlatex. The function rendered as a LaTeX string.
$c.layernumber. Z-order layer index for stacking the function on a graph.
$c.lowerValuenumber. Lower bound for the operator's range.
$c.maxima[ number ]. Local maxima of the function.
$c.maximumLocations[ number ]. The x-coordinates of the function's local maxima.
$c.maximumValues[ number ]. The values of the function's local maxima.
$c.minima[ number ]. Local minima of the function.
$c.minimumLocations[ number ]. The x-coordinates of the function's local minima.
$c.minimumValues[ number ]. The values of the function's local minima.
$c.numExtremanumber. Number of local extrema (minima + maxima) of the function.
$c.numInputsinteger. Number of input variables of the function.
$c.numMaximanumber. Number of local maxima of the function.
$c.numMinimanumber. Number of local minima of the function.
$c.numOutputsinteger. Number of output values of the function.
$c.simplifytext. Level of simplification applied when displaying the formula.
$c.styleDescriptiontext. A textual description of the function's style.
$c.styleDescriptionWithNountext. Style description including the word "function".
$c.symbolicboolean. Whether the function is treated symbolically.
$c.texttext. The function rendered as a plain text string.
$c.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$c.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$c.upperValuenumber. Upper bound for the operator's range.
$c.variable_variableName. The function's first input variable name.
$c.variables[ _variableName ]. The names of the function's input variables.
$c.xscalenumber. Scale factor used along the x-axis.
$c.yscalenumber. Scale factor used along the y-axis.
Common to all components (4)
$c.doenetMLtext. The DoenetML source code that produced this component.
$c.hideboolean. Whether to hide this component from the rendered output.
$c.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$c.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Clamp a function to
The underlying function f(x) = x/4 is plotted alongside its clamp. Outside
the input range the clamped function flatlines at or .
Example: Use as part of a graph
Setting lowerValue and upperValue clamps sin(x) to a band of width ,
flattening the peaks and troughs. The original function is plotted underneath
for comparison.
Example: Evaluate a clamped function at specific inputs
The named clamp is evaluated like any other function with $$name(input).
Outputs inside pass through unchanged; outputs outside it are
replaced by the nearest endpoint.
Attribute Examples
Attribute Example: lowerValue, upperValue
lowerValue and upperValue set the output interval. The clamped function
is constant outside the input range where the underlying function is below
lowerValue or above upperValue.