• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

Numerical Integration Report

Extracts from this document...

Introduction

Ali Adnan Ahmed

Numerical Integration

08-01-2007

Numerical Integration

Ali Adnan Ahmed

08-01-2007

Abstract:

For functions in Physics that cannot be integrated exactly, it is appropriate to use alternative, numerical techniques to calculate the integral. I examined two of these methods. The Trapezium Rule and Simpson’s Rule. By using the given relationship of the error being inversely proportional to the number of strips to the power of another number, m, I plotted a log-log graph thus calculating that the power when using the Trapezium rule is 1, and the power when using the Simpson’s rule is approximately 3.75. This proves that the Simpson’s rule is a far more accurate way of carrying out numerical integration.

Introduction:

The trapezium rule is a way of estimating the area under a curve. We know that the area under a curve is also given by integration, therefore the trapezium rule can also be used to estimating integrals. This comes in use when it is difficult to find the integral of a function. The Simpson’s Rule works in a similar way to the Trapezium Rule; however it uses polynomials to split the curve rather than just straight lines. Theoretically this should make it a more accurate approximation. To find out to what degree this is true,I a computer program was designed which carried out the Trapezium Rule and Simpson’s Rule, for a given integral, for a specified number of strips.

...read more.

Middle

 0;

For Simpson’s Rule, the main body where the integral was calculated presented more of a challenge.

In principle, as you can see from the formula

I = dx/3 x (y0 + yn + 4(y1 + y3 +….. + yn-1)+ 2(y2 + y4 +…..+ yn-2)

The Simpson’s Rule operates by calculating the sum of the first and last ordinates, y0 and yn, added to FOUR times the sum of the odd ordinates, plus TWICE the sum of the even ordinates.

Therefore two independent loops were used.

do// loop to calculate sum of all the odd ordinates

        {

                y = 4*(1/x);

                sum1 += y;

                x += 2*dx; // ensures that the next x value used remains odd

                c++;

        }

while (x<b);

Above is the first loop, which calculated the sum of the odd ordinates, and stores them into sum1.

The integer variable, c , is an integer counter which has no effect on the calculation in the loop. It is purely present as a ‘’check’’ to ensure that the loop is carried out the correct number of times.

The loop is done until x reaches the upper limit of integration, b.

The second loop looks distinctly similar, however the following is added before it starts, to ensure that the first ordinate used is even.

x1 = a+dx+dx; //ensures only even ordinates are used

The loop that follows is

do// loop to calculate sum of all the even ordinates

        {

                z = 2*(1/x1);

                sum2 += z;

                x1 += 2*dx; // ensures that the next x value used remains even

                d++;

        }

while (x1<b);

...read more.

Conclusion

 std;

int main ()

{

        ofstream simpsons("simpsons rule.txt");

        simpsons.precision(20);//make precision to 20digits

double sum1 = 0.0;

double sum2 = 0.0;

double a, b,dx, x, I,nmax,y,x1, z,error;

int n,c,d;

        cout <<"Enter the Lower limit"<<endl;

        cin >> a;

        cout <<"Enter the upper limit"<<endl;

        cin >> b;

        cout <<"Enter the max number of strips"<<endl;

        cin >> nmax;

        n= 4; // start with n=4 strips

do//loop for continuing number of strips up to N, max number of strips

        {

        dx = (b-a)/(n); //strip height

        x=a+dx;

        c=0; //integer counter check. to see if it is taking the right number of ODD ordinates

do// loop to calculate sum of all the odd ordinates

        {

                y = 4*(1/x);

                sum1 += y;

                x += 2*dx; // ensures that the next x value used remains odd

                c++;

        }

while (x<b);

        x1 = a+dx+dx; //ensures only even ordinates are used

        d = 0; ////integer counter check. to see if it is taking the right number of EVEN ordinates

do// loop to calculate sum of all the even ordinates

        {

                z = 2*(1/x1);

                sum2 += z;

                x1 += 2*dx; // ensures that the next x value used remains even

                d++;

        }

while (x1<b);

        I = (dx/3)* ((1/a) + sum1 + sum2 + (1/b)); //Intergral, I

        error = I - log(10.0); //error calculation

//cout << c << "\t"<<d<<endl; // cout to see if the right number of ordinates are used

        simpsons <<n<<"\t"<< I<<"\t"<<error<<endl;

        sum1 = 0.0;//reset sum1

        sum2 = 0.0;//reset sum2

        n+=10; // add ten strips each time

        }

while (n<=nmax);

return 0;

}

}

Trapezium Rule Flowchartimage00.png

image01.png

Simpson’s Rule

Flowchart

...read more.

This student written piece of work is one of many that can be found in our GCSE Gradient Function section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related GCSE Gradient Function essays

  1. The Gradient Function

    Every time that the place value of a is increased by one, then the curve on x=1, will always run through 1 higher place value of y. I have now put all my results for this set of graphs into a table, which you can find below: The Curve The Gradient Function y=x3 3*x2 y=2x3 (3*x2)

  2. The Gradient Function

    2 I will now test this equation on the above given points X = -2 [Y = 1/x] -a (1/x) 2 = -1(1/-2) 2 = -0.25 X = -2 [Y = -2/x] -a (1/x) 2 = -(2)(1/-2) 2 = 0.5 X = -2 [Y = 3/x] -a(1/x)2 = -(3)(1/-2)

  1. Investigate the elastic properties of a strip of metal (hacksaw blade) and use the ...

    is 0 then after that as been multiplied by the gradient, a2 will also be 0. After these calculations, a small preliminary experiment was carried out to obtain a few pieces of data that would give a rough idea of the Young's Modulus that is to be obtained.

  2. To investigate the effect of the constants a, b and c on the graph ...

    From these graphs, we can make a guess at the changes c will have on a more complex graph like y = ax2 + bx + c. It seems likely that the graph will be moved up and down the y-axis in a similar fashion as before.

  1. I have been given the equation y = axn to investigate the gradient function ...

    For the tangent at x = 3 , 3 X 3(3�) = 54 Therefore the equation is correct which is 3ax� y = x� 2x� 3x� Gradient function 3x� 6x� 9x� Testing: y =6x3 Gradient function for the tangent at x = 2 is 3(6*22 )

  2. I am going to investigate the gradients of different curves and try to work ...

    y = 3x2 I am investigating the changes in gradient for the curve y = 3x2. To plot the curve, I will use the table of values given below. x 0 1 2 3 4 5 6 y 0 3 12 27 48 75 108 I will be working out

  1. In the following coursework, will investigate the gradient functions using the formula y=ax^n, where ...

    -2 y=3x 3 3 y=-3x -3 -3 y=1/2x 1/2 1/2 y=-1/2x -1/2 -1/2 As we can see in the table above, the gradient for the straight line graphs I plotted are equal to the coefficient of x. For example in the equation y=x the coefficient of x is 1 and the gradient is 1.

  2. The Gradient Function

    y1 6.25 4.41 4.0401 4.004001 4.00040001 4.0000400001 Gradient y1-y x1-x 6.25-4 2.5-2 =4.5 4.1 4.01 4.001 4.0001 4.00001 From this we can predict the gradient to be 4 because the numbers behind the decimal point are insignificant. P=(3,9) A1 A2 A3 A4 A5 A6 x1 3.5 3.1 3.01 3.001 3.0001

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work