<differences>
<differences> is a Math Operator
component that renders the differences between successive arguments: for inputs
it gives .
The result is one shorter than the input, and is empty when the input has fewer than
two values. <differences> undoes
<cumulativeSum>, apart from the first value, which the
running total has already absorbed.
Attributes and Properties
Attributes for <differences>
Highlighted (3)
asListboolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).
forceNumericboolean. Default value: false. Whether to force the operator to evaluate numerically rather than symbolically.
forceSymbolicboolean. Default value: false. Whether to force the operator to evaluate symbolically rather than numerically.
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.
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 <differences name="d">
Highlighted (2)
$d.forceNumericboolean. Whether to force the operator to evaluate numerically rather than symbolically.
$d.forceSymbolicboolean. Whether to force the operator to evaluate symbolically rather than numerically.
Number display (5)
$d.avoidScientificNotationIn developmentboolean. Whether to render numbers in full decimal form rather than scientific notation.
$d.displayDecimalsIn developmentinteger. Number of decimal places to display when rendering this number.
$d.displayDigitsIn developmentinteger. Number of significant digits to display when rendering this number.
$d.displaySmallAsZeroIn developmentnumber. Threshold below which numbers are displayed as zero.
$d.padZerosIn developmentboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Common to all components (8)
$d.disabledIn developmentboolean. Whether this component is disabled and cannot be interacted with.
$d.doenetMLtext. The DoenetML source code that produced this component.
$d.fixedIn developmentboolean. Whether this component's value is fixed and cannot be modified.
$d.fixLocationIn developmentboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$d.hideboolean. Whether to hide this component from the rendered output.
$d.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$d.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: successive differences
Four inputs give three differences.
Example: first differences of a sequence
The first differences of the squares are the odd numbers, and their differences are constant β the signature of a quadratic.
Example: inverting a cumulative sum
Taking differences recovers the original values, except for the first one, which the cumulative sum folded into its starting entry.