# stair function - how to

Hi experts!

How can I make a stair function graph?

Thanks a lot!

stair function - how to

Hi experts!

How can I make a stair function graph?

Thanks a lot!

add a comment

1

I am not sure to understand your wish, do you mean something like:

```
sage: plot(floor, 0, 10)
```

0

You can use a sum of `heaviside`

functions.

```
f(x)=heaviside(x)+heaviside(x-1)+heaviside(x-2)+heaviside(x-3)
plot(f(x),(x,0,4),exclude=[0,1,2,3])
```

Or, you can do it with a python function.

```
def step(x):
if (0<x) and (x<1):
return(1)
elif (x<2):
return(2)
elif (x<3):
return(3)
else:
return(4)
plot(lambda x: step(x),(x,0,4),exclude=[0,1,2,3])
```

You could also use the `piecewise`

command.

Asked: **
2013-10-18 01:33:42 -0500
**

Seen: **283 times**

Last updated: **Oct 18 '13**

expand hyperbolic trig functions

substitute expression instead of formal function symbol

Solving large trigonometric fucntions

automatic substitution within functions?

What's wrong with my function syntax?

How to make a function return a value

arithmetic with matrices of formal functions

Why functions are much slower than var in some calculations?

How do I get an ordered list of a symbolic functions arguments?

how to tell if a function is admissible as a 'symbolic' function

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.