ReferencesolveEquations

<solveEquations>

Numerically solves a system of equations

<solveEquations> numerically finds solutions of one or more equations in one variable. It evaluates the difference between the two sides of each equation across numDiscretizationPoints sample points, identifies sign changes, and refines each candidate to a numerical root.

The result is a list of solutions, exposed through the solutions property and numSolutions. Because the solver is numerical, it can find roots that have no closed form, but it has the usual caveats: nearby roots, very flat crossings, and roots outside the search range may be missed.

Attributes and Properties

Attributes for <solveEquations>

Other (4)

number. Upper bound of the variable's search range.

number. Lower bound of the variable's search range.

number. Default value: 100. Number of points used when searching for solutions numerically.

variables

[ _variableNameList ]. Names of the variables to solve for.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <solveEquations name="s">

Other (9)
$s.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$s.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$s.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$s.hidden

boolean. Whether this component is hidden from the rendered output.

$s.numDiscretizationPoints

number. Number of points used when searching for solutions numerically.

$s.numSolutions

integer. The number of numerical solutions found.

$s.solutions

[ math ]. The numerical solutions of the equations.

$s.variable

_variableName. The first variable being solved for.

$s.variables

[ _variableName ]. The variables of the equations.

Common to all components (4)
$s.doenetML

text. The DoenetML source code that produced this component.

$s.hide

boolean. Whether to hide this component from the rendered output.

$s.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$s.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Roots of a polynomial

The equation is parsed from the children. numSolutions counts the solutions found; solutions is the list of root values.


Example: User-entered equation

The equation and the variable are taken from <mathInput>. The variables attribute names the variable to solve for, defaulting to x when omitted.

Attribute Examples

Attribute Example: minVar, maxVar

minVar and maxVar set the search range. Roots outside that interval are not returned. When the attributes are omitted, the solver defaults to [10,10][-10, 10]. (That default is currently a fallback applied inside the solver, not a value advertised on the attribute descriptors, so it does not appear in the attributes table above.)


Attribute Example: numDiscretizationPoints

numDiscretizationPoints controls how densely the search range is sampled when looking for sign changes. For oscillatory equations the default may under-sample; increasing this value catches more roots at the cost of performance.