ceil - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


trunc

truncate a number to the next nearest integer towards 0

round

round a number to the nearest integer

frac

fractional part of a number

floor

greatest integer less than or equal to a number

ceil

smallest integer greater than or equal to a number

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

References

Calling Sequence

trunc(n, x)

round(n, x)

frac(n, x)

floor(n, x)

ceil(n, x)

Parameters

n

-

(optional) any expression, assumed to be a non-negative integer

x

-

any expression

Description

• 

These functions compute integer or fractional parts of numbers.  For real arguments x:

  

For 0x, trunc(x) is the greatest integer less than or equal to x.  For x<0, trunc(x) = -trunc(-x).

  

round(x) rounds x to the nearest integer. In case of a tie (at half-integers), it rounds away from 0.

  

frac(x) is the fractional part of x, that is, frac(x) = x - trunc(x).

  

floor(x) (floor) is the greatest integer less than or equal to x.

  

ceil(x) (ceiling) is the smallest integer greater than or equal to x.

• 

For complex arguments x:

  

trunc(x) = trunc(x) + I*trunc(x)

  

round(x) = round(x) + I*round(x)

  

frac(x) = frac(x) + I*frac(x)

  

For floor(x), let a=xx and let b=xx.  Then floor(x) = floor(x) + I*floor(x) + X, where

  

 

X=0a+b<111a+bandbaI1a+banda<b

  

ceil(x) = -floor(-x)

• 

For all functions, the two-argument case indicates the nth derivative of the function at x.  Except for frac, these derivatives are 0 wherever they are defined.  For frac, the first derivative is 1 wherever it is defined.

• 

If x is a constant, these functions will use evalr() to try to cautiously evaluate x to a floating point number and then apply themselves to the result.  This computation is performed initially at the current setting of Digits, and then if necessary a limited number of times more at higher settings.  If evalr() continues to return a result which is ambiguous with respect to the function being applied, the original function will return unevaluated. In this case, increasing Digits before calling the function may still help in rare cases.

• 

In all other cases, these functions return unevaluated.

Thread Safety

• 

The trunc command is thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

Truncate a number to the nearest integer towards 0.

trunc7

7

(1)

trunc83

2

(2)

trunc2.4

−2

(3)

truncπ

3

(4)

trunc3.5+4.2I

3+4I

(5)

Round a number to the nearest integer.

round7

7

(6)

round83

3

(7)

round2.4

−2

(8)

roundπ

3

(9)

round3.5+4.2I

4+4I

(10)

Fractional part of a number.

frac7

0

(11)

frac83

23

(12)

frac2.4

−0.4

(13)

fracπ

π3

(14)

frac3.5+4.2I

0.5+0.2I

(15)

Greatest integer less than or equal to a number.

floor7

7

(16)

floor83

2

(17)

floor2.4

−3

(18)

floorπ

3

(19)

floor3.5+4.2I

3+4I

(20)

Smallest integer greater than or equal to a number.

ceil7

7

(21)

ceil83

3

(22)

ceil2.4

−2

(23)

ceilπ

4

(24)

ceil3.5+4.2I

4+4I

(25)

More advanced operations.

ceilexp3

21

(26)

truncdiff76.8x&comma;x

76

(27)

roundevalx2+5x9&comma;x=2.1

6

(28)

The functions can be differentiated.

difftruncx&comma;x

trunc1&comma;x

(29)

diffroundx&comma;x

x

(30)

difffracx&comma;x

1trunc1&comma;x

(31)

difffloorx&comma;x

x1

(32)

diffceilx&comma;x

x1

(33)

floor1&comma;3.5

0

(34)

trunc1&comma;243.422

0

(35)

Errors are returned when the functions are not defined:

floor1&comma;5

Error, (in floor) floor is not differentiable at integers

References

  

McDonnell, E.E. "Integer functions of complex numbers, with applications." IBM Philadelphia Scientific Center Tech. Rep. pp. 320-3015. Feb., 1973.

See Also

initialfunctions