This entry is documented with its primary interface. Open the documentation →
nerdamer.assume
nerdamer.assume(expr: string): Assumptionnerdamer.assume(symbol: string, exprOrAssumption: string | Assumption): AssumptionRegisters a numeric interval assumption in Nerdamer's global assumption state.
A one-argument call parses a complete constraint such as x >= 0. The two-argument
form associates a plain variable with either another complete constraint for that
same variable or an existing Assumption instance. Built-in constants and the
configured imaginary-unit symbol cannot receive real interval assumptions.
Repeated assumptions for the same variable are intersected. If the intersection is
empty, the new constraint is rejected and the previously registered assumption is
left unchanged.
Assumption state is process-wide. It is consulted by expression comparisons and by
algorithms that rely on those comparisons, including positivity-sensitive
simplifications. Call clearAssumptions when that state should no longer
affect later work. Scoped assumption contexts are not simulated in 2.0 because a
correct scoped design must be threaded through the parser and algorithms rather
than wrapping only this registry.
Error Thrown when the constraint is malformed or its bound is not numeric.
UnexpectedInputError Thrown when a new constraint contradicts the existing assumption.
Parameters
| Name | Type | Description |
|---|---|---|
expr | string | Complete constraint in the supported assumption grammar. |
Returns
Assumption — The registered interval after intersection with any existing constraint.
Examples
assume('x >= 0');
assume('x < 10');
getAssumptionFor('x')?.toString(); // "[0, 10)"
clearAssumptions();