Algosim documentation: ClosedInterval

ClosedInterval

Returns a closed interval of real numbers.

Syntax

Description

Conceptually, ClosedInterval(a, b) returns the closed interval [a, b]. However, there are a few differences between the mathematical object [a, b] and ClosedInterval(a, b).

First, since the mathematical set [a, b] contains an infinite number of real numbers when a < b (the typical case), it cannot be represented as a true Algosim set, since that would require a computer with an infinite amount of memory. Therefore, ClosedInterval(a, b) only returns a finite number of equally spaced numbers from this interval.

Second, the returned object isn’t an Algosim set but a list. This is because lists are easier to work with in practice. Still, Algosim is designed in such a way that you often can think of ClosedInterval(a, b) as the mathematical object [a, b].

Specifically, CloseInterval(a, b, δ) returns the list of all numbers

a, a + δ, a + 2⋅δ, ...

that are less than or equal to b. In particular, if a > b, the empty list is returned and if a = b, the single-element list containing only a is returned. Otherwise, the number of elements depends on δ. If omitted, δ is chosen so that the list contains about 1000 elements.

A synonym for ClosedInterval is interval. Also, the circumfix operator [] is mapped to this function. Hence, ClosedInterval(a, b) can also be written interval(a, b) or [a, b].

Examples

f ≔ t ↦ t⋅❨cos(t), sin(t)❩;
plot([0, 6⋅π] @ f)

Image 1

f ≔ t ↦ (e^sin(t) − 2⋅cos(4⋅t) + sin((2⋅t − π)/24)^5) ⋅ ❨cos(t), sin(t)❩;
plot([0, 100, 0.01] @ f)

Image 2

See also