Assignment #3 - 91A

# Assignment #3 - 91A

Assignment 3                                    Due  8 February
===========                                     Weight 30
E-Mail to HQR3
!!! NOTE !!!!!!!!                               T.A. Lucie Bernier
Updated 4 Feb 12:30                   Office Hours Mon Fri 13:00 - 15:00
McConnell Room 322  Desk 8

Integration Approximation
-------------------------

For this assignment, you will be given a function f(x) for which
you will have to estimate the area under the curve between the values x=a
and x=b.

We will use the midpoint rule to estimate the integration of
f(x).  We will break the area under the curve into n panels of width h.
The estimated total area under the curve will then be the sum of all the
the area of the n panels.  To estimate the area of a panel we will
compute the area of the rectangle with base h and height equals to the
value of f(x) for x in the midpoint of the interval of width h
considered.  Summing over the n panels then gives the approximation of
f(x) between x=a and x=b.

So if we want to have 10 panels in our estimation, the width h
of our panels will be equal to  (b - a) / 10.  If you start at x0 = a
and x1 = a+h (which correspond the the 2 endpoints of your first panel),
the midpoint estimate of f(x) for this panel is   f (x0 + (x1-x0)/2 ),
or              f (x0 + h/2)       for the first panel.

============ NOTE Correction to Mid point Formula ================

And the area of the first panel is  h * f(x0 + h/2)

============ NOTE Correction to Mid point Formula ================

Therefore the integration approximation of f(x) between x=a and x=b is
given by this formula:
n
----
A =  \     h * f( (x0 + (n-1) * h / 2 )
/
----
i = 1

============ NOTE Correction to Mid point Formula ================

For this assignment you have to approximate the integral of

f(x) = 3*x*x + 4*x + 7  between the values of a=0 and b=10

To estimate the integral use n = 2,5,10 and 20.  Once the
estimation is finished I want you to find out the real value of the
integral.  This is an easy integral so you can find F(x) (the integrated
function of f(x) manually) and then evaluate it for each values of a and
b.  Your output should look like this:

F(x) = ......

Estimation of f(x) between a=0 and b=10:
----------------------------------------

n       Estimation       Real Value       Difference

2         .....             ....              ....
5         ....              ....              ....
10        ....              ....              ....
20        ....              ....              ....

- Read in the values of a and b at the end of your program.
- I do not want to see any goto for such a program.
- Make sure that your variable names are representative of their use.
- Comment your program so someone else can understand what it does.
- Good luck.

your data may look like this:

/DATA
0
10