Ask Your Question

Revision history [back]

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.

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)
sum=width*(sum+i**4)
    return sum

sum

Any help will be greatly apreciated.