0% found this document useful (0 votes)
338 views5 pages

5.exploration With CAS-I.Lab5

The document provides instructions for writing Scilab code to estimate errors in functions' Taylor series approximations and to compare functions to their Taylor series expansions by plotting, including calculating the error between e^x and its Taylor series approximation at x=1 and between sinx and its Taylor series approximation at x=π/2. Algorithms are given for estimating errors and plotting functions against Taylor series approximations up to a given order n.

Uploaded by

Yash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
338 views5 pages

5.exploration With CAS-I.Lab5

The document provides instructions for writing Scilab code to estimate errors in functions' Taylor series approximations and to compare functions to their Taylor series expansions by plotting, including calculating the error between e^x and its Taylor series approximation at x=1 and between sinx and its Taylor series approximation at x=π/2. Algorithms are given for estimating errors and plotting functions against Taylor series approximations up to a given order n.

Uploaded by

Yash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment-5:

Objectives:
To write a SCILAB -CODE
5.1. To find the error in estimated value (yest) of
a function f(x) at a point x using its Taylor
series.
5.2. To compare a function f(x) and its Taylor
series expansion using 2d plots.
Excercises

Write a Scilab code in a script file:


5.1.1. To find the error in estimating the value of function f(x)=ex at x=1
using its Taylor series expansion about origin.
5.1.2. To find the error in estimating the value of function f(x)=sinx at
x=pi/2 using its Taylor series expansion about origin.

5.2.1. To compare the function f(x)=ex and its Taylor series expansion
about origin by using 2d plots
5.2.2. To compare the function f(x)=sinx and its Taylor series
expansion about origin by using 2d plots
Name Details
4.1.parametric form of some 2d curves Examples

Function Notation f(x) f(x)=ex


Characterised by a rule, Domain(x Domain=(-∞, ∞)
values) and Range( f(x) values )
Range=(0, ∞)

Power c0+c1(x-a)+c2(x-a)2+ c3(x-a)3+…



Series x 2 x3 xn
=  1  x    ...  
2! 3! n 0 n !
 cn ( x  a )n
Characterised
n0 by centre, convergence, Centre a=0,
interval of convergence Converges for -∞<x< ∞
Taylor f(x)=c0+c1(x-a)+c2(x-a)2+ c3(x-a)3+… Taylor series about 0
Series
2 3  n
x x x
e 1 x   ...  
x
f ( n ) (a) 2! 3! n0 n!
c0  f ( a ), cn  , n  1, 2,...
n! x3 x5  n x2n1
Converges ...
sinxx  for (1) ∞
-∞<x<
3! 5! n0 (2n1)!
Algorithm for error estimation
• 1. write commands clc , clear,
• 2. enter the value of the centre of power series a
• 3. Enter the value of x at which we want to estimate the vaule of
function
• 4. write equation of curve y=f(x), e.g. y=e^x
• 5. enter n the order of the power series
• 6. Initialize yest=0
• 7. // to write the Taylor series formula
• for i=0 to n
write the formula for Taylor series of yest
end
8. error =abs(y-yest)
display error
Algorithm for plotting function and its
Taylor series
• 1. write commands clc , clear, clf
• 2. write the range of x variable using command linspace
• 3. write equation of curve y=f(x), e.g. y=e^x
• 4. plot(x,y)
• 5. enter n the order of the power series
• 6. Initialize yest=0
• 7. for i=0 to n
write the formula for Taylor series of yest
end
8. error =abs(y-yest)
display error
9. plot(x,yest)
10. use the commands xtitle and legend

You might also like