Professional Documents
Culture Documents
Taylor Series (Q#1-Q#6)
Taylor Series (Q#1-Q#6)
Taylor Series (Q#1-Q#6)
ASSIGNMENT
OF
NUMERICAL METHOD
SUBMITTED TO
SIR JAMIL
SUMERA PASHA
2005-CE-120
SADIA NAZ
2005-CE-155
MADIHA NADEEM
2005-CE-121
DATED:31-10-07
1
Numerical methods
TAYLOR SERIES:
Q#1:
Let f(x) =sinx & apply Theorem 41.
(a). use x0= 0 & fine P5 (x), P7 (x) & P9 (x)
Solution:
When x=0:
f(x) = sinx = 0
f ´(x)= cosx = 1
f ´´(x)= -sinx = 0
f(3)(x) = -cosx = -1
f(4)(x) = sinx = 0
f (5)(x)= cosx = 1
f (6)(x)= -sinx = 0
f (7)(x)= -cosx = -1
f (8)(x)= sinx = 0
f(9)(x)= cosx = 1
Formula:
f(x)≈PN(x)
PN(x)= NΣk=0 fk(x0)(x-x0)k / k!
For P5(x):
For P7(x):
2
Numerical methods
f(x) = 0 + 1(x-0) - (0) (x-0)2/2! - (1) (x-0)3/3! + (0) (x-0)4/4! + (1) (x-0)5/5! +
+ (0) (x-0)6/6! - (1) (x-0)7/7!
For P9(x):
f(x) = 0 + 1(x-0) - (0) (x-0)2/2! - (1) (x-0)3/3! + (0) (x-0)4/4! + (1) (x-0)5/5! +
+ (0) (x-0)6/6! - (1) (x-0)7/7! + (0) (x-0)8/8! + (1) (x-0)9/9!
Q#1(b):
Show that if |x| ≤ 1, then the approximation.
Sin(x) ≈ x – x3/3! + x5/5! - x7/7! + x9/9!
has the error bound |E9(x)| ≤ 1/10! ≤ 2.75574 * 10-7.
Solution:
Error Bound:
|E9(x)| = Rn ≤ M(x-a) n+1/ (n+1)!
R=1, M=sin©
= | sin© (x) (9+1) / (9+1)!|
3
Numerical methods
=1/10!
=2.75574*10-7 ≤ 1
|E9(x)| = 0.000000275574 ≤ 1
Q#2:
Let f(x) =cosx & apply Theorem 41.
(a). use x0= 0 & fine P4 (x), P5 (x) & P6(x)
Solution:
When x=0:
f(x) = cosx = 1
f ´(x)= -sinx = 0
f ´´(x)= -cosx = -1
f(3)(x) = sinx = 0
f(4)(x) = cosx = 1
f (5)(x)= -sinx = 0
f (6)(x)= -cosx = -1
f (7)(x)= sinx = 0
f (8)(x)= cosx = 1
Formula:
f(x)≈PN(x)
PN(x)= NΣk=0 fk(x0)(x-x0)k / k!
4
Numerical methods
For P4(x):
For P6(x):
f(x) = 1 – (0) (x-0) - (1) (x-0)2/2! + (0) (x-0)3/3! + (1) (x-0)4/4! - (0) (x-0)5/5!
- (1) (x-0)6/6!
For P8(x):
f(x) = 1 – (0) (x-0) - (1) (x-0)2/2! + (0) (x-0)3/3! + (1) (x-0)4/4! - (0) (x-0)5/5!
- (1) (x-0)6/6! + (1) (x-0)7/7! + (0) (x-0)8/8!
Q#2(b):
Show that if |x| ≤ 1, then the approximation.
5
Numerical methods
Solution:
Error Bound:
|E8(x)| = Rn ≤ M(x-a) n+1/ (n+1)!
R=1, M=cos©
= | cos© (x) (8+1) / (8+1)!|
= | cos (1)9/9!|
=1/9!
=2.75574*10-6 ≤ 1
|E8(x)| = 0.00000275574 ≤ 1
Q#3:
Does f(x) = x 1/2have a Taylor series expansion about x0 = 0?
Justify your answer. Does the function f(x) = x 1/2have a Taylor series expansion about x0 = 1? Justify
your answer.
Solution:
When x=0:
f(x) = x 1/2 = 0
f ´(x)=(1/2) (x) -1/2= 0
f ´´(x)= (-1/4)( x) -3/2= 0
f(3)(x) = (3/8 )(x) -1/2 = 0
6
Numerical methods
f(x 1/2) = 0 + (0) (x-0) +(0) (x-0)2/2! + (0) (x-0)3/3! + (0) (x-0)4/4!
f(x 1/2) = 0 + 0 + 0 + 0 + 0
f(x 1/2) = 0
Hence,
No Taylor Series.
When x=1:
f(x) = x 1/2 = 1
f ´(x)=(1/2) (x) -1/2= 1/2
f ´´(x)= (-1/4)( x) -3/2= -1/2
f(3)(x) = (3/8 )(x) -1/2 = 3/8
f(4)(x) = (-3/16)(x) -3/2= -3/16
f(x 1/2) = 1 + (1/2) (x-1) - (1/2) (x-1)2/2! + (3/8) (x-1)3/3! - (3/16) (x-1)4/4!
Hence,
It has Taylor Series
7
Numerical methods
Q#4(a):
Find a Taylor Polynomial of degree N=5 for f(x) = 1 / 1+x
Expanded about x0=0.
Solution:
When x=0:
f(x) = 1 / (1+x) = 0
f ´(x)= 1 / (1+x)2 = 1
f ´´(x)= 2 / (1+x) 3 = 2
f(3)(x) = 6/ (1+x)4 = 6
f(4)(x) = 24/ (1+x) 5= 24
f(5)(x) = 120 / (1+x) 6= 120
f(1/1+x) = 0+1(x-0)+(2)(x-0)2/2!+(6)(x-0)3/3!+(24)(x-0)4/4!+(120)(x-0)5/5!
f(1/1+x) = x + x2 + x3 + x4 + x5.
Q#4(b):
Find the Error term E5(x) from the polynomial in part (a).
Solution:
8
Numerical methods
N=5,
f(1/1+x) = x + x2 + x3 + x4 + x5.
f(x)=720
Formula:
M= 720,
a=0,
R6 ≤ 720(x-0)5+1/ (5+1)!
R6 ≤ 720x6/6!
R6 ≤ x6.
Q#6:
Find a Taylor Polynomial of degree N=3 for f(x) = x3–2x2+2x Expanded about x0=1 show f(x) =
P3(x).
Solution:
When x=0:
f(x) = x3-2x2+2x = 1
f ´(x)= 3x2-4x+2 = 1
f ´´(x)= 6x-4= 2
f(3)(x) = 6
For P3(x):
9
Numerical methods
f(x3-2x2+2x) = 1+1(x-1)+(2)(x-1)2/2!+(6)(x-1)3/3!
f(x3-2x2+2x) = 1+ x – 1 + x2 – 2x + 1 + x3 – x2 – 2x2 + 2x + x - 1
Hence,
f(x) = P3(x).
NEWTON POLYNOMIALS:
Q.5) f(x)= x1/2
X= 4.5, 7.5
K Xk F(kx)
0 4 2.00000
1 5 2.23607
2 6 2.44949
3 7 2.64575
4 8 2.82843
Solution:
For 1DD:
F3=f4 – f 3 / x 4- x3 = 0.18268
For 2DD:
F2=f3 – f 2 / x - x2 = -0.0068
For 3DD:
For 4DD:
Newton polynomial:
P(x) = P(4.5)
P(x) = P(7.5)
P1(7.5)= 12.26245
P2(7.5)=12.16335
P3(7.5)=12.11005
P4(7.5)= 12.1153
11
Numerical methods
K Xk F(kx)
0 1.0 3.60
1 2.0 1.80
2 3.0 1.20
3 4.0 0.90
4 5.0 0.72
Solution:
For 1DD:
F2=f3 – f 2 / x 3- x2 = 0.90-1.20/4-3=-0.3
F3=f4 – f 3 / x 4- x3 = 0.70.90/5-3=-0.18
For 2DD:
F0=f1 – f 0 / x 2- x0 =-0.6+1.8/2=0.6
F1=f2 – f 1 / x 3- x1 = -0.3+0.6/2=0.15
F2=f3 – f 2 / x - x2 = -0.18+0.3/5-3=0.06
For 3DD:
12
Numerical methods
F1=f2 – f 1 / x 4- x1 = 0.06-0.75/5-2=-0.03
For 4DD:
Newton polynomial:
P3(x) =3.6 -1.8(x-1) +0.6(x-1)(x-2) -0.15 (x-1)(x-2) (x-3) +0.03(x-1)(x-2) (x-3) (x-4)
P(x) = P(2.5)
P1(2.5)= 0.9
P2(2.5)=1.35
P3(2.5)=1.40625
P4(2.5)=1.423125
P(x) = P(3.5)
P1(3.5)= -0.9
P2(3.5)=1.35
P3(3.5)=1.06785
P4(3.5)= 1.040625
Q.7) f(x)= 3 sin2 (3.142 x/6)
X= 1.5, 3.5
K Xk F(kx)
0 0.0 0.00
1 1.0 0.75
2 2.0 2.25
3 3.0 3.00
4 4.0 2.25
Solution:
13
Numerical methods
For 1DD:
F0=f1 – f 0 / x 1- x0 = 0.75-0/1-0=0.75
F2=f3 – f 2 / x 3- x2 = 3.00-2.25/1=0.75
For 2DD:
For 3DD:
For 4DD:
Newton polynomial:
14
Numerical methods
P(x) = P(1.5)
P1(1.5)= 1.125
P2(1.5)=1.40625
P3(1.5)=1.5
P4(1.5)=1.48245
P(x) = P(3.5)
P1(3.5)= 2.625
P2(3.5)= 4.63125
P3(3.5)=1.35
P4(3.5)= 1.14492
LARGRANGE POLYNOMIALS:
Q 1)Find lagrange polynomials that approximate f(x) =x3
(a) find the linear interpolation polynomial P1(x) using the nodes x0 = -1x
SOLUTION
x fx
-1 -1
0 0
1 1
2 8
15
Numerical methods
SOLUTION
= 1/2 [- x2 + x = x2 + x ]
= ½ (2x)
=x
P2 ( x ) = ax2 + bx2 + c
= 0x2 + x + 0
=x
P2( x ) = x
(c) Find the cubic interpolation polynomial P3( x ) using the nodes x0 = -1 , x1 = 0, x2 = 1, and x3 = 2
(d) Find the linear interpolation polynomial P1( x ) using the nodes x0 = 1 and x 1 , x1 = 2
P1 ( x ) =l0y0 + l1 y1
= {( x – x1 ) /{( x0 _ x1 )} y0 + ( x – x0 ) / ( x1 – x0 ) y1
x F(x)
16
Numerical methods
1 1
2 8
= ( x _ 2 ) (1 )/ ( 1 – 2) + ( x – 1 ) ( 8 ) /( 2 – 1 )
= ( x – 2 ) / ( -1 ) + ( x – 1 ) ( 8 ) / ( 1 )
= - ( x – 2 ) + ( x – 1) 8
=-x +2+8x–8
P1( X ) = 7 X – 6
(e) Find the quadratic interpolation polynomial P2( x ) using the nodes x0 = 0, x1 – 1 , and x2 = 2
P2 ( x ) = x 0 = 0 , x1 = 1 , x = 2
P2 ( x ) = l0y0 + l1y1 + l2 y2
– x0 ) ( x – x1 ) / ( x2 – x0 ) ( x2 – x1 )} ( y2 )
= {( x – 1 ) (x – 2 ) / ( 0 – 1 ) ( 0 – 2 ) } ( 0 ) + ( x – 0 ) ( x – 2 ) / ( 1 – 0 ) ( 1 – 2 )}( 1 ) + ( x – 0 ) ( x
– 1) / ( 2 – 0 ) ( 2 – 1 ) ( 8 )
= 0 + {(x2 – 2x) / (-1)} + {(8x2 – 8x) / (2)}(8)
= -{(x2 – 2x) / (1)} + {(8x-2 – 8x) / (2)}
= (-2x2 + 4x + 8x2 – 8x) / 2
= (6x2 – 4x) / 2
P2(x)= 3x2 – 2x
SOLUTION
Let f(x) = x+2 / x
X0 = 1 , x1 = 2 , x2 = 2.5
F(1.5) = ?
F(1.2) = ?
Quadratic interpolation:
P2(x) = {(x – x1)(x – x2) / (x0 – x1)(x0 – x2)}y0 + {(x – x0)(x – x2) / (x1 – x0)(x1 – x2)}y1+ {(x – x0)(x
– x1) / (x2 – x0)(x2 – x1)}y2
17
Numerical methods
P2(x) = {x – 2)(x – 2.5) / (1 – 2)(1 – 2)}(3) + {(x – 1)(x – 2.5) / (2 – 1)(2 – 2.5)}(3) + (x – 1)(x –
2) / (2 – 1)(2.5 – 2)}(3.3)
= (x2 – 2.5x – 2x + 5) / {(-1)(-1)}](3) + {(x2 – 2.5x – x + 2.5) / (1)(- 0.5)}(3) + {(x2 – 2.5x
– x +2) / (1)(0.5)}(3.3)
= (3x2 – 13.5x + 15) / (1) + 3x2 – 10.5 + 7.5) / (-0.5) + (3..3x2 – 9.9x + 6.6) / (0.5)
f(1.5) = 0.15
2.
(b). Use cubic lagrange interpolation based on the nodes x0 = 0.5, x1= 1, x2 =2, and x3 =2.5 to
approximate f(1.5) and f(1.2)
SOLUTION
Given:
P3(x) = ?
x0= 0.5, x1= 1, x2 =2, and x3 =2.5
f=x+2/x
X F(x)
0.5 4.5
1 3
18
Numerical methods
2 3
2.5 3.3
P3(x) = {(x – x1)(x – x2)(x – x3) / (x0 – x1)(x0 – x2)(x0 – x3)}y0 + {(x – x0)(x – x2)(x
– x3) / (x1 – x0)(x1 – x2)(x1 – x3)}y1 + {(x – x0)(x – x1)(x – x3) / (x2 – x0)(x2 – x1)(x2 – x3)}y2 + {(x –
x0)(x – x1)(x – x2) / (x3 – x0)(x3 – x1)(x3 – x2)}y3
={(x3 – x2x2 – x2x1 + xx1x2 – x2x3 + xx2x3 + xx1x3 – x1x2x3) / (x03 – x02x2 + x1x02 + x0x1x2 – x02x3 +
x0x2x3 + x1x0x3 + x1x2x3)}(4.5)
={(x3 – x2x2 – x2x0 + xx0x2 – x2x3 - xx2x3 + xx0x3 – x0x2x3) / (x13 – x0x12 - x12x2 + x0x1x2 – x12x3 +
x0x1x3 + x1x2x3 – x0x2x3)}(3)
={(x3 – x2x0 – x2x1 + xx0x1 – x2x3 + xx0x3 + xx1x3 – x0x1x3) / (x23 – x22x0 - x1x22 + x1x0x2 – x22x3 +
x2x3x0 + x1x2x3 – x0x1x3)}(3)
= {(x3 – 5.5x2 + 9.5x – 5) / (6)}(4.5) + {(x3 – 5x2 – 5.25x – 2.5) / (0.75)}(3) + {(x3 – 4x+4.25x –
1.25) / (-0.75)}(3) + {(x3 – 0.5x2 + 1x – 4) / (1.5)}(3.3)
= (4.5x3 - 24.75x2 + 42.75x – 22.5) / (6) + {(3x3 – 15x2 – 15.75x – 7.5) / (0.75) + 3x3 – 12x2 +
12.75x – 3.75) / (-0.75) + (3.3x3 – 1.65x2 + 3.3x – 13.2) / (1.5)
f(1.5) = {4.5(1.5)3 – 12(1.5)2 + 42.75(1.5) – 22.5}/ (6) + {3(1.5)3 – 15(1.5)2 – 15.75(1.5) – 7.5} /
(0.75) + 3(1.5)3 – 12(1.5)2 + 12.75(1.5) – 3.75} / (-0.75) + {3.3(1.5)3 – 1.65(1.5)2 + 3.3(1.5) –
13.2} / (1.5)
19