Skip to content

Ceil ​

The least integer greater than or equal to x: ⌈x⌉\lceil x \rceil.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaFloor and ceiling functionsMathWorldCeilingFunctionWikidataQ215193FungrimCeil✓Fungrim entrya3a253✓Wolfram LanguageCeiling!
Ceil(x)the least integer ≥x\ge x, ⌈x⌉\lceil x \rceil.
SageMathenumeratio_ceil(x)SymPyceiling(x)mpmathceil(x)Oscarceil(BigInt, x)Juliaenumeratio_ceil(x)Rustceil(x)
Ceil(x, step)the least multiple of step at or above x.
Typed signatures
TypePackageApplies
(x: real | signed_infinity | ~oo, step: real?) -> real | signed_infinity | ~ooanalyticreplaces compute-enginealways
(x: real | signed_infinity | ~oo, step: real?) -> real | signed_infinity | ~oocompute-enginealways
(any, any?) -> anystructuresreplaces analyticalways

Domain: Arithmetic

Details
  • The least integer ≥x\ge x: ⌈x⌉\lceil x \rceil.
  • Rounds toward +∞+\infty, not toward 0 -- so ⌈−3.7⌉=−3\lceil -3.7 \rceil = -3, not −4-4.
  • For a non-integer x, ⌈x⌉=⌊x⌋+1\lceil x \rceil = \lfloor x \rfloor + 1. See Floor.
  • Agrees with Floor exactly on integers.
  • Threads element-wise over a list.
  • A second argument rounds up to the nearest multiple of it -- the step needn't be an integer.
  • The second argument is a step, a multiple to ceil to, as in Wolfram's Ceiling[x, a]: Ceil(226,10)=230\mathrm{Ceil}(226, 10) = 230. Round's second argument is a step too. Round breaks ties to even, as Wolfram does (see Round).

Examples

3 more kept as data, checked against the oracles
Basic #
live ↗
In⌈72⌉\lceil\frac{7}{2}\rceilOut44
live ↗
In⌈3.2⌉\lceil3.2\rceilOut44

Integers pass through unchanged

live ↗
In⌈5⌉\lceil5\rceilOut55

Threads element-wise over a list

live ↗
In⌈[1.2,−1.2,3.7]⌉\lceil\bigl\lbrack1.2, -1.2, 3.7\bigr\rbrack\rceilOut[2,−1,4]\bigl\lbrack2, -1, 4\bigr\rbrack
live ↗
In⌈2.4⌉\lceil2.4\rceilOut33
live ↗
In⌈2.6⌉\lceil2.6\rceilOut33
Scope #

Stays symbolic

live ↗
In⌈x⌉\lceil x\rceilOut⌈x⌉\lceil x\rceil

Exact radicals are decided numerically

live ↗
In⌈50⌉\lceil\sqrt{50}\rceilOut88

Evaluates at an exact constant: ⌈π⌉=4\lceil\pi\rceil = 4

live ↗
In⌈π⌉\lceil π\rceilOut44

A second argument rounds up to a multiple of it -- the next multiple of 10 above 226

live ↗
InCeil(226,10)\mathrm{Ceil}(226, 10)Out230230

...the step needn't be an integer: 3.5⋅⌈−10.3/3.5⌉=−73.5 \cdot \lceil -10.3/3.5 \rceil = -7

live ↗
InCeil(−10.3,3.5)\mathrm{Ceil}(-10.3, 3.5)Out−7.0-7.0

...nor rational: 2π−e≈3.572\pi - e \approx 3.57 rounds up to the multiple 15/415/4 of 5/45/4

live ↗
InCeil(2π−e,54)\mathrm{Ceil}(2π-e, \frac{5}{4})Out154\frac{15}{4}

Rounds the real and imaginary parts up separately

live ↗
In⌈5.37−1.3i⌉\lceil5.37-1.3i\rceilOut6−i6-i

Threads entrywise over a matrix

live ↗
In⌈[[12,−1],[0,−12]]⌉\lceil\bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, -\frac{1}{2}\bigr\rbrack\bigr\rbrack\rceilOut[[1,−1],[0,0]]\bigl\lbrack\bigl\lbrack1, -1\bigr\rbrack, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack

As a matrix function it agrees with entrywise ceil on a triangular matrix

live ↗
InMatrixFunction(Ceil,[[12,−1],[0,−12]])\mathrm{MatrixFunction}(\mathrm{Ceil}, \bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, -\frac{1}{2}\bigr\rbrack\bigr\rbrack)Out[[1,−1],[0,0]]\bigl\lbrack\bigl\lbrack1, -1\bigr\rbrack, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack

An integer is its own ceiling

live ↗
In⌈0⌉\lceil0\rceilOut00

Infinity passes through

live ↗
In⌈∞⌉\lceil∞\rceilOut∞∞

Two-argument ceil to a multiple of 2: a branch per multiple, the last the default

live ↗
InPiecewiseExpand(Ceil(x,2),0<x<4)\mathrm{PiecewiseExpand}(\mathrm{Ceil}(x, 2), 0\lt x\lt4)OutPiecewise([[2,x≤2]],4)\mathrm{Piecewise}(\bigl\lbrack\bigl\lbrack2, x≤2\bigr\rbrack\bigr\rbrack, 4)
live ↗
Ind⌈x⌉dx\frac{\mathrm{d}\lceil x\rceil}{\mathrm{d}x}Out00
Applications #

How many 5-seat vans are needed to carry 17 people

live ↗
In⌈175⌉\lceil\frac{17}{5}\rceilOut44

