it.grypho.scala.leonardo.scalar
Members list
Type members
Classlikes
The absolute value abs(e) — on a complex argument, the modulus (issue F_0036).
The absolute value abs(e) — on a complex argument, the modulus (issue F_0036).
On the Sin template with one distinction: abs is closed over the rationals, so the exact arm answers r.abs directly — negating a numerator loses nothing — rather than taking viaExact's approximate-at-working-precision route, which exists for the transcendentals because they are not closed. The complex case reduces to the real magnitude through math.hypot, which does not overflow where re² + im² would.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The arccosine function acos(e).
The arccosine function acos(e).
Out-of-domain real arguments (|x| > 1) stay symbolic. Complex inputs stay symbolic. Accepts _MatrixValue (element-wise).
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The inverse hyperbolic cosine acosh(e). Real only for e ≥ 1; out-of-domain and complex inputs stay symbolic. Accepts _MatrixValue (element-wise).
The inverse hyperbolic cosine acosh(e). Real only for e ≥ 1; out-of-domain and complex inputs stay symbolic. Accepts _MatrixValue (element-wise).
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The arcsine function asin(e).
The arcsine function asin(e).
Out-of-domain real arguments (|x| > 1) stay symbolic. Complex inputs stay symbolic (the "Asin convention" -- no complex extension is applied). Accepts _MatrixValue (element-wise).
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The inverse hyperbolic sine asinh(e). Defined on all reals; complex inputs stay symbolic (the Asin convention). Accepts _MatrixValue (element-wise).
The inverse hyperbolic sine asinh(e). Defined on all reals; complex inputs stay symbolic (the Asin convention). Accepts _MatrixValue (element-wise).
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The arctangent function atan(e).
The arctangent function atan(e).
Defined on all real inputs; accepts _MatrixValue (element-wise). Complex inputs stay symbolic.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The inverse hyperbolic tangent atanh(e). Real only for |e| < 1; out-of-domain and complex inputs stay symbolic. Accepts _MatrixValue (element-wise).
The inverse hyperbolic tangent atanh(e). Real only for |e| < 1; out-of-domain and complex inputs stay symbolic. Accepts _MatrixValue (element-wise).
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The beta function Beta(a, b) = Gamma(a)Gamma(b) / Gamma(a+b).
The beta function Beta(a, b) = Gamma(a)Gamma(b) / Gamma(a+b).
Capitalised for the same reason as Gamma: lowercase beta stays available as a variable. Computed through lgamma for positive arguments so it survives large inputs; stays symbolic when any factor is undefined.
Value parameters
- a
-
the first argument
- b
-
the second argument
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The regularised incomplete beta betaI(x, a, b) = I_x(a, b).
The regularised incomplete beta betaI(x, a, b) = I_x(a, b).
The Student-t and F cdfs. Three arguments, which no other _Function has; children and rebuild carry all three, so the generic traversal handles it like any other node.
Value parameters
- a
-
the first shape parameter
- b
-
the second shape parameter
- x
-
the argument, in
[0, 1]
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The binomial coefficient binom(n, k).
The binomial coefficient binom(n, k).
Generalised to a real upper index by the falling factorial n(n-1)...(n-k+1)/k!, so binom(-1, 3) is -1; k must be a non-negative integer, and the value is 0 for a negative k or for k > n at non-negative integer n. Exact for integer arguments, which is what keeps binom(30, 15) an integer rather than a rounded Double.
Value parameters
- k
-
the lower index
- n
-
the upper index
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The n-th Catalan number catalan(n) = binom(2n, n)/(n+1).
The n-th Catalan number catalan(n) = binom(2n, n)/(n+1).
Value parameters
- e
-
the index
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The ceiling function ceil(e) -- the least integer not below e (F_0324); see Floor.
The ceiling function ceil(e) -- the least integer not below e (F_0324); see Floor.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The cosine integral Ci(e) — the antiderivative of cos(v)/v; real only for e > 0.
The cosine integral Ci(e) — the antiderivative of cos(v)/v; real only for e > 0.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
One requirement placed on one sub-expression.
One requirement placed on one sub-expression.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The cosine function cos(e).
The cosine function cos(e).
Accepts _Number, _MatrixValue (element-wise), and _Complex arguments.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The hyperbolic cosine cosh(e). Entire; accepts _MatrixValue and _Complex arguments.
The hyperbolic cosine cosh(e). Entire; accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The cotangent cot(e) = cos(e)/sin(e). Symbolic at the poles (sin = 0); accepts _MatrixValue and _Complex arguments.
The cotangent cot(e) = cos(e)/sin(e). Symbolic at the poles (sin = 0); accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The hyperbolic cotangent coth(e) = cosh(e)/sinh(e). Symbolic at e = 0; accepts _MatrixValue and _Complex arguments.
The hyperbolic cotangent coth(e) = cosh(e)/sinh(e). Symbolic at e = 0; accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The cosecant csc(e) = 1/sin(e). Symbolic at the poles (sin = 0); accepts _MatrixValue and _Complex arguments.
The cosecant csc(e) = 1/sin(e). Symbolic at the poles (sin = 0); accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The hyperbolic cosecant csch(e) = 1/sinh(e). Symbolic at e = 0; accepts _MatrixValue and _Complex arguments.
The hyperbolic cosecant csch(e) = 1/sinh(e). Symbolic at e = 0; accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The digamma function digamma(e) = Γ'(e)/Γ(e).
The digamma function digamma(e) = Γ'(e)/Γ(e).
Spelled lowercase, unlike Gamma/Beta: those are capitalised because gamma and beta are extremely common variable names, and digamma is not.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Which number system the question is being asked in.
Which number system the question is being asked in.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The domain of an expression in one variable.
The domain of an expression in one variable.
Value parameters
- constraints
-
every requirement the expression places, always populated
- intervals
-
the resolved real intervals, or
Nonewhen they could not be derived
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The exponential integral Ei(e) — the antiderivative of e^v/v; e = 0 is the pole.
The exponential integral Ei(e) — the antiderivative of e^v/v; e = 0 is the pole.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The error function erf(e).
The error function erf(e).
Like the rest of the analytic family this has no _Function.exactKernel — spire supplies no special functions, so the kernel is Double-based and an exact argument falls back to viaDouble, capped at _Rational.DoubleReliableDigits.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The complementary error function erfc(e) = 1 − erf(e).
The complementary error function erfc(e) = 1 − erf(e).
Its own node rather than sugar for 1 - erf(x), because the kernel computes it without that subtraction and so keeps its accuracy far out in the tail.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The natural exponential function exp(e).
The natural exponential function exp(e).
Accepts _Number, _MatrixValue (element-wise), and _Complex arguments. Delegates to _Complex.expc for complex inputs.
Value parameters
- e
-
the exponent expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Which end of the order an operation takes.
Which end of the order an operation takes.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The factorial fact(e) = e!.
The factorial fact(e) = e!.
A non-negative integer argument uses the exact table; a non-integer argument is the analytic continuation Gamma(e + 1), so fact(0.5) is sqrt(pi)/2. Stays symbolic at the poles (negative integers), past the 170! overflow bound, and on a complex argument (the Asin convention). Distributes element-wise over a matrix argument like every other _Function.
Differentiating it needs the digamma function, which is not implemented, so derive(fact(x), x) stays symbolic.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The floor function floor(e) -- the greatest integer not above e (F_0324).
The floor function floor(e) -- the greatest integer not above e (F_0324).
On the Abs template. Exact on exact input: a rational or a surd answers the exact integer (a _Rational), the surd decided by integer arithmetic rather than by a reading at the working precision. A real answers a Double that is a whole number; a dense matrix is mapped element-wise. A complex or interval argument stays unevaluated, the Asin convention: neither has an order to round in. derive is zero away from the integers, where the function jumps (differentiable excludes them).
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The Fresnel cosine integral fresnelC(e) = ∫₀ᵉ cos(π t²/2) dt.
The Fresnel cosine integral fresnelC(e) = ∫₀ᵉ cos(π t²/2) dt.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The Fresnel sine integral fresnelS(e) = ∫₀ᵉ sin(π t²/2) dt.
The Fresnel sine integral fresnelS(e) = ∫₀ᵉ sin(π t²/2) dt.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The gamma function Gamma(e), the analytic continuation of the factorial.
The gamma function Gamma(e), the analytic continuation of the factorial.
Spelled with a capital G in the grammar on purpose: it keeps the lowercase gamma free as an ordinary variable name, which it very commonly is (Lorentz factor, Euler-Mascheroni constant, regression coefficients). Beta follows the same rule; lgamma does not need it, since it is not a name anyone binds.
Stays symbolic at the poles 0, -1, -2, ..., on overflow, and on complex arguments.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The regularised lower incomplete gamma gammaP(a, x) = P(a, x).
The regularised lower incomplete gamma gammaP(a, x) = P(a, x).
Exposed directly because it is the chi-squared and gamma cdf, not only an internal step towards erf.
Value parameters
- a
-
the shape parameter
- x
-
the argument
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The regularised upper incomplete gamma gammaQ(a, x) = Q(a, x) = 1 − P(a, x).
The regularised upper incomplete gamma gammaQ(a, x) = Q(a, x) = 1 − P(a, x).
Value parameters
- a
-
the shape parameter
- x
-
the argument
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The n-th harmonic number harmonic(n) = 1 + 1/2 + ... + 1/n (harmonic(0) = 0).
The n-th harmonic number harmonic(n) = 1 + 1/2 + ... + 1/n (harmonic(0) = 0).
Rational-valued, so the exact tier is the interesting one: harmonic(4) is 25/12 exactly, not 2.0833.... Related to the existing Digamma by H(n) = psi(n+1) + gamma, which the test suite checks rather than assumes.
Value parameters
- e
-
the index
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
A closed/open real interval; endpoints may be infinite.
A closed/open real interval; endpoints may be infinite.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The logarithmic integral li(e) = Ei(ln e) — the antiderivative of 1/ln(v); real for e > 0, e ≠ 1.
The logarithmic integral li(e) = Ei(ln e) — the antiderivative of 1/ln(v); real for e > 0, e ≠ 1.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Direction of approach for a limit expression.
Direction of approach for a limit expression.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The natural logarithm ln(e).
The natural logarithm ln(e).
For a negative real argument returns the principal complex value ln|x| + i*pi via _Complex.logc; ln(0) stays symbolic. Accepts _MatrixValue (element-wise) and _Complex arguments.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The general-base logarithm log(e, base).
The general-base logarithm log(e, base).
log(x) in the grammar is syntactic sugar for LogBase(x, 10); log(x, b) for LogBase(x, b). Evaluated via the change-of-base formula ln(x) / ln(base). Complex closure: log(-1, 10) = i*pi / ln(10) and similar are computed correctly. Undefined forms (log(0, b), log(x, 1), log(x, 0)) stay symbolic.
Value parameters
- base
-
the logarithm base
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The log-gamma function lgamma(e) = ln|Gamma(e)|.
The log-gamma function lgamma(e) = ln|Gamma(e)|.
Stays finite well past the point where Gamma itself overflows, which is what it is for. Lowercase because, unlike Gamma/Beta, it collides with nothing.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The remainder mod(a, b) = a - b·⌊a/b⌋, with the sign of the divisor (F_0324, Python's convention): mod(-7, 3) is 2 and mod(7, -3) is -2.
The remainder mod(a, b) = a - b·⌊a/b⌋, with the sign of the divisor (F_0324, Python's convention): mod(-7, 3) is 2 and mod(7, -3) is -2.
Exact on exact operands (evaluated from the definition, so a surd operand stays exact), and on Doubles the exact remainder of the two values rather than the formula, which loses every digit once a/b passes 2⁵³. A zero divisor, a non-finite operand, a complex, interval or matrix operand stays unevaluated. derive is a' - b'·⌊a/b⌋, away from the jumps.
Value parameters
- a
-
the dividend
- b
-
the divisor
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The multifactorial mfact(e, k) = e * (e-k) * (e-2k) * ....
The multifactorial mfact(e, k) = e * (e-k) * (e-2k) * ....
mfact(n, 1) is the ordinary factorial and mfact(n, 2) the double factorial, which the grammar spells dfact(n) and desugars to mfact(n, 2) -- the same sugar relationship log(x) has with LogBase(x, 10). Defined for a non-negative integer argument and a positive integer step; anything else stays symbolic.
Value parameters
- e
-
the argument expression
- k
-
the step expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The token a function node prints and parses as, plus the one rendering built from it.
The token a function node prints and parses as, plus the one rendering built from it.
A separate trait rather than members on _Function, and the reason is binary compatibility (issue F_0016 step 0). Putting an abstract name on the published _Function would oblige every external subclass to supply it, which MiMa correctly reports as a break — an abstract val is no better, since a Scala val compiles to an accessor method and the JVM has no abstract fields. A new trait is additive, and mixing it into an existing class adds an interface rather than an obligation on anyone else's code, so nothing outside the library can be broken by it.
Mix it into a node whose printed form is exactly name(child, child, …).
Attributes
- Supertypes
- Known subtypes
-
class Absclass Acosclass Acoshclass Asinclass Asinhclass Atanclass Atanhclass Betaclass BetaIclass Binomclass Catalanclass Ceilclass Ciclass Cosclass Coshclass Cotclass Cothclass Cscclass Cschclass Digammaclass Eiclass Erfclass Erfcclass Expclass Factorialclass Floorclass FresnelCclass FresnelSclass Gammaclass GammaPclass GammaQclass Harmonicclass Liclass Lnclass LogBaseclass LogGammaclass Modclass MultiFactorialclass Roundclass Secclass Sechclass Siclass Sinclass Sinhclass Tanhclass Tgclass _Clampclass _Extremeclass _Joinclass _SoftplusShow all
Exponentiation: base ^ exp.
Exponentiation: base ^ exp.
The parser keeps ^ right-associative (2^3^2 = 2^(3^2)). When the real power is undefined (NaN / infinite), falls back to the principal complex value — so (-2)^0.5 = i√2 and (-8)^(1/3) is the principal complex cube root.
For a square dense _MatrixValue base with an integer exponent, uses binary exponentiation (A^0 = I, A^-n = (A⁻¹)^n). Non-square, non-integer, or negative power of singular matrix → stays symbolic.
Value parameters
- base
-
the base expression
- exp
-
the exponent expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Operationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Multiplication of two expressions: a * b.
Multiplication of two expressions: a * b.
Matrix cases are evaluated before the scalar zero short-circuit (0 * M yields the zero matrix, not _Number(0)). Matrix–matrix uses _MatrixValue.multiply; scalar–matrix uses _MatrixValue.scale. Complex closure is applied when both operands are concrete values.
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Operationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Division of two expressions: a / b.
Division of two expressions: a / b.
x/0 and 0/0 stay symbolic. M / k scales the matrix; k / M computes k · M⁻¹; M / N computes M · N⁻¹ (non-invertible or non-conforming → symbolic). Complex closure applied when both operands are concrete.
Value parameters
- a
-
numerator
- b
-
denominator
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Operationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Which reduction a _Reduction denotes (issue F_0037).
Which reduction a _Reduction denotes (issue F_0037).
Two kinds, one definition: they differ only in the binary node that combines two terms and in what an empty range is worth, so _Reduction holds both facts once and the named spellings round-trip -- the _Sequence/SeqKind pattern.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalstrait Keywordedclass Objecttrait Matchableclass AnyShow all
What a node demands of one of its arguments.
What a node demands of one of its arguments.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A rewrite rule: match lhs, check condition, produce rhs.
A rewrite rule: match lhs, check condition, produce rhs.
Value parameters
- condition
-
a guard over the bindings and the context variable —
∫ dv/(a²+v²)needs the holeato be free of the integration variable, which is only readable once that variable is threaded in. The combinators below (freeOf, nonZero, …) are the intended way to build one. - lhs
-
the pattern, built from ordinary nodes plus _Pattern holes
- name
-
a label, for diagnostics and test failure messages
- rhs
-
the template, whose
_Patternholes are filled from the match
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The rounding function round(e) -- the nearest integer to e, a tie going away from zero (F_0324; see Rounding for why that convention); see Floor for the rest.
The rounding function round(e) -- the nearest integer to e, a tie going away from zero (F_0324; see Rounding for why that convention); see Floor for the rest.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The secant sec(e) = 1/cos(e). Symbolic at the poles (cos = 0); accepts _MatrixValue and _Complex arguments.
The secant sec(e) = 1/cos(e). Symbolic at the poles (cos = 0); accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The hyperbolic secant sech(e) = 1/cosh(e). Entire (cosh ≥ 1); accepts _MatrixValue and _Complex arguments.
The hyperbolic secant sech(e) = 1/cosh(e). Entire (cosh ≥ 1); accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Which linear recurrence a _Sequence denotes.
Which linear recurrence a _Sequence denotes.
Every case is x(k) = p*x(k-1) + q*x(k-2) with its own seeds and coefficients, so there is one definition of the recurrence and the named variants are spellings of it:
| kind | seeds (a, b) |
(p, q) |
first terms |
|---|---|---|---|
Fibonacci |
(0, 1) |
(1, 1) |
0, 1, 1, 2, 3, 5, ... |
Lucas |
(2, 1) |
(1, 1) |
2, 1, 3, 4, 7, 11, ... |
Pell |
(0, 1) |
(2, 1) |
0, 1, 2, 5, 12, 29, ... |
Jacobsthal |
(0, 1) |
(1, 2) |
0, 1, 1, 3, 5, 11, ... |
An enum-tagged node rather than parse-time aliases, which is the _Statistic/StatKind and _Comparison/CompareOp pattern. Desugaring lucas(n) into fib(n, 2, 1) — the dfact -> mfact route — would have been cheaper, but the sugar is lost on the way back: the user types lucas(10) and the REPL, and :save, answer fib(10, 2, 1). Acceptable for dfact; self-defeating for a family whose point is that the names are related. This way each name survives the round trip and the equivalence (lucas(n) = fib(n, 2, 1)) is a documented fact rather than a second implementation.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalstrait Keywordedclass Objecttrait Matchableclass AnyShow all
The sine integral Si(e) = ∫₀ᵉ sin(t)/t dt — the antiderivative of sin(v)/v.
The sine integral Si(e) = ∫₀ᵉ sin(t)/t dt — the antiderivative of sin(v)/v.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The sine function sin(e).
The sine function sin(e).
Accepts _Number, _MatrixValue (element-wise), and _Complex arguments.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
One located singularity.
One located singularity.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
How an isolated singularity behaves.
How an isolated singularity behaves.
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The hyperbolic sine sinh(e). Entire; accepts _MatrixValue and _Complex arguments.
The hyperbolic sine sinh(e). Entire; accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Addition of two expressions: a + b.
Addition of two expressions: a + b.
Also evaluates concrete matrix operands via _MatrixValue.add (conforming dimensions) and concrete complex-valued operands via _Complex.add. Dimension mismatches stay symbolic.
Value parameters
- a
-
left operand
- b
-
right operand
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Operationtrait _Expressionclass Objecttrait Matchableclass AnyShow all
Optional method-call syntax for the scalar algorithms.
Optional method-call syntax for the scalar algorithms.
Lets callers write e.simplify() instead of simplify(e). Kept in an object (and out of the _Expression trait) so core depends on no domain and the method names do not collide with the top-level package functions they forward to. Opt in with import scalar.Syntax.*.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Syntax.type
The hyperbolic tangent tanh(e). Entire; accepts _MatrixValue and _Complex arguments.
The hyperbolic tangent tanh(e). Entire; accepts _MatrixValue and _Complex arguments.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
The tangent function tan(e) (also parsed as tg(e)).
The tangent function tan(e) (also parsed as tg(e)).
A real result that is NaN or infinite (at multiples of pi/2) stays symbolic. Accepts _MatrixValue (element-wise) and _Complex arguments.
Value parameters
- e
-
the argument expression
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctionclass _Functiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
balanced(n) — the balanced-ternary form of n, with digits {-1, 0, 1}.
balanced(n) — the balanced-ternary form of n, with digits {-1, 0, 1}.
Written T/0/1, the same alphabet the symmetric ternary logic uses for {false, unknown, true}. That shared alphabet is why balanced ternary belongs in this library rather than being a bare utility: logic symmetric on and balanced(n) are the same three digits seen from two sides.
Value parameters
- e
-
the value to re-base
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
Saturation: clamp(x, lo, hi), x limited to [lo, hi], element-wise with numbers spreading (actuator saturation of an input column, against scalar or column bounds). lo > hi has no interval to clamp into and leaves it unevaluated.
Saturation: clamp(x, lo, hi), x limited to [lo, hi], element-wise with numbers spreading (actuator saturation of an input column, against scalar or column bounds). lo > hi has no interval to clamp into and leaves it unevaluated.
Value parameters
- hi
-
the upper bound(s)
- lo
-
the lower bound(s)
- x
-
the value(s) to limit
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
AST node for a definite integral: integral(e, v, lo, hi) in the grammar.
AST node for a definite integral: integral(e, v, lo, hi) in the grammar.
eval numerically integrates with composite Simpson's rule when low_limit and up_limit fold to concrete numbers. Step count is scaled by the interval length and the session precision. The fast path compiles the integrand to a Double => Double closure; the fallback evaluates the tree per step.
Value parameters
- e
-
the integrand
- low_limit
-
lower bound of integration
- up_limit
-
upper bound of integration
- v
-
the integration variable (binder -- excluded from
children)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
AST node for symbolic differentiation: derive(e, v) in the grammar.
AST node for symbolic differentiation: derive(e, v) in the grammar.
eval delegates to derive, and guards against the fixpoint case where derive returns this (would loop forever): if the algorithm cannot reduce, stays symbolic.
Value parameters
- e
-
the expression to differentiate
- v
-
the differentiation variable (binder -- excluded from
children)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
The reduction: max(v) / min(v), the extreme entry of one array.
The reduction: max(v) / min(v), the extreme entry of one array.
Over every entry, row-major, whatever the shape — the mean(x) sample convention, not MATLAB's column-wise rule. A number is its own extreme.
Value parameters
- arg
-
the array, or a number
- kind
-
which end of the order
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
Truncated Fourier series of e in v over one period centred on zero: fourierSeries(e, v, period, n).
Truncated Fourier series of e in v over one period centred on zero: fourierSeries(e, v, period, n).
Like _Taylor, v is the expansion variable rather than a binder: it appears free in the result. It is kept out of children and carried through rebuild so substitute cannot rewrite the variable the expansion is taken in.
Unlike _Taylor, the coefficients are numeric: each is a definite integral evaluated by Simpson's rule, so period must reduce to a concrete positive number and the integrand must be evaluable over [-period/2, period/2]. Anything else leaves the node symbolic, the fixpoint convention shared with the transforms.
Not to be confused with transform._Fourier (fourier(e, t, w)), which is the Fourier transform -- a different operation with a different result type.
Value parameters
- e
-
the expression to expand
- n
-
the highest harmonic retained
- period
-
the period,
T - v
-
the expansion variable
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
- Known subtypes
-
class Absclass Acosclass Acoshclass Asinclass Asinhclass Atanclass Atanhclass Betaclass BetaIclass Binomclass Catalanclass Ceilclass Ciclass Cosclass Coshclass Cotclass Cothclass Cscclass Cschclass Digammaclass Eiclass Erfclass Erfcclass Expclass Factorialclass Floorclass FresnelCclass FresnelSclass Gammaclass GammaPclass GammaQclass Harmonicclass Liclass Lnclass LogBaseclass LogGammaclass Modclass MultiFactorialclass Roundclass Secclass Sechclass Siclass Sinclass Sinhclass Tanhclass TgShow all
Base class for higher-order operators that take an expression and a variable and produce a new expression: differentiation, integration, and limits.
Base class for higher-order operators that take an expression and a variable and produce a new expression: differentiation, integration, and limits.
The algorithms live in their own files (Derive.scala, Integrate.scala, Limit.scala); subclasses here are the AST nodes that carry the unevaluated form.
children / rebuild convention: the binder variable (v in derive(e, v), integral(e, v), limit(e, v, point)) is excluded from children -- it names the variable of differentiation/integration, not a use-site occurrence -- so traversals (substitute, dependsOn) never recurse into it. _DefIntegral's children include low_limit and up_limit because they are regular expression positions subject to substitution and dependsOn checks.
Attributes
- Supertypes
- Known subtypes
-
class _ODEclass _DefIntegralclass _Derivativeclass _FourierSeriesclass _Integralclass _Laurentclass _Limitclass _Padeclass _Reductionclass _Tabulateclass _Taylorclass _Fourierclass _FourierCausalclass _InverseLaplaceclass _InverseZTransformclass _Laplaceclass _ZTransformShow all
AST node for symbolic indefinite integration: integral(e, v) in the grammar.
AST node for symbolic indefinite integration: integral(e, v) in the grammar.
eval delegates to integrate, guarded against the fixpoint where integrate returns this (mirrors _Derivative.eval's termination guard).
Value parameters
- e
-
the integrand
- v
-
the integration variable (binder -- excluded from
children)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
The interval literal [lo, hi] (F_0008): evaluates to a core._Interval once both endpoints are real numbers with lo ≤ hi, and stays as written otherwise — the _DistributionOf split, so [0, a] keeps its meaning while a is free.
The interval literal [lo, hi] (F_0008): evaluates to a core._Interval once both endpoints are real numbers with lo ≤ hi, and stays as written otherwise — the _DistributionOf split, so [0, a] keeps its meaning while a is free.
A single pair of brackets was free in the grammar: a matrix row is always written inside a second pair, [[a, b]]. toString is the literal, so it round-trips.
Value parameters
- hi
-
the upper endpoint
- lo
-
the lower endpoint
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The element-wise join: maximum(a, b, …) / minimum(a, b, …).
The element-wise join: maximum(a, b, …) / minimum(a, b, …).
Value parameters
- args
-
two or more operands; a number spreads over a matrix operand's cells
- kind
-
which end of the order
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
AST node for laurent(e, v, point, m, n).
AST node for laurent(e, v, point, m, n).
Expands e about an isolated singularity as Σ(k = −m to n) c_k·(v − point)ᵏ.
Follows _Taylor's convention that v is the expansion variable rather than a binder — free in the result, but excluded from children so substitute cannot rewrite the variable the expansion is taken in.
m is optional. When absent the pole order is detected with singularitiesOf whose Pole(order) is the length of the principal part. A Removable singularity gives m = 0, which is an ordinary Taylor series — returned rather than refused, since the caller asked a well-formed question that simply has no principal part.
Stays symbolic when the order cannot be determined, when a coefficient does not fold finite, or when the point is an essential singularity: there the principal part is infinite, and a truncation would carry a different contract from the polynomial tiers — the discarded terms blow up near the point instead of becoming small.
Value parameters
- e
-
the expression to expand
- m
-
the pole order, or
Noneto detect it - n
-
the highest non-negative power retained
- point
-
the singularity
- v
-
the expansion variable
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
AST node for a limit expression: limit(e, v, point) or limit(e, v, point, +/-).
AST node for a limit expression: limit(e, v, point) or limit(e, v, point, +/-).
eval delegates to evalLimit, guarded against the fixpoint where it returns this (stays symbolic). The binder variable v is excluded from children; point is included because it may contain other free variables.
Value parameters
- dir
-
the direction of approach (default: LimitDir.Both)
- e
-
the expression whose limit to compute
- point
-
the limit point
- v
-
the approach variable (binder -- excluded from
children)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
Padé approximant [m/n] of e about zero: pade(e, v, m, n).
Padé approximant [m/n] of e about zero: pade(e, v, m, n).
The rational function P/Q with deg P <= m, deg Q <= n and Q(0) = 1 whose Maclaurin series agrees with e's through order m + n. Frequently a much better approximation than the Taylor polynomial of the same total degree, because a rational function can model a nearby pole that no polynomial can.
Follows _Taylor's convention that v is the expansion variable rather than a binder -- free in the result, but excluded from children so substitute cannot rewrite it. Like _FourierSeries the coefficients are numeric, so m and n must fold to non-negative integers with m + n <= MaxTaylorOrder and every Maclaurin coefficient must reduce; anything else leaves the node symbolic, including the case where the linear system is singular and no [m/n] approximant exists.
Value parameters
- e
-
the expression to approximate
- m
-
the numerator degree
- n
-
the denominator degree
- v
-
the expansion variable
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
A pattern variable: matches any sub-expression and binds it under name.
A pattern variable: matches any sub-expression and binds it under name.
Never appears in a user expression — it exists only inside a rule's left-hand side — so nothing outside this file has to recognise it, and core needs no change to accommodate it. eval stays symbolic, which is the correct answer for a thing that is not a value.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
sum(e, k, lo, hi) / product(e, k, lo, hi) -- a finite reduction over an integer range.
sum(e, k, lo, hi) / product(e, k, lo, hi) -- a finite reduction over an integer range.
The counterpart of _Tabulate, which yields the terms rather than their total, and the reason a summation could not be converted from the editor before: tabulate is not an answer to a Σ, so the AsciiMath reader had nothing to translate one into and refused it by name. Same shape as tabulate -- k is a binder (excluded from children, carried through rebuild, so substitute cannot rewrite it) while lo/hi are ordinary children, the _DefIntegral convention -- and the same MaxTabulateTerms cap, shared through indexRange.
The terms are folded with reduce, never a seeded fold. Seeding with a literal _Number(0) would be an inexact-tier constant, so an exact sum would be demoted through float contagion before anything could use it -- the numeric-tier rule, and the single most repeated bug of issues 4.L and 4.N. The identity is therefore used for the empty range only, where there is nothing to combine with and nothing to demote.
An empty range is the identity rather than a refusal, unlike tabulate's empty grid: the empty sum is 0 and the empty product 1 by universal convention, which is exactly what makes sum(f, k, 1, n) read correctly at n = 0 instead of declining a base case.
Symbolic terms EXPAND. sum(k*x, k, 1, 3) becomes x + 2x + 3x rather than staying folded, so normalize/simplify can collect it -- and since this is a _Functional, F_0034's pass reduces it under the simplify command with no further wiring.
Value parameters
- e
-
the term, in which
vis bound - hi
-
the last index, inclusive
- kind
-
which reduction this is
- lo
-
the first index, inclusive
- v
-
the index variable (a binder)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
A term of a linear recurrence: fib(n), lucas(n), pell(n), jacobsthal(n), and the seed-generalised fib(n, a, b).
A term of a linear recurrence: fib(n), lucas(n), pell(n), jacobsthal(n), and the seed-generalised fib(n, a, b).
Indexing is the standard one: x(0) = 0, x(1) = 1, so fib(10) = 55, matching OEIS A000045 and every published table. The "classic rabbit" pair is fib(n, 1, 1), which is this sequence shifted by one (fib(n, 1, 1) = fib(n+1)). Stated here because it cannot be inferred and an off-by-one would be silent — the rule also applied to the spherical polar angle.
These are numeric sequences, not integer ones. The recurrence needs only addition and multiplication, so fib(5, 1.5, -pi) is a legitimate call and exact seeds stay exact. An exact integer index with exact seeds goes through linRecExact, which is what lets fib(79) be right: F(79) exceeds 2^53, so the Double path can only approximate it.
Value parameters
- kind
-
which recurrence
- n
-
the index
- seeds
-
empty for the kind's own seeds, or exactly two expressions overriding them
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The smooth max(0, x): softplus(x, k) = ln(1 + e^(k·x))/k, tending to max(0, x) as k grows. k must be positive.
The smooth max(0, x): softplus(x, k) = ln(1 + e^(k·x))/k, tending to max(0, x) as k grows. k must be positive.
Never evaluated as written: ln(1 + e^(k·x)) overflows once k·x passes ~709, so the value is (max(k·x, 0) + log1p(e^(−|k·x|)))/k — the numerical conditioning rule. An exact argument re-enters the exact tier through fromApproximation, the transcendental precedent.
Value parameters
- k
-
the sharpness, positive
- x
-
the argument(s), element-wise
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait NamedFunctiontrait _Expressionclass Objecttrait Matchableclass AnyShow all
tabulate(e, k, lo, hi) — evaluates e at each integer k in [lo, hi], as a row matrix.
tabulate(e, k, lo, hi) — evaluates e at each integer k in [lo, hi], as a row matrix.
The generic answer to "how do I get a list of terms?" It is not specific to the sequences: tabulate(binom(4, k), k, 0, 4) is a Pascal row and tabulate(k^2, k, 1, 5) the squares, so every function in the library gains a tabulated form from one node.
The result is a 1xn matrix._Matrix, which is already this project's carrier for a sequence of values — eigen(A) returns one — so indexing with at(r, 1, k), tuple assignment, the matrix operations, pretty-printing and :save all come for free.
k is a binder: excluded from children and carried through rebuild, so substitute cannot rewrite it, while lo and hi are ordinary children — the _DefIntegral convention. The index is bound as a _Number, matching _DefIntegral and sample; a term that does not fold stays symbolic in its cell.
Value parameters
- e
-
the expression to tabulate
- hi
-
the last index, inclusive
- lo
-
the first index, inclusive
- v
-
the index variable (a binder)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
Taylor expansion of e in v about point, truncated after order n: taylor(e, v, point, n).
Taylor expansion of e in v about point, truncated after order n: taylor(e, v, point, n).
v is the expansion variable, not a binder: unlike _Derivative's or _Integral's variable it appears free in the result, which is a polynomial in (v - point) — the same role the output variable plays in _Laplace. It is nevertheless kept out of children and carried through rebuild, so substitute cannot rewrite the variable the expansion is taken in.
eval builds the series with taylorSeries and evaluates the result, so a bound v folds the polynomial to a number while a free one leaves it symbolic. It stays symbolic when n does not reduce to an integer in 0 .. MaxTaylorOrder, or when some coefficient cannot be differentiated (Gamma, fact, ... — see hasDerivative).
maclaurin(e, v, n) in the grammar is sugar for taylor(e, v, 0, n) and prints in that form, exactly as log(x) prints as log(x, 10).
Value parameters
- e
-
the expression to expand
- n
-
the truncation order
- point
-
the centre of the expansion
- v
-
the expansion variable
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
tobase(n, b) — reads n as an integer written in base b.
tobase(n, b) — reads n as an integer written in base b.
Evaluates to a core._Based, which is the number and additionally remembers its base for display. There is no inverse node: a _Based already reads as its value through _Number's widening extractor, so tobase(255, 16) + 0 is 255.
Stays symbolic when n is not a whole number or b is not an integer in _Based.MinBase .. _Based.MaxBase — the smart factory would collapse those to a plain _Number, which would silently discard the request rather than refuse it.
Value parameters
- base
-
the radix
- e
-
the value to re-base
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The data-driven table of integrals: rewrite rules run through the Rewrite engine.
The data-driven table of integrals: rewrite rules run through the Rewrite engine.
Every rule here is a RewriteRule, not a compiled case arm. That is the whole point of the hybrid: this table is expected to keep growing, one entry at a time, and a rule added here needs no change to integrate's match.
The integration variable is a pattern variable named v. A rule is written over the integrand, and the binder is matched like any other hole — so ∫ tan(v) dv is the pattern Tg(?v).
?v may bind a linear function of the integration variable, not only the variable itself. A pattern matches a shape, so Tg(?v) alone would cover ∫ tan(x) dx and not ∫ tan(2x) dx — yet the compiled tiers have handled a linear inner argument since the beginning by dividing through by the slope, and there is no reason for the table to be weaker. applyTo therefore requires ?v to bind some a·x + b with a ≠ 0 and divides the instantiated result by a. Every rule in the table gains its chain-rule case from that one place.
That requirement subsumes the "is it the right variable?" check this table needed before: ∫ tan(y) dx binds ?v to y, whose derivative in x is zero, so no rule fires. A non-linear argument (∫ tan(x²) dx) is rejected the same way, which keeps it correctly unsolved rather than wrongly solved.
Consulted only after every compiled arm has declined, so adding a rule cannot change an integral that already works. The corollary is that nothing here duplicates a compiled rule: 1/(1+v²), 1/√(1-v²), v·eᵛ, ln v, sinⁿ v, √v and the rational tier all close earlier, and a second definition of the same fact is only a way for the two to disagree.
Products and sums are matched in the order written. Unification is structural, so Product(Exp(?v), Sin(?v)) does not match sin(x)·exp(x); the commuted spelling of a commutative operand pair is a separate entry, because a user types either one.
Inventory (by section): the base entries (tan, cot, sec, csc, sec·tan, sin·cos, the hyperbolics sinh…csch·coth, ln²v, ln(v)/v, 1/(v·ln v), eᵛ/(1+eᵛ), the cyclic eᵛ·sin v/eᵛ·cos v); the special-integral connections (Si/Ci/Ei/li/erf/Fresnel); and the bulk transcription — symbolic-slope hyperbolics (sinh(a·v) …), the standalone inverse functions (asin … atanh), the remaining hyperbolics (sech, csch, tanh², coth²), the symbolic-a algebraic and radical family (1/(a²−v²), 1/√(a²±v²), 1/√(v²−a²)), the product-to-sum trio (sin(a·v)·cos(b·v) …), the general e^(a·v)·sin/cos(b·v) pair, v·aᵛ and vᵃ — every one verified by the IntegralTableTest harness, which differentiates each rule's rhs back against its lhs at expression level.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
integralRules.type
Value members
Concrete methods
The beta function B(x, y) = Γ(x)Γ(y) / Γ(x+y).
The beta function B(x, y) = Γ(x)Γ(y) / Γ(x+y).
For positive arguments this goes through lgammaOf and exponentiates, which keeps it finite for large x/y where the individual gammas would overflow; otherwise it falls back to the direct gamma quotient. None when any factor is undefined or the result is not representable.
Value parameters
- x
-
the first argument
- y
-
the second argument
Attributes
- Returns
-
Some(B(x, y))when defined and representable,Noneotherwise
The exact binomial coefficient for a non-negative integer n and k.
The exact binomial coefficient for a non-negative integer n and k.
Multiplicative form, dividing at every step so the intermediate values stay as small as the result — C(2n, n) would otherwise build (2n)! on the way.
Attributes
- Returns
-
Some(C(n, k)), orNonewhenkexceeds the cap
The binomial coefficient C(n, k) in Double, generalised to a real upper index.
The binomial coefficient C(n, k) in Double, generalised to a real upper index.
Uses the falling factorial n(n-1)…(n-k+1)/k!, which is the standard generalisation and handles a negative or fractional n (C(-1, 3) = -1). k must be a non-negative integer; C(n, k) = 0 for a negative k, and for k > n when n is a non-negative integer.
Attributes
- Returns
-
Some(C(n, k)), orNonewhenkis not an integer or the result is non-finite
The n-th Catalan number C(2n, n)/(n+1), exactly.
The n-th Catalan number C(2n, n)/(n+1), exactly.
Attributes
- Returns
-
Some(Cat(n)), orNoneoutside the non-negative integers within the cap
The n-th Catalan number in Double.
The n-th Catalan number in Double.
Attributes
The cosine integral Ci(x) = γ + ln x + ∫₀ˣ (cos t − 1)/t dt. Real only for x > 0.
The cosine integral Ci(x) = γ + ln x + ∫₀ˣ (cos t − 1)/t dt. Real only for x > 0.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(Ci(x))forx > 0,Noneotherwise
Extracts the dense coefficient vector of e as a polynomial in v.
Extracts the dense coefficient vector of e as a polynomial in v.
Returns Some(Vector(c0, c1, ..., cn)) where e = c0 + c1*v + ... + cn*v^n and every ci is free of v. Returns None when e is not polynomial in v (e.g. sin(v), 1/v, 2^v, a fractional power).
Value parameters
- e
-
the expression to analyse
- v
-
the polynomial variable
Attributes
- Returns
-
Somecoefficient vector (length = degree + 1) orNonefor non-polynomial shapes
Attempts to compile expression e into a raw Double => Double closure over v, resolving any other free variables from env.
Attempts to compile expression e into a raw Double => Double closure over v, resolving any other free variables from env.
When Some(f) is returned, f(x) evaluates e with v bound to x at full Double precision with no per-sample allocation, no tree traversal, and no environment lookup — O(1) per sample after compilation. This is the fast path in _DefIntegral.eval (Simpson's rule) and in sample.
None is returned for expressions that contain unresolvable symbolic nodes (_Derivative, _Integral, unbound variables, complex values, etc.).
Value parameters
- e
-
the expression to compile
- env
-
environment for resolving any other free variables
- v
-
the free variable that maps to the closure argument
x
Attributes
- Returns
-
Some(f)when the expression is fully compilable,Noneotherwise
Compiles a symbolic matrix into a closure returning its cells, row-major (F_0058).
Compiles a symbolic matrix into a closure returning its cells, row-major (F_0058).
The cells are compiled exactly as compile compiles one expression, over the same positional variables, so a Jacobian built by jacobian(F, x, y, …) evaluates in one call without walking the tree. The argument must already BE a matrix — a _MatrixShaped literal or a dense value; a matrix operation is not evaluated here, so evaluate it first. Each call returns a fresh array of rows · cols values.
Value parameters
- env
-
environment for resolving every other free variable
- m
-
the matrix to compile
- vars
-
the variables, in argument order; a repeated name declines
Attributes
- Returns
-
Some(f)when every cell compiles,Nonefor a non-matrix or any cell that declines
Returns true when expression e contains variable v as a free occurrence.
Returns true when expression e contains variable v as a free occurrence.
Uses the cached freeVars set on each node — computed once per node on first call, then O(1) — so repeated dependsOn calls on the same expression tree are effectively free after the first traversal.
Value parameters
- e
-
the expression to inspect
- v
-
the variable to look for
Attributes
Returns the symbolic derivative of e with respect to v.
Returns the symbolic derivative of e with respect to v.
The result is memoised: calling derive(e, v) multiple times with the same arguments returns the cached result without re-walking the rule table.
Value parameters
- e
-
the expression to differentiate
- v
-
the differentiation variable
Attributes
- Returns
-
d(
e)/d(v) as a new expression (never _Derivative for rules that fire)
Returns the n-th derivative of e with respect to v.
Returns the n-th derivative of e with respect to v.
n = 0 returns e unchanged; n < 0 is rejected.
Value parameters
- e
-
the expression to differentiate
- n
-
the derivative order (non-negative)
- v
-
the differentiation variable
Attributes
- Returns
-
d^n(
e)/d(v)^n
The digamma function ψ(z) = Γ'(z) / Γ(z).
The digamma function ψ(z) = Γ'(z) / Γ(z).
Recurrence ψ(z) = ψ(z+1) − 1/z pushes a small argument up into the range where the asymptotic series converges, mirroring how gammaOf handles its own domain; the reflection formula ψ(1−z) − ψ(z) = π·cot(πz) covers the negative half-line.
Its payoff is not only the cdfs: derive has no rule for Γ or fact without it, so both stay symbolic under differentiation. With it, d/dx Γ(x) = Γ(x)·ψ(x).
Value parameters
- z
-
the argument
Attributes
- Returns
-
Some(ψ(z)), orNoneat the poles0, −1, −2, …and for non-finite input - See also
The exponential integral Ei(x), the principal value of ∫_{−∞}^x e^t/t dt.
The exponential integral Ei(x), the principal value of ∫_{−∞}^x e^t/t dt.
x > 0: series (all-positive terms, stable) up to 40, asymptotic e^x/x·Σ k!/x^k beyond; x < 0: −E₁(−x); x = 0 is a pole.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(Ei(x))for finite non-zerox(untile^xoverflows),Noneotherwise
The error function erf(x) = 2/√π ∫₀ˣ e^(−t²) dt.
The error function erf(x) = 2/√π ∫₀ˣ e^(−t²) dt.
Derived from lowerGammaP rather than approximated in its own right, so it carries full Double accuracy: erf(x) = sign(x) · P(1/2, x²).
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(erf(x))in(-1, 1), orNonefor a NaN argument - See also
The complementary error function erfc(x) = 1 − erf(x).
The complementary error function erfc(x) = 1 − erf(x).
For a positive argument this is Q(1/2, x²), computed without the subtraction: erf(3) is within 2e-5 of 1, so forming 1 − erf(x) would leave a tail value with only a handful of correct digits.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(erfc(x))in(0, 2), orNonefor a NaN argument
Evaluates lim_{v → point[dir]} e, returning the limit as an expression.
Evaluates lim_{v → point[dir]} e, returning the limit as an expression.
When point folds to a concrete _Number, the four-tier engine is applied. When point is symbolic the node stays symbolic.
Value parameters
- dir
-
the direction of approach (
Both,FromRight, orFromLeft) - e
-
the expression whose limit to evaluate
- env
-
environment for resolving free variables other than
v - point
-
the limit point (may be finite or
±∞) - v
-
the approach variable
Attributes
- Returns
-
the limit value as a
_Number, or the unchanged_Limitnode when it cannot be determined
Distributes * over +, multiplies out (a+b)^n for integer 1 ≤ n ≤ 20, and folds like terms as it goes (F_0076).
Distributes * over +, multiplies out (a+b)^n for integer 1 ≤ n ≤ 20, and folds like terms as it goes (F_0076).
The polynomial part of the expression is built over a term map — each monomial a multiset of factors, each coefficient a number — so (a+b)^20 is the 21 terms a reader expects, not the 2²⁰ products it used to be, and x + x is 2x. Anything that is not a sum, a product or such a power is a factor of that polynomial, expanded inside; terms and factors keep the order they first appear in. _ElementWise containers (matrices, equations) are expanded element-wise. Constants it invents (a coefficient 1, an exponent) are built in the input's tier, so an exact expression stays exact.
Folding treats * as commutative, which is right for scalars. A literal matrix leaf (_MatrixValue, or a symbolic matrix) is not, so a product containing one is distributed in order without folding, as before. A free variable later bound to a matrix cannot be told apart here — at the REPL resolveMatrixOps re-types such products before expand runs; a library caller expanding A*B + B*A over matrix-valued names should not.
Three guards: MaxExpandPower, the work budget MaxExpandWork and the depth limit core.MaxExpressionDepth every producer of expressions shares (F_0078). A product past a budget is left undistributed; expandReporting returns the reason with the result.
Value parameters
- e
-
the expression to expand
Attributes
- Returns
-
the expanded expression
The exact factorial n! as an arbitrary-precision integer.
The exact factorial n! as an arbitrary-precision integer.
The exact-tier counterpart of factorialOf, which is capped at 170! only because a Double overflows there.
Value parameters
- n
-
the argument
Attributes
- Returns
-
Some(n!), orNonefor a negativenor one above MaxExactFactorial
The factorial n!.
The factorial n!.
A non-negative integer up to MaxFactorial uses the exact table; a non-integer argument falls through to Γ(n + 1), which is the analytic continuation (so fact(0.5) is √π / 2). None — meaning the caller stays symbolic — for a negative integer (a pole of the gamma function), for an integer past the overflow bound, and for any non-finite input.
Value parameters
- n
-
the argument
Attributes
- Returns
-
Some(n!)when defined and representable,Noneotherwise
Expands e as a truncated Fourier series in v over one period, centred on zero.
Expands e as a truncated Fourier series in v over one period, centred on zero.
a₀/2 + Σ(k = 1 .. order) [ a_k·cos(kωv) + b_k·sin(kωv) ] with ω = 2π/T and
a_k = (2/T) ∫ f(t)·cos(kωt) dt b_k = (2/T) ∫ f(t)·sin(kωt) dt
both taken over [−T/2, T/2]. The coefficients are computed numerically, by handing each integrand to _DefIntegral — which means this needs a real Environment (unlike taylorSeries, which is purely symbolic) and that period must be a concrete positive number.
Coefficients are not thresholded. A term that vanishes analytically — every sine coefficient of an even function, say — comes back at the integrator's noise floor rather than exactly zero, and is kept. Chopping it would mean inventing an epsilon and silently discarding genuinely small coefficients; following the library's rule that cleanup is a display concern, the noise is left visible instead.
Value parameters
- e
-
the expression to expand
- env
-
environment used to evaluate the coefficient integrals
- order
-
the highest harmonic retained; must be in
0 .. MaxFourierOrder - period
-
the period
T; must be finite and strictly positive - v
-
the expansion variable; free in the result, as in taylorSeries
Attributes
- Returns
-
the truncated series, or
Nonewhen an argument is out of range or some coefficient integral does not reduce to a number
The Fresnel cosine integral C(x) = ∫₀ˣ cos(π t²/2) dt. Odd; defined everywhere.
The Fresnel cosine integral C(x) = ∫₀ˣ cos(π t²/2) dt. Odd; defined everywhere.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(C(x)), orNonefor a non-finite argument
The Fresnel sine integral S(x) = ∫₀ˣ sin(π t²/2) dt. Odd; defined everywhere.
The Fresnel sine integral S(x) = ∫₀ˣ sin(π t²/2) dt. Odd; defined everywhere.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(S(x)), orNonefor a non-finite argument
The gamma function over a complex argument, as a (re, im) pair.
The gamma function over a complex argument, as a (re, im) pair.
The same Lanczos approximation as gammaOf — the coefficients are shared, since the series is valid over the half-plane Re(z) ≥ 0.5 and not merely over the real ray — with the reflection formula Γ(z) = π / (sin(πz)·Γ(1−z)) covering the rest.
Kept on raw Double pairs rather than on core._Complex: the companion's kernels return Option[_Value], so a loop written against them would allocate and unwrap an Option on every one of the nine terms. _Complex is the boundary type, not the arithmetic type.
Value parameters
- im
-
the imaginary part
- re
-
the real part of the argument
Attributes
- Returns
-
Some((re, im))ofΓ(z), orNoneat the real poles and for non-finite input - See also
The gamma function Γ(z), the analytic continuation of the factorial (Γ(n) = (n−1)!), by the Lanczos approximation.
The gamma function Γ(z), the analytic continuation of the factorial (Γ(n) = (n−1)!), by the Lanczos approximation.
Arguments below 0.5 go through the reflection formula Γ(z) = π / (sin(πz) · Γ(1−z)). None at the poles z = 0, −1, −2, … and whenever the result overflows a Double.
Value parameters
- z
-
the argument
Attributes
- Returns
-
Some(Γ(z))when defined and representable,Noneotherwise
The n-th harmonic number H(n) = 1 + 1/2 + … + 1/n, exactly (H(0) = 0).
The n-th harmonic number H(n) = 1 + 1/2 + … + 1/n, exactly (H(0) = 0).
A natural showcase for the exact tier: H(4) is 25/12, not 2.0833…. Related to the existing digamma by H(n) = ψ(n+1) + γ, which the test suite checks rather than assumes.
Attributes
- Returns
-
Some(H(n)), orNoneoutside the non-negative integers within the cap
The n-th harmonic number in Double.
The n-th harmonic number in Double.
Attributes
The regularised incomplete beta function I_x(a, b).
The regularised incomplete beta function I_x(a, b).
The Student-t and F cdfs, and the binomial's exact tail. Continued fraction with the symmetry I_x(a,b) = 1 − I_{1−x}(b,a) used to keep the argument in the half where it converges fastest; the normalising constant goes through lgammaOf, which was computes in log space precisely so it survives large parameters.
Value parameters
- a
-
the first shape parameter, strictly positive
- b
-
the second shape parameter, strictly positive
- x
-
the argument, which must lie in
[0, 1]
Attributes
- Returns
-
Some(I_x(a, b))in[0, 1], orNoneoutside the domain - See also
Returns an antiderivative of e with respect to v, or _Integral(e, v) when no rule applies.
Returns an antiderivative of e with respect to v, or _Integral(e, v) when no rule applies.
_ElementWise containers (matrices, equations) are integrated element-wise. Chain-rule support is limited to linear inner arguments; integration by parts covers polynomial times exp/sin/cos and the standalone logarithm; rational functions are integrated by partial fractions (see integrateRational).
Value parameters
- e
-
the integrand
- v
-
the integration variable
Attributes
- Returns
-
an antiderivative of
e(constant of integration omitted), or_Integral(e, v)when no rule fires
Expands e as a Laurent series about an isolated singularity at point.
Expands e as a Laurent series about an isolated singularity at point.
Σ(k = −m to n) c_k · (v − point)ᵏ — a Taylor series extended with a principal part of m negative powers, which is what makes it work where Taylor cannot.
The method is one line; the difficulty is entirely in the first step. For a pole of order m at a, the function g(v) = (v − a)^m · f(v) is regular at a, so it can be expanded by taylorSeries to order m + n and every exponent shifted down by m.
Multiplying is not cancelling, and that is the trap. Taylor coefficients are instantiated with substitute(v := a). If the product is still written as (v − a)^m · N(v)/D(v) with the factor still present in D, then every coefficient evaluates 0/0 and comes back NaN — the series would be silently wrong rather than absent. So the product is simplified first and then verified: any coefficient that does not fold to a finite number aborts the whole expansion. This is the hasDerivative give-up rule applied to a different failure mode.
Value parameters
- e
-
the expression to expand
- env
-
bindings, used to verify the coefficients are finite
- m
-
the order of the pole, i.e. the length of the principal part
- n
-
the highest non-negative power retained
- point
-
the singularity to expand about
- v
-
the expansion variable; it appears free in the result, like taylorSeries
Attributes
- Returns
-
the truncated Laurent series, or
Nonewhen it cannot be produced honestly
The log-gamma function ln|Γ(z)|.
The log-gamma function ln|Γ(z)|.
Computed in log space rather than as log(gammaOf(z)), so it stays finite for arguments far past the factorial overflow bound — which is the whole point of having it. None at the poles and for non-finite input.
Value parameters
- z
-
the argument
Attributes
- Returns
-
Some(ln|Γ(z)|)when defined,Noneotherwise
The logarithmic integral li(x) = Ei(ln x) for x > 0, x ≠ 1 (x = 1 is the pole).
The logarithmic integral li(x) = Ei(ln x) for x > 0, x ≠ 1 (x = 1 is the pole).
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(li(x)), orNoneoutside the domain
The exact n-th term of x(k) = p·x(k-1) + q·x(k-2) over the rationals.
The exact n-th term of x(k) = p·x(k-1) + q·x(k-2) over the rationals.
Kept separate from linRecOf rather than generalised over a numeric type class: the two tiers differ in their failure modes (overflow versus a compute cap), and the exact one is the reason this function exists at all.
Attributes
- Returns
-
Some(x(n)), orNonewhennis not an index within the cap
The n-th term of x(k) = p·x(k-1) + q·x(k-2) in Double, from seeds (a, b).
The n-th term of x(k) = p·x(k-1) + q·x(k-2) in Double, from seeds (a, b).
Attributes
- Returns
-
Some(x(n)), orNonefor a non-indexnor a non-finite result (overflow)
The regularised lower incomplete gamma function P(a, x) = γ(a, x) / Γ(a).
The regularised lower incomplete gamma function P(a, x) = γ(a, x) / Γ(a).
The engine of this whole tier, and the reason it is implemented before erf rather than after: the same kernel is the chi-squared and gamma cdfs, and erf falls out of it at full Double accuracy. The obvious alternative — the Abramowitz & Stegun 7.1.26 rational approximation for erf — is accurate to only about 1.5e-7, which would be seven digits in a library whose every other kernel is good to fifteen.
Series expansion for x < a + 1, continued fraction beyond it; that split is where each of the two converges quickly.
Value parameters
- a
-
the shape parameter, which must be strictly positive
- x
-
the argument, which must be non-negative
Attributes
- Returns
-
Some(P(a, x))in[0, 1], orNoneoutside the domain or on non-convergence - See also
Expands e as a Maclaurin polynomial — the Taylor series about zero.
Expands e as a Maclaurin polynomial — the Taylor series about zero.
Sugar over taylorSeries with point = 0, not a separate algorithm; the grammar's maclaurin(e, v, n) desugars to taylor(e, v, 0, n) in the same way log(x) desugars to LogBase(x, 10).
Value parameters
- e
-
the expression to expand
- order
-
the highest power retained
- v
-
the expansion variable
Attributes
- Returns
-
the truncated series, or
Noneunder the same conditions as taylorSeries
The exact multifactorial n!!…! stepping down by k.
The exact multifactorial n!!…! stepping down by k.
k = 1 is the factorial and k = 2 the double factorial, matching multiFactorialOf.
Value parameters
- k
-
the step
- n
-
the argument
Attributes
- Returns
-
Some(n!^(k)), orNonefor a negativen, a non-positivek, or annabove MaxExactFactorial
The multifactorial n!^(k) — the product n · (n−k) · (n−2k) · … down to the last positive term.
The multifactorial n!^(k) — the product n · (n−k) · (n−2k) · … down to the last positive term.
multiFactorialOf(n, 1) is the ordinary factorial and multiFactorialOf(n, 2) the double factorial n!!. Defined here for non-negative integer n and positive integer k only; anything else (including a non-integer n, which has no standard multifactorial) yields None and stays symbolic.
Value parameters
- k
-
the step
- n
-
the argument
Attributes
- Returns
-
Some(n!^(k))when defined and representable,Noneotherwise
Rebuilds e as a sum of like terms collected as a polynomial in v.
Rebuilds e as a sum of like terms collected as a polynomial in v.
Non-polynomial expressions (where collect returns None) are returned unchanged. _ElementWise containers (matrix literals, equations) are processed element-wise.
Value parameters
- e
-
the expression to normalise
- v
-
the polynomial variable
Attributes
- Returns
-
the equivalent expression with like terms folded (e.g.
10x - 2xbecomes8x)
The Padé approximant [m/n] of e about zero: the rational function P/Q with deg P ≤ m, deg Q ≤ n and Q(0) = 1 whose Maclaurin series agrees with e's through order m + n.
The Padé approximant [m/n] of e about zero: the rational function P/Q with deg P ≤ m, deg Q ≤ n and Q(0) = 1 whose Maclaurin series agrees with e's through order m + n.
Often a far better approximation than the Taylor polynomial of the same total degree, because a rational function can model a nearby pole that no polynomial can.
Construction: normalising q₀ = 1, matching the series through order m + n gives the n × n linear system Σ(j = 1..n) q_j·c_{m+k-j} = −c_{m+k} for k = 1..n (with c_i = 0 for i < 0), after which p_k = c_k + Σ(j = 1..min(k,n)) q_j·c_{k-j}.
The system is solved with core._MatrixValue.inverse, not equation.solveSystem: equation imports scalar, so reaching the other way would be a dependency cycle. core is the common layer both can use.
Value parameters
- e
-
the expression to approximate
- env
-
environment in which the coefficients must fold to numbers
- m
-
the numerator degree
- n
-
the denominator degree
- v
-
the variable; free in the result
Attributes
- Returns
-
the rational approximant, or
Nonewhen a degree is out of range, a coefficient will not reduce, or the system is singular (no[m/n]approximant exists in normal form)
Evaluates e over a uniform grid of n points in [lo, hi], returning (x, f(x)) pairs in ascending order, with non-finite results silently dropped.
Evaluates e over a uniform grid of n points in [lo, hi], returning (x, f(x)) pairs in ascending order, with non-finite results silently dropped.
Fast path: if the expression compiles to a Double => Double closure over v (no unresolvable symbolic nodes), every point is evaluated with no per-step allocation. Fallback: evaluates the tree with v bound per step, keeping only _Number results.
Value parameters
- e
-
the expression to sample
- env
-
environment for resolving any other free variables
- hi
-
right endpoint of the sampling range
- lo
-
left endpoint of the sampling range
- n
-
number of grid points (default 200)
- v
-
the free variable that ranges over the grid
Attributes
- Returns
-
(x, f(x))pairs with finite values, in ascendingxorder
The sine integral Si(x) = ∫₀ˣ sin(t)/t dt. Odd; defined on the whole real line.
The sine integral Si(x) = ∫₀ˣ sin(t)/t dt. Odd; defined on the whole real line.
Value parameters
- x
-
the argument
Attributes
- Returns
-
Some(Si(x)), orNonefor a non-finite argument
Substitutes named definitions into an expression, replacing every _Variable whose name appears in definitions with that definition's body, recursively, so chained definitions (g defined in terms of f) resolve in a single call.
Substitutes named definitions into an expression, replacing every _Variable whose name appears in definitions with that definition's body, recursively, so chained definitions (g defined in terms of f) resolve in a single call.
Termination: a seen set breaks reference cycles -- inside the expansion of f, any further occurrence of f is left as a free variable, so self- and mutually-recursive definitions cannot loop.
Binder positions are never substituted: the variable of differentiation / integration (and every other binder -- limit, integral transforms, solveSystem, ode) names the binder, not a use, so substitution must not touch it. No special-casing is needed: binders are excluded from children and carried through by rebuild, so the generic other.rebuild(other.children.map(...)) clause recurses into use positions while preserving every binder. Only the _Variable case performs the actual replacement.
Value parameters
- definitions
-
map from variable name to its replacement body
- e
-
the expression to substitute into
Attributes
- Returns
-
ewith every bound name replaced by its definition
Expands e as a Taylor polynomial in v about point, to and including order order.
Expands e as a Taylor polynomial in v about point, to and including order order.
Σ(k = 0 to order) f⁽ᵏ⁾(point) / k! · (v − point)ᵏ, built from truncated power-series arithmetic (powerSeries, F_0085), the derivative path — each derivative held within MaxDerivativeNodes — taken only for a subexpression the arithmetic does not cover. The result is run through simplifyFully, which collapses the k = 0 term's (v − point)⁰ to 1 and folds the constant coefficients.
point need not be numeric: expanding about a symbolic centre a is meaningful and yields a polynomial in (v − a) with f⁽ᵏ⁾(a) coefficients.
Value parameters
- e
-
the expression to expand
- order
-
the highest power retained; must be in
0 .. MaxTaylorOrder - point
-
the centre of the expansion
- v
-
the expansion variable; it appears free in the result, so it is not a binder in the
_Derivativesense
Attributes
- Returns
-
the truncated series, or
Nonewhen the order is out of range, some coefficient could not be differentiated, or a derivative exceeds MaxDerivativeNodes (taylorDetailedsays which)
The regularised upper incomplete gamma function Q(a, x) = 1 − P(a, x).
The regularised upper incomplete gamma function Q(a, x) = 1 − P(a, x).
Computed directly by the continued fraction where that converges, rather than as 1 − P: for large x, P is within an ulp of 1 and the subtraction would destroy every significant digit of a small Q. This is what lets erfc stay accurate far out in the tail, which is exactly where a survival function is worth having.
Value parameters
- a
-
the shape parameter, which must be strictly positive
- x
-
the argument, which must be non-negative
Attributes
- Returns
-
Some(Q(a, x))in[0, 1], orNoneoutside the domain or on non-convergence
Returns true when e has a value only where v is a whole number (issue F_0044).
Returns true when e has a value only where v is a whole number (issue F_0044).
True exactly when some sum, product or tabulate inside e takes v in one of its bounds: those require a whole bound (indexOf accepts one only at d == Math.floor(d)), so at every other value of v the node stays symbolic and whatever contains it has no value at all. A sampler that grids v continuously therefore misses such an expression almost everywhere — over 0 … 100 at 200 points, at exactly one sample.
The test is structural, and deliberately so. Inferring it from behaviour — noticing that many samples came back empty — cannot tell this apart from a pole or a restricted domain, and would report an ordinary discontinuous function as a grid problem. Reading the shape answers the question that was actually asked.
Only the bounds count. A reduction whose body mentions v is an ordinary continuous function of it (sum(v*k, k, 1, 5) is a polynomial), and the binder itself is not v's business — which is why this cannot be written in terms of freeVars alone.
Value parameters
- e
-
the expression to inspect
- v
-
the variable a caller intends to vary
Attributes
- Returns
-
whether varying
vcontinuously would step outside whereeis defined
Concrete fields
The most nodes one derivative inside a series may have (F_0077).
The most nodes one derivative inside a series may have (F_0077).
The order cap does not bound the work; this does. The k-th derivative of a composite function grows by a factor of 2 to 8.5 per order even simplified, so MaxTaylorOrder = 20 was unreachable for exp(sin(x)) by orders of magnitude. Set on the slowest platform (F_0078's rule, applied to time): a derivative step costs about 4 µs per node on Node against 0.2 µs on the JVM, and one step multiplies the count by up to ~8.5 — so at this budget the worst refusal measured costs ~1.1 s in the browser and well under 0.1 s on the JVM. F_0077 first set 250 000 from the JVM alone, which left a browser refusal at ~15 s — found when the suite's timing test ran on Node. Since F_0085 it bounds only the fallback: the power-series engine computes every covered function without differentiating, and only a subexpression it does not cover (erf, the special functions) pays this cost. A derivative past it makes the series decline with a reason. The default of core.Limit.MaxDerivativeNodes (F_0124).
Attributes
Largest argument the exact factorial family will evaluate.
Largest argument the exact factorial family will evaluate.
A different kind of limit from MaxFactorial, and worth the distinction: 170 is where a Double stops being able to represent the answer, whereas this is where computing it stops being instant. 10000! is a 35 660-digit integer and takes a few milliseconds; a few orders of magnitude more would hang the REPL, and an unbounded fact is exactly the sort of thing a user types by accident. Past the cap the node stays symbolic, the same give-up rule the rest of the library uses. The default of core.Limit.MaxExactFactorial (F_0124): fact, mfact and Gamma pass their environment's value.
Attributes
Largest index computed exactly, past which a sequence node stays symbolic.
Largest index computed exactly, past which a sequence node stays symbolic.
F(10000) is a 2090-digit integer and costs milliseconds by linear iteration; a few orders of magnitude more would hang the REPL. The same "computable in principle is not should be attempted" line MaxExactFactorial draws. Linear iteration is enough under this bound — fast doubling (O(log n)) would only matter if it were raised, and applies to the integer case alone, since arbitrary seeds need the plain recurrence anyway.
The default of core.Limit.MaxExactSequenceIndex (F_0124): the public kernels below apply it, while the sequence nodes pass their environment's value to the …Within forms.
Attributes
The highest integer power expand multiplies out; above it the power stays as written. The default of core.Limit.MaxExpandPower (F_0124).
The highest integer power expand multiplies out; above it the power stays as written. The default of core.Limit.MaxExpandPower (F_0124).
Attributes
The most term pairs one multiplication inside expand may combine, checked before any is built (F_0076): it bounds the time where core.MaxExpressionDepth bounds the size — a sum is a spine as deep as it has terms, so an expansion deeper than the walkers can descend would be built only to crash whatever simplifies it next (F_0078) — since folding can make a large product small. Measured, not round (the MaxMatrixCells rule): on the JVM a 447×447 product (2·10⁵ pairs) takes ~0.45 s and 1000×1000 ~1.5 s, and a browser is several times slower — so the bound sits near half a second where the page freezes while it runs (F_0019). A legitimate expansion needs more only through massive cancellation. The default of core.Limit.MaxExpandWork (F_0124); the Limits overload of expand takes another.
The most term pairs one multiplication inside expand may combine, checked before any is built (F_0076): it bounds the time where core.MaxExpressionDepth bounds the size — a sum is a spine as deep as it has terms, so an expansion deeper than the walkers can descend would be built only to crash whatever simplifies it next (F_0078) — since folding can make a large product small. Measured, not round (the MaxMatrixCells rule): on the JVM a 447×447 product (2·10⁵ pairs) takes ~0.45 s and 1000×1000 ~1.5 s, and a browser is several times slower — so the bound sits near half a second where the page freezes while it runs (F_0019). A legitimate expansion needs more only through massive cancellation. The default of core.Limit.MaxExpandWork (F_0124); the Limits overload of expand takes another.
Attributes
Largest n whose factorial is representable as a finite Double: 170! is about 7.26e306, while 171! overflows to +Infinity.
Largest n whose factorial is representable as a finite Double: 170! is about 7.26e306, while 171! overflows to +Infinity.
Past this bound factorialOf returns None and the AST node stays symbolic, rather than propagating an infinity — the "domain errors stay symbolic" rule the rest of the library follows. Use lgammaOf when a large factorial is wanted in log space.
Attributes
Highest Fourier order fourierSeries will compute.
Highest Fourier order fourierSeries will compute.
Each order costs two definite integrations, so the work is linear in the order but the constant is large (Simpson uses max(precision * 200, 100) intervals per integral). Capped at the same 20 as MaxTaylorOrder and Expand's power cap. The default of core.Limit.MaxFourierOrder (F_0124), which fourierSeries reads from its environment.
Attributes
Upper bound on the number of terms _Tabulate will produce.
Upper bound on the number of terms _Tabulate will produce.
A row of a thousand values is already past what a REPL line can show; the cap exists so a mistyped bound declines instead of building an unbounded matrix, the same reasoning as MaxTruthTableVars. The default of core.Limit.MaxTabulateTerms (F_0124): the three nodes read their environment's value.
Attributes
Highest Taylor order taylorSeries will expand.
Highest Taylor order taylorSeries will expand.
Matches Expand's integer-power cap of 20. It does not bound the work on its own — a composite function's derivatives grow exponentially with the order — which is what MaxDerivativeNodes is for (F_0077). Beyond the cap the _Taylor node stays symbolic. The default of core.Limit.MaxTaylorOrder (F_0124): the series nodes read their environment's value, and so do laurentSeries and padeApproximant.