assignment ame 4053 (1)

22
Module No: AME-4053 Tutor Name: Ms Karthika Verma ASSIGNMENT ___ Numerical Integration 1

Upload: kazimhassan

Post on 25-Sep-2015

217 views

Category:

Documents


0 download

DESCRIPTION

Mechanical 1st year

TRANSCRIPT

Module No: AME-4053

Tutor Name: Ms Karthika Verma

ASSIGNMENT ___ Numerical Integration

Table of Contents

1. Task 1_______________________________3

2. Task 2_______________________________7

3. Task 3_______________________________9

4. Task 4_______________________________11

5. Task 5_______________________________12

6. Bibliography___________________________18

TASK 1

1. Describe fully, with sketches, the Trapezium rule and Simpsons rule methods of numerical integration?

Trapezium rule: The numerical method that approximates the value of a definite integral is called the trapezoidal rule. We consider the definite integral

We assume that f(x) is continuous on [a, b] and we divide [a, b] into n subintervals of equal length x =

Using the n + 1 points,

= a, = a + x, = a + 2x, . . . , = a + nx = b.

We can compute the value of f(x) at these points.

= f(), = f(), = f(), . . . , = f(xn)

We approximate the integral by using n trapezoids formed by using straight line segments between the points (, ) and (, ) for 1 i n as shown in the figure below.

The area of a trapezoid is obtained by adding the area of a rectangle and a triangle

A=

By adding the area of n trapezoids, we obtain the approximation

which simplifies to the trapezoidal rule formula

Simpsons Rule:

It is a very accurate approximation method & it gives the exact area for any polynomial function of degree three or less. In general Simpsons rule gives a much better result than either the midpoint rule or the trapezoid rule. With Simpsons rule, you approximate the area under a curve with curvy-topped trapezoids. The tops of these shapes are sections of parabolas. We can call them trapezoids because they play the same role in Simpsons rule as the true trapezoids play in the trapezoid rule. Simpsons rule is used to find the integral value of any function. It calculates the value of the area under any curve over a given interval by dividing the area into equal parts. It follows the method similar to integration by parts.

Simpsons One third Rule formula is

Simpsons Three eight rule formula is

We divide the area intonequal segments of widthx. The approximate area is given by the following.

Where

In Simpsons rule, n must b even

TASK 2

Q: Apply both the Trapezium rule and Simpsons rule methods to solving the above integral using 8 intervals for each case correct to 3 decimal places

NB Use computerised means to obtain values.

Ans: Trapezium Rule code:

I=[1 2];

f=@(x)1. /x;

m=8;

trapezoid_rule(f,I,m)

Screen-Shot (Trapezoidal rule), MATLAB

Simpsons Rule: (Code)

f=@(x)1./x

a=1;

b=2;

n=8;

l=Simpsons (f, a, b, n);

l

l =

0.6932

Simpsons Rule (Screen-Shot), MATLAB

Task 3

Q: Solve the integral by conventional integration means to obtain an exact value and compare to those obtained numerically.

A: Trapezoidal rule states that

= (f()+ 2f()+ 2f()+... +2f()+ f()),

where x= .

We have that a=1, b=2, n=8.

Therefore, x= =.

Divide interval [1,2] into n=8 subintervals of length x=1/8 with the following endpoints: a=1, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8 , 2=b.

Now, we just evaluate function at those endpoints:

f (x0) =f(a)=f(1)=1=1

2f () =2f (9/8)=16/9=1.77777777777778

2f () =2f (5/4)=8/5=1.6

2f () =2f (11/8)=16/11=1.45454545454546

2f ()=2f (3/2)=4/3=1.33333333333333

2f ()=2f (13/8)=16/13=1.23076923076923

2f ()=2f (7/4)=8/7=1.14285714285714

2f ()=2f (15/8)=16/15=1.06666666666667

f ()=f(b)=f(2)=1/2=0.5

Finally, just sum up above values and multiply by x/2=1/16: 1/16(1+1.77777777777778+1.6+...+1.06666666666667+0.5)=0.69412185037185

Answer: 0.694

SIMPSONS RULE:

It states that:

(f () +4f () +2f () +4f () +2f () +...+4f () +2f () +f()),

where x= .

We have that a=1, b=2, n=8.

Therefore, x= = .

Divide interval [1,2] into n=8 subintervals of length x=1/8 with the following endpoints: a=1, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8 ,2=b.

Now, we just evaluate function at those endpoints:

f () = f(a)= f(1)=1=1

4f () = 4f ( ) = =3.55555555555556

2f () = 2f ( ) = =1.6

4f () = 4f () = =2.90909090909091

2f () = 2f () = =1.33333333333333

4f () = 4f () = =2.46153846153846

2f ()= 2f ( ) = =1.14285714285714

4f () = 4f ()= =2.13333333333333

