# Area under function with rectangles

I'm assigned to write a simple function which gives me the area under x^4 between an interval, but using a series of rectangles instead of a straight integral. I have to write a function that defines the minimum height of these rectangles and another function defining the maximum height, and then find the average value. I am a **total** newbie, so as trivial as it sounds, I've no clue how to define those functions.
I dont know how to make one define minimum heights and the other define maximum, and I don't think what I came up with as a sum of rectangles is correct.

```
def Smin(n):
sum=0
a=0
b=6
width=(b-a)/n
for i in range (1,n+1):
sum=width*(sum+i**4)
return sum
```

Any help will be greatly apreciated.

Homework ?

There are several problems with your function. It takes

`n`

as an arguemt (`def Smin(n)`

) but where do`a`

and`b`

come from? Don't you want to make them argument as well?On the other hand, if you want to integrate

`x^4`

on the interval`[a, b]`

, this is not what your function is doing. What you want to do is something like $h \times \sum_{i=0}^{n} (a + i h)^4$. You should first fix your`Smin`

function (and check that it works). Then, you will be able to improve it by computing lower and upper bounds for the integral using minimum and maximal value inside an interval`[a + ih, a + (i+1)h]`

.The problem your looking at is known as Riemann sums. This Wikipedia entry will give some insight into the functions using minimum heights as well as maximum heights. Since your function is increasing on the interval [0,6], the lower bound of the estimate for the area under the curve is from using the left endpoint. The upper bound for the estimate of the area under the curve is from using the right endpoint. The actual area under the curve will be between the left Riemann sum and the right Riemann sum.