fexpr_builtin.h – builtin symbols

This module defines symbol names with a predefined meaning for use in symbolic expressions. These symbols will eventually all support LaTeX rendering as well as symbolic and numerical evaluation (where applicable).

By convention, all builtin symbol names are at least two characters long and start with an uppercase letter. Single-letter symbol names and symbol names beginning with a lowercase letter are reserved for variables.

For any builtin symbol name Symbol, the header file fexpr_builtin.h defines a C constant FEXPR_Symbol as an index to a builtin symbol table. The symbol will be documented as Symbol below.

C helper functions

slong fexpr_builtin_lookup(const char *s)

Returns the internal index used to encode the builtin symbol with name s in expressions. If s is not the name of a builtin symbol, returns -1.

const char *fexpr_builtin_name(slong n)

Returns a read-only pointer for a string giving the name of the builtin symbol with index n.

slong fexpr_builtin_length(void)

Returns the number of builtin symbols.

Variables and iteration

Expressions involving the following symbols have a special role in binding variables.

For

Generator expression. This is a syntactical construct which does not represent a mathematical object on its own. In general, For(x, ...) defines the symbol x as a locally bound variable in the scope of the parent expression. The following arguments ... specify an evaluation range, set or point. Their interpretation depends on the parent operator. The following cases are possible.

Case 1: For(x, S) specifies iteration or comprehension for x ranging over the values of the set S. This interpretation is used in operators that aggregate values over a set. The For expression may be followed by a filter predicate P(x) restricting the range to a subset of S. Examples:

Set(f(x), For(x, S)) denotes \(\{f(x) : x \in S\}\).

Set(f(x), For(x, S), P(x)) denotes \(\{f(x) : x \in S \operatorname{and} P(x)\}\).

Sum(f(x), For(x, S)) denotes \(\sum_{x \in S} f(x)\).

Sum(f(x), For(x, S), P(x)) denotes \(\sum_{x \in S, \, P(x)} f(x)\).

Case 2: For(x, a, b) specifies that x ranges between the endpoints a and b in the context of Sum, Product, Integral, and similar operators. Examples:

Sum(f(n), For(n, a, b)) denotes \(\sum_{n=a}^b f(n)\). The iteration is empty if \(b < a\).

Integral(f(x), For(x, a, b)) denotes \(\int_a^b f(x) dx\), where the integral follows a straight-line path from a to b. Swapping a and b negates the value.

Case 3: For(x, a) specifies that x approaches the point a in the context of Limit-type operator, or differentiation with respect to x at the point a in the context of a Derivative-type operator. Examples:

