assume
Adds a real numeric interval assumption for a symbol so assumption-aware operations can use the known range.
Assumptions narrow a plain variable to a non-empty interval of real numeric values. Repeated constraints for the same variable are intersected, and contradictory constraints are rejected without replacing the previous assumption.
Assumptions are used conservatively. They can influence comparisons and transformations that depend on sign or ordering, but they are not a general logical theorem system.
Exact rational bounds and supported real algebraic endpoints such as sqrt(2) are preserved without decimal rounding. In Nerdamer Notation, assume(x>sqrt(2)) registers an exact irrational lower bound; unsupported expressions are rejected.
Parser notation also supports relations between two variables with exact rational differences, such as assume(x<y+1) and assume(2*x+3<2*y+5). Such relations can derive bounds from current assumptions on another variable; getAssumptionFor returns only explicitly registered numeric intervals.
Assumption-aware comparisons can prove signs for compatible linear combinations, positive products, selected integer and reciprocal powers, and square roots over nonnegative intervals. When the constraints do not prove a conclusion, Nerdamer does not infer it. An even power may be nonnegative without being strictly positive.
Assumption relations can distinguish true, false, and undefined (unknown); public Expression comparison methods still return booleans for compatibility. Forgotten variables remove dependent relationships, and contradictory constraints are rejected without discarding valid earlier assumptions.
Examples
These examples use Nerdamer Notation.
Use disjoint symbolic ranges to prove which variable is larger.
assume(x>0); assume(y<0); max(x,y)
// → xUse a lower bound to remove an otherwise necessary absolute value.
assume(x>=3); sqrt((x-3)^2)
// → -3+xUse positivity information in a sign-sensitive logarithm simplification.
assume(x>0); assume(y>0); simplify(log(x)+log(y))
// → log(x*y)Use an exact algebraic endpoint to establish a comparison without rounding.
assume(x>sqrt(2)); x>1
// → truePropagate a strict upper bound through a relationship between variables.
assume(x<y+1); assume(y<=3); x<4
// → trueUse independent intervals to establish the strict sign of a linear combination.
assume(a>5); assume(b<3); a-b-2>0
// → trueEstablish a strict square-root bound when the entire assumed interval is positive.
assume(x>4); sqrt(x)-2>0
// → trueInterfaces
The same operation is available through the interfaces below.
Nerdamer Notation
Use this form inside input passed to nerdamer(...).
assume(arg1)
nerdamer.assume
Call the operation through the default nerdamer import.
nerdamer.assume(expr: string): Assumption
nerdamer.assume(symbol: string, exprOrAssumption: string | Assumption): 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.
Direct JavaScript / TypeScript API
Import the operation directly from its package entry point.
import { assume } from 'nerdamer/assumptions';
assume(expr: string): Assumption
assume(symbol: string, exprOrAssumption: string | Assumption): 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.
Notes
- The direct string API accepts a variable, a comparison operator, and a numeric bound. Parser notation can evaluate arithmetic such as 1/3 before storing the bound.
- Assumption state is process-wide until it is cleared or forgotten.
- Direct string assumptions handle exact rational arithmetic; parser notation additionally accepts supported exact real algebraic endpoints and two-variable relationships.
- Relationships may propagate through multiple variables, but unsupported nonlinear relations such as assume(x<y^2) are rejected.
- Reciprocal bounds require intervals separated from zero, and square-root bounds require a nonnegative domain. Unknown results are not proofs.
- Use forgetAssumptionFor(variable) to remove that variable's dependent relationships, or clearAssumptions() to clear process-wide state.