f () = f(b) =f(2) = =0.5

Finally, just sum up above values and multiply by x / 3 = 1/24: 1/24(1+3.55555555555556+1.6+...+2.13333333333333+0.5) = 0.693154530654531

Answer: 0.693

ASSIGNMENT 2 (TASK 4)

Q: Describe fully, with sketches, the Newton- Raphson method for solving mathematical equation.

Ans: The Newton-Raphson method, or Newton Method, is a powerful technique for solving equations numerically. Like so much of the differential calculus, it is based on the simple idea of linear approximation

The Newton-Raphson method works most of the time if the initial guess is good enough. Sometimes it fails but sometimes you can make it work by changing the initial guess. Lets try to solve x = tan x for x. In other words, we solve f(x) = 0 where f(x) = x tan x. The recursion formula (1) becomes

Lets try an initial guess of = 4. With this initial guess we find that = 6.12016, = 238.40428, = 1957.26490, etc. Clearly these numbers are not converging. We need a new initial guess. Lets try = 4.6. Then we find = 4.54573, = 4.50615, = 4.49417, = 4.49341, = 4.49341, etc. A couple of further iterations will confirm that the digits are no longer changing to 5 decimal places. As a result, we conclude that a root of x = tan x is x = 4.49341 to 5 decimal places.

We want to find the root of an equation f(x) = 0, that is a number r such that f(r) = 0. If f is differentiable near the root, then tangent lines can be used to produce a sequence of approximations to the root that approaches the root quite quickly

The idea is as follows; Make an initial guess at the root, say x = . Draw the tangent line to y = f(x) at (, f()), and find , the x-intercept of this tangent line. Under certain circumstances will be closer to the root than was. The process can be repeated over and over again to get , , ......,getting closer and closer to the root r. We use to represent the x-intercept of the tangent line to y = f(x) at (, f()). The formula for the Newton-Raphson method can be derived as follows. Look at the triangle formed by our tangent estimate to the point x1 in Figure 1. The base of the triangle has length (x0 x1) and the perpendicular height of the triangle is f(). Therefore the angle formed by the tangent line when it intercepts the x-axis at the point is given by

The Newton cotes formula is

=

TASK 5

Q: Apply the Newton- Raphson method for solving the above mathematical equation correct to 2 decimal places with your first approximation r1 = 2.

X3 2x 5 = 0

Ans: As = 2

f(x) = X3 2x 5

f(2) = (2)3 2(2) 5

= 8 4 5

f(2) = -1

Taking the derivative

f/(x) = 3x2 2

f/(2) = 3(2)2 2

f/(2) = 12 - 2

= 10

-

= 2

= 2.1 (Value of

f(x) = X3 2x 5

f(2.1) = (2.1)3 2(2.1) 5

= 9.261 4.2 5

= 0.061

= 3(2.1)2 2

= 11.23

-

= 2.1

= 2.094 (Value of

=

So our Answer is 2.0945

Screen-Shots of Newton Raphson Method

TEXT:

Script 1

function f = myfun(x)

f= x^3-2*x-5;

(Script 1), MATLAB

Script 2

function fd= mydifffun(x)

fd=3*x^2-2;

(Script 2), MATLAB

MATLAB

>> x(1)=2;

for i=1:5;

x(i+1)=x(i)-myfun(x(i))/mydifffun(x(i));

x

end

x =

2.000000000000000 2.100000000000000

x =

2.000000000000000 2.100000000000000 2.094568121104185

x =

2.000000000000000 2.100000000000000 2.094568121104185 2.094551481698199

x =

Columns 1 through 4

2.000000000000000 2.100000000000000 2.094568121104185 2.094551481698199

Column 5

2.094551481542327

x =

Columns 1 through 4

2.000000000000000 2.100000000000000 2.094568121104185 2.094551481698199

Columns 5 through 6

2.094551481542327 2.094551481542327

(Script 3), MATLAB

BIBLIOGRAPHY

Trapezium rule (online) (2015), Available from http://www.mathsrevision.net/advanced-level-maths-revision/pure-maths/calculus/trapezium-rule

Accessed at {16/05/2015}

Trapezium rule (Online) (2015), Available from

http://www.intmath.com/integration/5-trapezoidal-rule.php

Accessed at {16/05/2015}

Simpsons rule (online), (2015) Available from http://mathworld.wolfram.com/SimpsonsRule.html

Accessed at {16/05/2015}

Simpsons rule (online) (2015), Available from http://www.intmath.com/integration/6-simpsons-rule.php

Accessed at {16/05/2015}

Newton Raphson method, (Online) (2015), Available from

http://www.sosmath.com/calculus/diff/der07/der07.html

Accessed at {16/05/2015}

Newton raphson method, (Online) (2015), Available from \

http://mathworld.wolfram.com/NewtonsMethod.html

Accessed at {16/05/2015}

2