Derivative(f(x), For(x, a)) denotes \(f'(a)\).

Limit(f(x), For(x, a)) denotes \(\lim_{x \to a} f(x)\).

Case 4: For(x, a, n) specifies differentiation with respect to x at the point a to order n in the context of a Derivative-type operator. Examples:

Derivative(f(x), For(x, a, n)) denotes \(f^{(n)}(a)\).

Where

Where(f(x), Def(x, a)) defines the symbol x as an alias for the expression a and evaluates the expression f(x) with this bound value of x. This is equivalent to f(a). This may be rendered as \(f(x) \; \operatorname{where} x = a\).

Where(f(x), Def(f(t), a)) defines the symbol f as a function mapping the dummy variable t to a.

Where(Add(a, b), Def(Tuple(a, b), T)) is a destructuring assignment.

Def

Definition expression. This is a syntactical construct which does not represent a mathematical object on its own. The Def expression is used only within a Where-expression; see that documentation of that symbol for more examples.

Def(x, a) defines the symbol x as an alias for the expression a.

Def(f(x, y, z), a) defines the symbol f as a function of three variables. The dummy variables x, y and z may appear within the expression a.

Fun

Fun(x, expr) defines an anonymous univariate function mapping the symbol x to the expression expr. The symbol x becomes locally bound within this Fun expression.

Step
Repeat

Booleans and logic

Equal

Equal(a, b), signifying \(a = b\), is True if a and b represent the same object, and False otherwise. This operator can be called with any number of arguments, in which case it evaluates whether all arguments are equal.

NotEqual

NotEqual(a, b), signifying \(a \ne b\), is equivalent to Not(Equal(a, b)).

Same

Same(a, b) gives a (or equivalently b) if a and b represent the same object, and Undefined otherwise. This can be used to assert or emphasize that two expressions represent the same value within a formula. This operator can be called with any number of arguments, in which case it asserts that all arguments are equal.

True

True is a logical constant.

False

False is a logical constant.

Not

Not(x) is the logical negation of x.

And

And(x, y) is the logical AND of x and y. This function can be called with any number of arguments.

Or

Or(x, y) is the logical OR of x and y. This function can be called with any number of arguments.

Equivalent

Equivalent(x, y) denotes the logical equivalence \(x \Leftrightarrow y\). Semantically, this is the same as Equal called with logical arguments.

Implies

Implies(x, y) denotes the logical implication \(x \implies y\).

Exists

Existence quantifier.

Exists(f(x), For(x, S)) denotes \(f(x) \;\text{ for some } x \in S\).

Exists(f(x), For(x, S), P(x)) denotes \(f(x) \;\text{ for some } x \in S \text{ with } P(x)\).

All

Universal quantifier.

All(f(x), For(x, S)) denotes \(f(x) \;\text{ for all } x \in S\).

All(f(x), For(x, S), P(x)) denotes \(f(x) \;\text{ for all } x \in S \text{ with } P(x)\).

Cases

Cases(Case(f(x), P(x)), Case(g(x), Otherwise)) denotes:

\[\begin{split}\begin{cases} f(x), & P(x)\\g(x), & \text{otherwise}\\ \end{cases}\end{split}\]

Cases(Case(f(x), P(x)), Case(g(x), Q(x)), Case(h(x), Otherwise)) denotes:

\[\begin{split}\begin{cases} f(x), & P(x)\\g(x), & Q(x)\\h(x), & \text{otherwise}\\ \end{cases}\end{split}\]

If both \(P(x)\) and \(Q(x)\) are true simultaneously, no ordering is implied; it is assumed that \(f(x)\) and \(g(x)\) give the same value for any such \(x\). More generally, this operator can be called with any number of case distinctions.

If the Otherwise case is omitted, the result is undefined if neither predicate is true.

Case

See Cases.

Otherwise

See Cases.

Tuples, lists and sets

Tuple
List
Set
Item
Element
NotElement
EqualAndElement
Length
Cardinality
Concatenation
Union
Intersection
SetMinus
Subset
SubsetEqual
CartesianProduct
CartesianPower
Subsets

Subsets(S) is the power set \(\mathscr{P}(S)\) comprising all subsets of the set S.

Sets

Sets is the class \(\operatorname{Sets}\) of all sets.

Tuples

Tuples is the class of all tuples.

Tuples(S) is the set of all tuples with elements in the set S.

Tuples(S, n) is the set of all length-n tuples with elements in the set S.

Numbers and arithmetic

Undefined

Undefined

Undefined is the special value \(\mathfrak{u}\) (undefined).

Particular numbers

Pi

Pi is the constant \(\pi\).

NumberI

NumberI is the imaginary unit \(i\). The verbose name leaves i and I to be used as a variable names.

NumberE

NumberE is the base of the natural logarithm \(e\). The verbose name leaves e and E to be used as a variable names.

GoldenRatio

GoldenRatio is the golden ratio \(\varphi\).

Euler

Euler is Euler’s constant \(\gamma\).

CatalanConstant

CatalanConstant is Catalan’s constant \(G\).

KhinchinConstant

KhinchinConstant is Khinchin’s constant \(K\).

GlaisherConstant

GlaisherConstant is Glaisher’s constant \(A\).

RootOfUnity

RootOfUnity(n) is the principal complex n-th root of unity \(\zeta_n = e^{2 \pi i / n}\).

RootOfUnity(n, k) is the complex n-th root of unity \(\zeta_n^k\).

Number constructors

Remark: the rational number with numerator p and denominator q can be constructed as Div(p, q).

Decimal

Decimal(str) gives the rational number specified by the string str in ordinary decimal floating-point notation (for example -3.25e-725).

AlgebraicNumberSerialized
PolynomialRootIndexed
PolynomialRootNearest
Enclosure
Approximation
Guess
Unknown

Arithmetic operations

Pos
Neg
Add
Sub
Mul
Div
Pow
Sqrt
Root

Inequalities

Less
LessEqual
Greater
GreaterEqual
EqualNearestDecimal

Sets of numbers

NN

NN is the set of natural numbers (including 0), \(\mathbb{N}\).

ZZ

ZZ is the set of integers, \(\mathbb{Z}\).

QQ

QQ is the set of rational numbers, \(\mathbb{Q}\).

RR

RR is the set of real numbers, \(\mathbb{R}\).

CC

CC is the set of complex numbers, \(\mathbb{C}\).

Primes

Primes is the set of positive prime numbers, \(\mathbb{P}\)

IntegersGreaterEqual

IntegersGreaterEqual(x), given an extended real number x, gives the set \(\mathbb{Z}_{\ge x}\) of integers greater than or equal to x.

IntegersLessEqual

IntegersLessEqual(x), given an extended real number x, gives the set \(\mathbb{Z}_{\le x}\) of integers less than or equal to x.

Range

Range(a, b), given integers a and b, gives the set \(\{a, a+1, \ldots, b\}\) of integers between a and b. This is the empty set if a is greater than b.

AlgebraicNumbers

The set of complex algebraic numbers \(\overline{\mathbb{Q}}\).

RealAlgebraicNumbers

The set of real algebraic numbers \(\overline{\mathbb{Q}}_{\mathbb{R}}\).

Interval

Interval(a, b), given extended real numbers a and b, gives the closed interval \([a, b]\).

OpenInterval

OpenInterval(a, b), given extended real numbers a and b, gives the open interval \((a, b)\).

ClosedOpenInterval

ClosedOpenInterval(a, b), given extended real numbers a and b, gives the closed-open interval \([a, b)\).

OpenClosedInterval

OpenClosedInterval(a, b), given extended real numbers a and b, gives the closed-open interval \((a, b]\).

RealBall

RealBall(m, r), given a real number m and an extended real number r, gives the the closed real ball \([m \pm r]\) with center m and radius r.

OpenRealBall

OpenRealBall(m, r), given a real number m and an extended real number r, gives the the open real ball \((m \pm r)\) with center m and radius r.

OpenComplexDisk

OpenComplexDisk(m, r), given a complex number m and an extended real number r, gives the open complex disk \(D(m, r)\) with center m and radius r.

ClosedComplexDisk

ClosedComplexDisk(m, r), given a complex number m and a real number r, gives the closed complex disk \(\overline{D}(m, r)\) with center m and radius r.

UpperHalfPlane

UpperHalfPlane is the set \(\mathbb{H}\) of complex numbers with positive imaginary part.

UnitCircle
BernsteinEllipse
Lattice

Infinities and extended numbers

Infinity

Infinity is the positive signed infinity \(\infty\).

UnsignedInfinity

UnsignedInfinity is the unsigned infinity \(\tilde \infty\).

RealSignedInfinities

RealSignedInfinities is the set of real signed infinities \(\{+\infty, -\infty\}\).

ComplexSignedInfinities

ComplexSignedInfinities is the set of complex signed infinities \(\{e^{i \theta} \cdot \infty : \theta \in \mathbb{R}\}\).

RealInfinities

RealInfinities is the set of real infinities (signed and unsigned) \(\{+\infty, -\infty\} \cup \{\tilde \infty\}\).

ComplexInfinities

ComplexInfinities is the set of complex infinities (signed and unsigned) \(\{e^{i \theta} \cdot \infty : \theta \in \mathbb{R}\} \cup \{\tilde \infty\}\).

ExtendedRealNumbers

ExtendedRealNumbers is the set of extended real numbers \(\mathbb{R} \cup \{+\infty, -\infty\}\).

ProjectiveRealNumbers

ProjectiveRealNumbers is the set of projectively extended real numbers \(\mathbb{R} \cup \{\tilde \infty\}\).

SignExtendedComplexNumbers

SignExtendedComplexNumbers is the set of complex numbers extended with signed infinities \(\mathbb{C} \cup \{e^{i \theta} \cdot \infty : \theta \in \mathbb{R}\}\).

ProjectiveComplexNumbers

ProjectiveComplexNumbers is the set of projectively extended complex numbers (also known as the Riemann sphere) \(\mathbb{C} \cup \{\tilde \infty\}\).

RealSingularityClosure

RealSingularityClosure is the Calcium singularity closure for real functions, encompassing real numbers, signed infinities, unsigned infinity, and undefined (u). This set is defined as \(\mathbb{R}_{\text{Sing}} = \mathbb{R} \cup \{+\infty, -\infty\} \cup \{\tilde \infty\} \cup \{ \mathfrak{u} \}\).

ComplexSingularityClosure

ComplexSingularityClosure is the Calcium singularity closure for complex functions, encompassing complex numbers, signed infinities, unsigned infinity, and undefined (u). This set is defined as \(\mathbb{C}_{\text{Sing}} = \mathbb{C} \cup \{e^{i \theta} \cdot \infty : \theta \in \mathbb{R}\} \cup \{\tilde \infty\} \cup \{ \mathfrak{u} \}\).

Operators and calculus

Sums and products

Sum
Product
PrimeSum
PrimeProduct
DivisorSum
DivisorProduct

Solutions and zeros

Zeros
UniqueZero
Solutions
UniqueSolution

Extreme values

Supremum
Infimum
Minimum
Maximum
ArgMin
ArgMax
ArgMinUnique
ArgMaxUnique

Limits

Limit
SequenceLimit
RealLimit
LeftLimit
RightLimit
ComplexLimit
MeromorphicLimit
SequenceLimitInferior
SequenceLimitSuperior
AsymptoticTo

Derivatives

Derivative
RealDerivative
ComplexDerivative
ComplexBranchDerivative
MeromorphicDerivative

Integrals

Integral

Complex analysis

Path
CurvePath
Poles
IsHolomorphicOn
IsMeromorphicOn
Residue
ComplexZeroMultiplicity
AnalyticContinuation

Matrices and linear algebra

Matrix
Row
Column
RowMatrix
ColumnMatrix
DiagonalMatrix
Matrix2x2
ZeroMatrix
IdentityMatrix
Det
Spectrum
SingularValues
Matrices
SL2Z
PSL2Z
SpecialLinearGroup
GeneralLinearGroup
HilbertMatrix

Polynomials, series and rings

Pol
Ser
Polynomial
Coefficient
PolynomialDegree
Polynomials
PolynomialFractions
FormalPowerSeries
FormalLaurentSeries
FormalPuiseuxSeries
Zero
One
Characteristic
Rings
CommutativeRings
Fields
QuotientRing
FiniteField
EqualQSeriesEllipsis
IndefiniteIntegralEqual
QSeriesCoefficient
Call
CallIndeterminate

Special functions

Number parts and step functions

Abs
Sign
Re
Im
Arg
Conjugate
Csgn
RealAbs
Max
Min
Floor
Ceil
KroneckerDelta

Primes and divisibility

IsOdd
IsEven
CongruentMod
Divides
Mod
GCD
LCM
XGCD
IsPrime
Prime
PrimePi
DivisorSigma
MoebiusMu
EulerPhi
DiscreteLog
LegendreSymbol
JacobiSymbol
KroneckerSymbol
SquaresR
LiouvilleLambda

Elementary functions

Exp
Log
Sin
Cos
Tan
Cot
Sec
Csc
Sinh
Cosh
Tanh
Coth
Sech
Csch
Asin
Acos
Atan
Acot
Asec
Acsc
Asinh
Acosh
Atanh
Acoth
Asech
Acsch
Atan2
Sinc
LambertW

Combinatorial functions

SloaneA
SymmetricPolynomial
Cyclotomic
Fibonacci
BernoulliB
BernoulliPolynomial
StirlingCycle
StirlingS1
StirlingS2
EulerE
EulerPolynomial
BellNumber
PartitionsP
LandauG

Gamma function and factorials

Factorial
Binomial
Gamma
LogGamma
DoubleFactorial
RisingFactorial
FallingFactorial
HarmonicNumber
DigammaFunction
DigammaFunctionZero
BetaFunction
BarnesG
LogBarnesG
StirlingSeriesRemainder
LogBarnesGRemainder

Orthogonal polynomials

ChebyshevT
ChebyshevU
LegendreP
JacobiP
HermiteH
LaguerreL
GegenbauerC
SphericalHarmonicY
LegendrePolynomialZero
GaussLegendreWeight

Exponential integrals

Erf
Erfc
Erfi
UpperGamma
LowerGamma
IncompleteBeta
IncompleteBetaRegularized
LogIntegral
ExpIntegralE
ExpIntegralEi
SinIntegral
SinhIntegral
CosIntegral
CoshIntegral
FresnelC
FresnelS

Bessel and Airy functions

AiryAi
AiryBi
AiryAiZero
AiryBiZero
BesselJ
BesselI
BesselY
BesselK
HankelH1
HankelH2
BesselJZero
BesselYZero
CoulombF
CoulombG
CoulombH
CoulombC
CoulombSigma

Hypergeometric functions

Hypergeometric0F1
Hypergeometric1F1
Hypergeometric1F2
Hypergeometric2F1
Hypergeometric2F2
Hypergeometric2F0
Hypergeometric3F2
HypergeometricU
HypergeometricUStar
HypergeometricUStarRemainder
Hypergeometric0F1Regularized
Hypergeometric1F1Regularized
Hypergeometric1F2Regularized
Hypergeometric2F1Regularized
Hypergeometric2F2Regularized
Hypergeometric3F2Regularized

Zeta and L-functions

RiemannZeta
RiemannZetaZero
RiemannHypothesis
RiemannXi
HurwitzZeta
LerchPhi
PolyLog
MultiZetaValue
DirichletL
DirichletLZero
DirichletLambda
DirichletCharacter
DirichletGroup
PrimitiveDirichletCharacters
GeneralizedRiemannHypothesis
ConreyGenerator
GeneralizedBernoulliB
StieltjesGamma
KeiperLiLambda
GaussSum

Elliptic integrals

AGM
AGMSequence
EllipticK
EllipticE
EllipticPi
IncompleteEllipticF
IncompleteEllipticE
IncompleteEllipticPi
CarlsonRF
CarlsonRG
CarlsonRJ
CarlsonRD
CarlsonRC
CarlsonHypergeometricR
CarlsonHypergeometricT

Elliptic, theta and modular functions

JacobiTheta
JacobiThetaQ
DedekindEta
ModularJ
ModularLambda
EisensteinG
EisensteinE
DedekindSum
WeierstrassP
WeierstrassZeta
WeierstrassSigma
EllipticRootE
HilbertClassPolynomial
EulerQSeries
DedekindEtaEpsilon
ModularGroupAction
ModularGroupFundamentalDomain
ModularLambdaFundamentalDomain
PrimitiveReducedPositiveIntegralBinaryQuadraticForms
JacobiThetaEpsilon
JacobiThetaPermutation

Nonsemantic markup

Ellipsis

Ellipsis renders as \(\ldots\) in LaTeX. It can be used to indicate missing function arguments for display purposes, but it has no predefined builtin semantics.

Parentheses

Parentheses(x) semantically represents x, but renders with parentheses (\(\left(x\right)\)) when converted to LaTeX.

Brackets

Brackets(x) semantically represents x, but renders with brackets (\(\left[x\right]\)) when converted to LaTeX.

Braces

Braces(x) semantically represents x, but renders with braces (\(\left\{x\right\}\)) when converted to LaTeX.

AngleBrackets

AngleBrackets(x) semantically represents x, but renders with angle brackets (\(\left\langle x\right\rangle\)) when converted to LaTeX.

Logic

Logic(x) semantically represents x, but forces logical expressions within x to be rendered using symbols instead of text.

ShowExpandedNormalForm

ShowExpandedNormalForm(x) semantically represents x, but displays the expanded normal form of the expression instead of rendering the expression verbatim. Warning: this triggers a nontrivial (potentially very expensive) computation.

Subscript