Catalan
The n-th Catalan number catalan(n) = binom(2n, n)/(n+1).
Value parameters
- e
-
the index
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.
Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.
Attributes
- Definition Classes
Reduces this expression in the given environment.
Reduces this expression in the given environment.
Value parameters
- env
-
variable bindings and display precision
Attributes
- Returns
-
Right(v)when all free variables resolved to concrete values;Left(e)when reduction is partial or impossible - Definition Classes
The token this function prints and parses as — "exp", "tan", "Gamma".
The token this function prints and parses as — "exp", "tan", "Gamma".
Stated per node rather than derived, and that is deliberate. A case class knows its own name through productPrefix, so this could have defaulted to it — but Exp prints exp while Gamma prints Gamma (capitalised by 4.K so the lower-case name stays free as a variable), and Tg prints tan. Neither productPrefix nor its lower-cased form is right for all three, and a default that is right for most nodes and silently wrong for a few is the confidently-wrong failure this codebase declines everywhere — here it would mean a session saving under one spelling and reloading under another.
Attributes
- Definition Classes
Reconstructs the same node shape with replacement sub-expressions.
Reconstructs the same node shape with replacement sub-expressions.
Value parameters
- newChildren
-
replacements in the same order and count as
children
Attributes
- Definition Classes
Inherited methods
The exact value of this function at a closed expression holding a named constant (F_0289): sin(pi/6) is 1/2, and tan(pi/2) is Left, undefined rather than a huge reading. Empty by default, so the argument is read at the working precision. A hook, like surdKernel, so the published signature of evalUnary is unchanged.
The exact value of this function at a closed expression holding a named constant (F_0289): sin(pi/6) is 1/2, and tan(pi/2) is Left, undefined rather than a huge reading. Empty by default, so the argument is read at the working precision. A hook, like surdKernel, so the published signature of evalUnary is unchanged.
Value parameters
- arg
-
the argument, closed and holding a constant
Attributes
- Returns
-
the exact answer, or
Noneto read the argument at the working precision - Inherited from:
- _Function
The one evaluation of a two-argument function with a real kernel and no matrix or complex extension (F_0149): an exact argument goes through viaDouble, two reals through kernel.
The one evaluation of a two-argument function with a real kernel and no matrix or complex extension (F_0149): an exact argument goes through viaDouble, two reals through kernel.
Value parameters
- a
-
the first argument
- b
-
the second
- env
-
the evaluation environment
- kernel
-
the value at a real pair,
Nonewhere it is undefined
Attributes
- Returns
-
the value, or the node unevaluated
- Inherited from:
- _Function
The one evaluation of a single-argument function (F_0149): every one-argument node is this call with its kernels.
The one evaluation of a single-argument function (F_0149): every one-argument node is this call with its kernels.
The arm order is the substance, and why it lives here rather than in 35 copies: an exact argument first (the node's own exact arm, else viaExact) — before the real arm, because _Number is a widening extractor and would read a _Rational as a Double (the ordering trap CLAUDE.md names); then a real, a dense matrix element-wise through the same real kernel, a complex argument, a symbolic matrix cell by cell, an interval through intervalImage; anything else stays as written. A node without a complex extension leaves complex at its default and stays unevaluated on one, the Asin convention.
Value parameters
- arg
-
the argument
- complex
-
the value at a complex point,
Nonewhere it is not computed - env
-
the evaluation environment
- exact
-
the node's own exact arm, consulted before viaExact
- real
-
the value at a real point,
Nonewhere it is undefined there
Attributes
- Returns
-
the value, or the node unevaluated
- Inherited from:
- _Function
The exact non-negative integer an argument denotes, if it denotes one.
The exact non-negative integer an argument denotes, if it denotes one.
The gate on every exact path in the factorial family: those functions are only closed over the rationals at non-negative integers, and everywhere else (Gamma(0.5), fact(-1)) the analytic kernels remain the right answer.
Value parameters
- r
-
the exact argument
Attributes
- Returns
-
Some(n)whenris a non-negative integer,Noneotherwise - Inherited from:
- _Function
This function as an arbitrary-precision kernel, when it has one.
This function as an arbitrary-precision kernel, when it has one.
Returning None means "not defined here", and covers both cases: a function with no Real counterpart at all, and an argument outside the real domain — ln of a negative, asin beyond ±1. The domain is checked explicitly per function rather than by computing in Double first and seeing whether it came back finite, because that oracle gets exp(1000) exactly wrong: Double overflows to an infinity there while the true value is a perfectly finite 435-digit number, which is the acceptance case.
Out-of-domain arguments fall through to viaDouble, which owns the complex fallback.
Attributes
- Inherited from:
- _Function
The image of an interval argument (F_0008), for the functions core._Interval.function has a rule for; any other function, or an interval outside the domain, stays as written.
The image of an interval argument (F_0008), for the functions core._Interval.function has a rule for; any other function, or an interval outside the domain, stays as written.
Value parameters
- env
-
supplies the working precision for an exact interval
- i
-
the interval argument
Attributes
- Returns
-
the image interval, or
Leftof this node overi - Inherited from:
- _Function
Applies a real scalar function element-wise over a dense matrix argument.
Applies a real scalar function element-wise over a dense matrix argument.
An out-of-domain element (e.g. ln of a negative entry yields NaN) leaves the whole node symbolic: the dense _MatrixValue carrier cannot hold the complex fallback value that a per-element scalar result would produce.
Value parameters
- f
-
the scalar function to apply to each element
- mv
-
the dense matrix to map over
Attributes
- Returns
-
Right(_MatrixValue)when all elements are finite,Left(this)otherwise - Inherited from:
- _Function
Applies this single-argument function element-wise over a symbolic matrix argument.
Applies this single-argument function element-wise over a symbolic matrix argument.
Rebuilds the matrix with this function wrapped around each cell and re-evaluates. Unlike mapMatrix, each cell degrades independently -- an out-of-domain cell becomes its own complex or symbolic result rather than dropping the whole matrix.
Value parameters
- env
-
the evaluation environment
- m
-
the symbolic matrix (
_MatrixShaped) whose cells are not yet concrete
Attributes
- Returns
-
the element-wise result, with numeric cells folded and symbolic cells kept
- Inherited from:
- _Function
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product
The value of this function at an exact surd, for a node closed over the surds (F_0231): abs is, since a surd's sign is decided exactly. Empty by default, so every other node reads the surd as its working-precision rational. A hook rather than a parameter of evalUnary: that method is part of a published non-sealed class, and a new parameter would remove its old signature, a binary break; a new concrete member is additive.
The value of this function at an exact surd, for a node closed over the surds (F_0231): abs is, since a surd's sign is decided exactly. Empty by default, so every other node reads the surd as its working-precision rational. A hook rather than a parameter of evalUnary: that method is part of a published non-sealed class, and a new parameter would remove its old signature, a binary break; a new concrete member is additive.
Attributes
- Returns
-
the node's surd arm
- Inherited from:
- _Function
Renders as name(arg, arg, …) — the grammar's own call syntax, so it re-parses.
Renders as name(arg, arg, …) — the grammar's own call syntax, so it re-parses.
One definition replacing 41 identical hand-written overrides.
_Functional is a separate hierarchy and deliberately does not mix this in. Its nine nodes — _Derivative, the integrals, _Limit and the transforms — print a binder that children excludes on purpose, so rendering from children alone would emit derive(e) for what is derive(e, v) and silently lose the variable. They keep their own toString, and would gain nothing from a name either: their LaTeX is \int, \frac{d}{dx} and \lim, bespoke however the token is spelled.
Attributes
- Definition Classes
-
NamedFunction -> Any
- Inherited from:
- NamedFunction
Evaluates this function on exact arguments by way of the Double kernel, lifting the result back into the exact tier.
Evaluates this function on exact arguments by way of the Double kernel, lifting the result back into the exact tier.
No transcendental function is closed over the rationals — exp(1) and sin(1/3) are irrational — so the exact tier's contract for them is "compute, then re-approximate to the working precision", and this is that step.
Implemented by rebuilding the node with _Number arguments and re-evaluating, rather than by taking a Double => Double kernel: that reuses each node's own logic, including its domain handling and its complex fallback, instead of duplicating a function reference at fourteen call sites and getting one of them wrong. The rebuilt node hits its _Number case, so there is no recursion.
A complex or symbolic result passes through untouched — a complex value is inexact, so float contagion is already the right answer for it.
This is now the fallback: viaExact is what the transcendentals reach first, and it comes back here for an out-of-domain argument or a low working precision.
Value parameters
- args
-
the same children, with every exact argument replaced by its
Double - env
-
supplies the working precision
Attributes
- Returns
-
the result lifted back to a
_Rational, or whatever non-real result came out - Inherited from:
- _Function
Evaluates this function on an exact argument, at the working precision.
Evaluates this function on an exact argument, at the working precision.
Uses the Double kernel when the working precision is inside Double's reliable range: there is nothing to gain there and roughly 110× to lose, since a Real transcendental costs about 0.6 ms against 0.006 ms. The two agree to within the precision either claims, so which one ran is not observable — only how long it took.
Value parameters
- env
-
supplies the working precision
- r
-
the exact argument
Attributes
- Returns
-
the result at the working precision, or the
Doublepath's answer - Inherited from:
- _Function
Inherited fields
Cached set of free variable names; O(1) after the first access.
Cached set of free variable names; O(1) after the first access.
Attributes
- Inherited from:
- _Expression