Ten bits are enough to number 1000 items, ⌈log⁡21000⌉\lceil \log_2 1000 \rceil

live ↗
In⌈log⁡2(1 000)⌉\lceil\log_{2}(1\,000)\rceilOut1010
Properties #

⌈x⌉=⌊x⌋+1\lceil x \rceil = \lfloor x \rfloor + 1 for non-integer x. See Floor

live ↗
In⌈72⌉=⌊72⌋+1\lceil\frac{7}{2}\rceil=\lfloor\frac{7}{2}\rfloor+1OutTrue\mathrm{True}

Floor and Ceil agree exactly on integers

live ↗
In⌈5⌉=⌊5⌋\lceil5\rceil=\lfloor5\rfloorOutTrue\mathrm{True}

Smallest multiple of 3 that is at least 16

live ↗
InCeil(16,3)\mathrm{Ceil}(16, 3)Out1818

⌈x2⌉\lceil x^2\rceil where x2x^2 rises: each branch is bounded by square roots

live ↗
InPiecewiseExpand(⌈x2⌉,0<x<2)\mathrm{PiecewiseExpand}(\lceil x^2\rceil, 0\lt x\lt2)OutPiecewise([[1,x≤1],[2,1<x≤21/2],[3,21/2<x≤31/2]],4)\mathrm{Piecewise}(\bigl\lbrack\bigl\lbrack1, x≤1\bigr\rbrack, \bigl\lbrack2, 1\lt x≤2^{1/2}\bigr\rbrack, \bigl\lbrack3, 2^{1/2}\lt x≤3^{1/2}\bigr\rbrack\bigr\rbrack, 4)

Rational generating function of the round-up-to-4 sequence

live ↗
InGeneratingFunction(Ceil(n,4),n,x)\mathrm{GeneratingFunction}(\mathrm{Ceil}(n, 4), n, x)Out4xx5−x4−x+1\frac{4x}{x^5-x^4-x+1}

Integers are fixed points

live ↗
In⌈1⌉\lceil1\rceilOut11

Known value · Wolfram MathematicalFunctionData, Ceiling

A negative integer is unchanged

live ↗
In⌈−1⌉\lceil-1\rceilOut−1-1

Known value · Wolfram MathematicalFunctionData, Ceiling

The imaginary part −1-1 is already an integer

live ↗
In⌈−i⌉\lceil-i\rceilOut−i-i

Known value · Wolfram MathematicalFunctionData, Ceiling

Rounds up: ⌈2.3⌉=3\lceil 2.3\rceil = 3

live ↗
In⌈2310⌉\lceil\frac{23}{10}\rceilOut33

Known value · Wolfram MathematicalFunctionData, Ceiling

Negative integers are fixed

live ↗
In⌈−3⌉\lceil-3\rceilOut−3-3

Known value · Wolfram MathematicalFunctionData, Ceiling

Nested ceilings: the inner one is expanded first, then the outer one over its pieces

live ↗
InPiecewiseExpand(⌈x+13+⌈1−x/2⌉3⌉,x∈R∧−1<x<1)\mathrm{PiecewiseExpand}(\lceil x+\frac{1}{3}+\lceil1-x/2\rceil^3\rceil, x∈ℝ∧-1\lt x\lt1)OutPiecewise([[2,0≤x≤2/3],[3,2/3<x],[8,x≤−1/3]],9)\mathrm{Piecewise}(\bigl\lbrack\bigl\lbrack2, 0≤x≤2/3\bigr\rbrack, \bigl\lbrack3, 2/3\lt x\bigr\rbrack, \bigl\lbrack8, x≤-1/3\bigr\rbrack\bigr\rbrack, 9)

Rounds toward +∞+\infty: ⌈−π⌉=−3\lceil -\pi\rceil = -3

live ↗
In⌈−π⌉\lceil-π\rceilOut−3-3

Known value · Wolfram MathematicalFunctionData, Ceiling

Negative rationals round up toward zero

live ↗
In⌈−2710⌉\lceil-\frac{27}{10}\rceilOut−2-2

Known value · Wolfram MathematicalFunctionData, Ceiling

Negative infinity passes through

live ↗
In⌈−∞⌉\lceil-∞\rceilOut−∞-∞

Known value · Wolfram MathematicalFunctionData, Ceiling

Complex input: each part rounds up, 3−2i3-2i

live ↗
In⌈2310−ie⌉\lceil\frac{23}{10}-ie\rceilOut3−2i3-2i

Known value · Wolfram MathematicalFunctionData, Ceiling

live ↗
In⌈i⌉\lceil i\rceilOutii

Known value · Wolfram MathematicalFunctionData, Ceiling

Possible issues #

Rounds toward +∞+\infty, not toward 0: ceil(-3.7) is -3, not -4

live ↗
In⌈−3.7⌉\lceil-3.7\rceilOut−3-3

NaN propagates rather than erroring

live ↗
In⌈NaN⁡⌉\lceil\operatorname{NaN}\rceilOutNaN⁡\operatorname{NaN}
About
Examples42
Checked againstWolfram Language 41 agree1 differSageMath 31 agree1 unevaluated1 errorSymPy 33 agree1 unevaluatedmpmath 15 agree1 errorOscar 16 agreeJulia 26 agree4 errorRust 22 agree1 error
CrosswalkWikipediaMathWorldWikidataFungrimFungrim entryWolfram LanguageSageMathSymPympmathOscarJuliaRust

Implementation

mappedoscarpackages/oracle/src/mappings.ts
mappedwolframpackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts
mappedmpmathpackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts

See also: Floor, Round