Ceiling and Floor functions

Just to give some idea of what these guys can do! Let's start with their basic behavior. Ceiling rounds up, and Floor rounds down:

Ceiling[1.5]
Floor[1.5]
Ceiling[1]
Floor[1]

Here's a plot of the floor function, from -3 to 10:

Plot[Floor[x],{x,-3,10}]

But we can't tell what's going on at the endpoints!

Let's create the endpoints, which I will want to use to distinguish the end on which the particular function has a value, and the end on which it does not:

xs=Table[i,{i,-3,10}] (*This is a comment, as indicated by the parentheses and asterix. *)
(* The xs are the endpoints where the functions jump -- at integer values. The Table function allows me to create a list of integer values from -3 to 10 by ones. *)
ys=xs; (* because x=y for the steps: meaning that Floor[x]=x and Ceiling[x]=x *)

ListPlot is a plot routine for point data. But it's expecting a list of pairs, rather than a pair of lists!

pairs=Transpose[{xs,ys}] (* The Transpose command takes a pair of lists and turns it into a list of pairs (or vice versa): *)
ListPlot[pairs]

The Show command let's me put two plots together, superimposing one on the other. So here's a better picture of the Floor function, because it shows off the endpoint behavior:

Show[
Plot[Floor[x],{x,-3,10}],
ListPlot[pairs]
]

Show[
Plot[Ceiling[x],{x,-3,10}],
ListPlot[pairs]
]

Now, as promised, here's our Postal Rate function. Do you see why it’s called a step function?:)

postalRates[x_]:=.49+.21Ceiling[x-1]
xs=Table[i,{i,0,10}]; (* We're only interested in positive weights *)
Show[
Plot[postalRates[x],{x,0,10},AxesOrigin->{0,0},AxesLabel->{"Weight (oz)","Cost ($)"},PlotLabel->"Postal Rates"],
ListPlot[Transpose[{xs,postalRates[xs]}]]
]