Академический Документы
Профессиональный Документы
Культура Документы
A . . Harmattan Semester, 2011-2012 Session PRACTICAL LAB II CSC 307: Numerical Computations I
Contents
1 Laboratory Assignment II 1.1 Task 01: Canonical Polynomials . . . . . . . 1.2 Task 02: Horners Polynomials . . . . . . . . 1.3 Task 03: Root of Polynomials . . . . . . . . 1.4 Task 04: Evaluating Function as Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 4 5 6 6 7
Laboratory Assignment II
During our lectures, we have seen that polynomials provide an efcient means of representing some mathematical expressions. We have also seen that most trigonometric, hyperbolic, and exponential functions can be expressed in the form of polynomial. The accurate, efcient and effective evaluation of polynomials are therefore important in the development of computational solution to scientic and engineering problems. A polynomial of degree n is written as: Pn (x) = a0 x0 + a1 x1 + a2 x2 +, . . . , +a(n1) x(n1) + an xn Equation 1 can also be written in the form:
n
(1)
Pn (x) =
i=0
ai xi
(2)
Equation 1 and 2 are called the Canonical, Nave, Series or Sequential form of polynomial expression. The values ai , i = 0, 1, 2, . . . , n are the parameters of the polynomial and x is the variable (independent). A polynomial of degree one, i.e. n = 1, is called linear (it describes a line function or relation). Polynomials with degree two or more, i.e. when (n 2), are called non-linear functions. Specic names for polynomial commonly used in engineering applications are listed in Table 1. Table 1: Polynomial Nomenclature Degree 1 2 3 4. Name Linear Quadratic Cubic Quatic Representation a0 + a1 x a0 + a1 x + a2 x2 a0 + a1 x + a2 x2 + a3 x3 a0 + a1 x + a2 x2 + a3 x3 + a4 x4
Polynomials are frequently used in engineering problem description, modelling and simulation. This is because they exhibit a number of unique properties which include the following [2, 1, 3]: 1. Polynomials are smooth. 2. Polynomials are easy to store and manipulate on a digital computer. To store polynomials, we only need to store the coefcients (i.e. the ai s) and one variable (i.e. x). To manipulate polynomials we require only basic arithmetic operations of addition (+), subtraction (-) and multiplication (*). 3. The derivative and integral of a polynomial will produce another polynomial whose coefcient can be computed algebraically. 4. The root of a polynomial can be easily computed using an algorithm. 5. Given a continuous function or a set of values over a closed interval, say [a, b], it is possible to nd a polynomial to model or represent it. 6. Most engineering problems can be expressed as a polynomial of suitable degree n.
Linear y = a0 + a1x x
3. Write the programme to implement the algorithm you designed for Equation 1 using Plato Fortran and Octave.
Table 2: Algorithm for Canonical Polynomial Evaluation ____________________________________________________ START: " i => Index of the coefficient array " n => Degree of the polynomial " A[n] => Array element n " P => The result of the polynomial computations INTEGER i,n REAL A[n], X, P READ n READ A[i], i <- 0, n P = A[0] For i <- 1, n P <- P + A[i] * Xn NEXT i WRITE P END: ____________________________________________________
Table 3: Algorithm for Horners Polynomial Evaluation ____________________________________________________ START: " i => Index of the coefficient array " n => Degree of the polynomial " A[n] => Array element n " P => The result of the polynomial computations INTEGER i,n READ n REAL A[n], X, P READ A[i], 0 <- 1,n P = A[n] For i <- 1, n P <- P*X + A[n-i] NEXT i WRITE P END: ____________________________________________________
1.3
Remember also that Equation 1 can be expressed as Equation 4. Pn (x) = (x x0 )(x x1 )(x x2 ), . . . , (x xn1 )(x xn ) or, in the short form
n
(4)
Pn (x) =
i=0
(x xi )
(5)
In Equation 4 and 5, x0 , x1 , . . . , xn are the roots of the polynomial. A root is a value which when you substitute into an equation, the result will be zero. This value corresponds to the point of stability or equilibrium of the system represented by the polynomial. Equation 5 requires n multiplications and n subtractions. Note that the computational load of the subtraction operation is more than that of addition, usually by a factor of 1.5. 1. Design the solution algorithm for Equation 4 using owchart and pseudo-code. 2. Write the programme to implement the algorithm you designed in 1. using Plato Fortran and Octave. Nota that, the programme you developed in Task 3 could be used to explore the root of the system modelled by Equation 1.
Engineering Application
As stated in the previous sections, most scientic and engineering models can be represented using polynomials. Some general problems have been studied and the numerical methods for their theoretical solution using polynomials have been developed. Examples of such polynomials include [4]: Chebychev polynomials, Laguerre polynomials and Hermite polynomials. For example, the second-order differential equation is useful in modelling the behaviour of a number of dynamic systems commonly encountered in engineering. The Laguerre form of such equation is given by d2 y dy + (1 x) + ny = 0.0 (6) dx2 dx In Equation 6, y is the dependent variable and x is the independent variable and n is a positive integer. The solution to this problem is a set of polynomial, which are x
orthogonal. Six of the Laguerre polynomials, which solves the model in Equation 6, are as listed in Equations 7 through 12: L0 (x) = 1.0 L1 (x) = 1.0 x L2 (x) = L3 (x) = L4 (x) = 1 2 (x 4.0x + 2.0) 2! (7) (8) (9) (10) (11)
L5 (x) =
(12)
References
[1] J. G. Bronson. Algorithm Development and program design using C, volume 1. West Publishing Company, 1996. [2] U. Manber. Introduction to Algorithms: A creative approach, volume 1. AddisionWesley, 1989. [3] K. H. Rosen. Discrete Mathematics and Its Application, volume 5th . McGraw-Hill Higher Education, United States, 2003. [4] F. Scheid. Schaums Outline of Theory and Problems of Numerical Analysis. McGraw-Hill Publishing, New Delhi, 2nd edition, 2006.
Function ex
Table 4: Polynomial Representation of Some Functions Polynomial expression (n terms) x3 x4 x5 x2 1.0 + x + + + + ... = 2! 3! 4! 5!
n i=0
xi i!
cos x
1.0
(1)i
i=0
x2i 2i!
sin x
(1)i
i=0
sinh x
x+
n i=1
cosh x
1.0 +
n i=1
x(2i) (2i)!
1.0 (1.0 x)
1.0 + x + x2 + x3 + x4 + x5 , . . . =
i=0
xi