lec 8 gauss spline

87
COMPUTATIONAL METHODS & STATISTICS MTH 2212 LECTURER DR ZAHARAH WAHID EXT 4514, ROOM E1-4-8- 13

Upload: aiman-roslan

Post on 02-Nov-2015

224 views

Category:

Documents


0 download

DESCRIPTION

for gaus spline and statistic

TRANSCRIPT

  • COMPUTATIONAL METHODS&STATISTICSMTH 2212LECTURERDR ZAHARAH WAHIDEXT 4514, ROOM E1-4-8-13

  • Solution of Linear Systems of Equation-Chap. 9

    Gaussian Elimination Pitfalls in Gauss Elimination Pivoting Scaling

  • Applications :Computational Methods (CMs) are mathematical methods used to

    Find and approximate solution for mathematical problemFit a curve (design the function) for the given tabulated data.Find the roots of nonlinear algebraic equations.Find optimum solution for optimization or mathematical programming problem.Find differentiation and integration numericallyFind the numerical solution of partial differential equations. Find the numerical solution of initial value and boundary value problems.

  • Computational Methods (CMs) are mathematical methods are used to

    Problem

    MathematicalModel

    modelingAnalyticalMethodsComputational(Numerical)MethodsExact(True)(Real) (Fixed)SolutionApproximateSolution

  • Algebraic Linear EquationsAn equation with variables of power one.. .

    Where as = constant coefficients, bs = constants, n = number of equation x = variableThere are no Trigonometric functionsLogarithmic functionsExponent functionsHyperbolic functions

  • Linear system has the general formA set of n equations and n unknowns. .

  • Nave Gaussian EliminationA method to solve simultaneous linear equations of the form [A][X]=[C]

    Solution two stages1. Forward Elimination2. Back Substitution

  • Linear system-Matrix Form

  • Forward EliminationThe goal of forward elimination is to transform the coefficient matrix into an upper triangular matrix

  • Forward EliminationA set of n equations and n unknowns . . . . . .

    (n-1) steps of forward elimination

  • ER0-Elem. Row Operations

  • ER0-Elem. Row Operations

  • ER0-Elem. Row OperationsBacksubst.

  • Forward EliminationStep 1 For Equation 2, divide Equation 1 by and multiply by .

  • Forward Elimination Subtract the result from Equation 2._________________________________________________or

  • Forward EliminationRepeat this procedure for the remaining equations to reduce the set of equations as . .. . .. . .. End of Step 1

  • Step 2Repeat the same procedure for the 3rd term of Equation 3.Forward Elimination . . . . . . End of Step 2

  • Forward EliminationAt the end of (n-1) Forward Elimination steps, the system of equations will look like . . . . . . End of Step (n-1)

  • Matrix Form at End of Forward Elimination

  • Back SubstitutionSolve each equation starting from the last equationExample of a system of 3 equations

  • Back Substitution Starting Eqns . . . . . .

  • Back SubstitutionStart with the last equation because it has only one unknown

  • Back Substitution

  • Example 1The upward velocity of a rocket is given at three different timesThe velocity data is approximated by a polynomial as:Find the velocity at t=6 seconds .Table 1 Velocity vs. time data.

    Time, Velocity, 5106.88177.212279.2

  • Example 1 Cont. AssumeResults in a matrix template of the form:Using data from Table 1, the matrix becomes:

  • Example 1 Cont.

    Forward EliminationBack Substitution

  • Forward Elimination

  • Number of Steps of Forward EliminationNumber of steps of forward elimination is (n-1)=(3-1)=2

  • Divide Equation 1 by 25 and

    multiply it by 64, .Forward Elimination: Step 1.Subtract the result from Equation 2Substitute new equation for Equation 2

  • Forward Elimination: Step 1 (cont.).Divide Equation 1 by 25 and

    multiply it by 144, .Subtract the result from Equation 3Substitute new equation for Equation 3

  • Forward Elimination: Step 2Divide Equation 2 by 4.8

    and multiply it by 16.8,

    .Subtract the result from Equation 3Substitute new equation for Equation 3

  • Back Substitution

  • Back SubstitutionSolving for a3

  • Back Substitution (cont.)Solving for a2

  • Back Substitution (cont.)Solving for a1

  • Nave Gaussian Elimination Solution

  • Example 1 Cont.SolutionThe solution vector isThe polynomial that passes through the three data points is then:

  • Pitfalls of Nave Gauss EliminationPossible division by zeroLarge round-off errors

  • Pitfall#1. Division by zero Caused by coefficient value equals zero or very close to zero.

    This can be solved by using pivoting technique

  • Pitfall#1. Division by zero

  • Is division by zero an issue here?

  • Is division by zero an issue here? YESDivision by zero is a possibility at any step of forward elimination

  • Pitfall#2. Large Round-off Errors

    This may be due to some of theFollowing : Large number of equations to be solved due to the fact that every result is dependent on previous results Errors in early steps will tend to propagate.

  • Pitfall#2. Large Round-off ErrorsSolve it on a computer using 6 significant digits with chopping

  • Pitfall#2. Large Round-off ErrorsSolve it on a computer using 5 significant digits with choppingIs there a way to reduce the round off error?

  • Pitfall#2. Large Round-off ErrorsExact Solution

  • Avoiding PitfallsGaussian Elimination with Partial PivotingAvoids division by zeroReduces round off error

  • Gauss Elimination with Partial Pivoting

  • PivotingThis involves the following steps Determine the largest coefficient available in the column below the pivot element. Switch the rows so that the largest element is the pivot element. This is known as partial pivoting.If column as well as rows are searched for the largest element & then switched, the process is called complete pivoting.

  • What is Different About Partial Pivoting?At the beginning of the kth step of forward elimination, find the maximum ofIf the maximum of the values is in the p th row,then switch rows p and k.

  • % :

    Significant figures 3 0.667-3.33109940.66670.000010050.666670.300001060.6666670.330000170.66666670.3330000 0.1

  • This case is much less sensitive to the number of significant figures on the result due to With partial pivoting

    Significant figures (%)30.6670.3330.140.66670.33330.0150.666670.333330.00160.6666670.3333330.000170.66666670.33333330.00001

  • Matrix Form at Beginning of 2nd Step of Forward Elimination

  • Example (2nd step of FE)Which two rows would you switch?

  • Example (2nd step of FE)Switched Rows

  • Forward EliminationSame as nave Gauss elimination method except that we switch rows before each of the (n-1) steps of forward elimination.

  • Example: Matrix Form at Beginning of 2nd Step of Forward Elimination

  • Matrix Form at End of Forward Elimination

  • Back Substitution Starting Eqns . . . . . .

  • Back Substitution

  • Gauss Elimination with Partial PivotingExample

  • Example 2

    Solve the following set of equations by Gaussian elimination with partial pivoting

  • Example 2 Cont.

    Forward EliminationBack Substitution

  • Forward Elimination

  • Forward Elimination: Step 1Examine absolute values of first column, first row and below.

    Largest absolute value is 144 and exists in row 3. Switch row 1 and row 3.

  • Forward Elimination: Step 1 (cont.).Divide Equation 1 by 144 and

    multiply it by 64, .Subtract the result from Equation 2Substitute new equation for Equation 2

  • Forward Elimination: Step 1 (cont.).Divide Equation 1 by 144 and

    multiply it by 25, .Subtract the result from Equation 3Substitute new equation for Equation 3

  • Forward Elimination: Step 2Examine absolute values of second column, second row and below.

    Largest absolute value is 2.917 and exists in row 3. Switch row 2 and row 3.

  • Forward Elimination: Step 2 (cont.).Divide Equation 2 by 2.917 andmultiply it by 2.667, Subtract the result from Equation 3Substitute new equation for Equation 3

  • Back Substitution

  • Back SubstitutionSolving for a3

  • Back Substitution (cont.)Solving for a2

  • Back Substitution (cont.)Solving for a1

  • Gaussian Elimination with Partial Pivoting Solution

  • Gauss Elimination with Partial PivotingAnother Example

  • Partial Pivoting: Example 2Consider the system of equationsIn matrix form = Solve using Gaussian Elimination with Partial Pivoting using five significant digits with chopping

  • Partial Pivoting: ExampleForward Elimination: Step 1Examining the values of the first column|10|, |-3|, and |5| or 10, 3, and 5The largest absolute value is 10, which means, to follow the rules of Partial Pivoting, we switch row1 with row1.Performing Forward Elimination

  • Partial Pivoting: Example 2Forward Elimination: Step 2Examining the values of the first column|-0.001| and |2.5| or 0.0001 and 2.5The largest absolute value is 2.5, so row 2 is switched with row 3Performing the row swap

  • Partial Pivoting: Example 2Forward Elimination: Step 2

    Performing the Forward Elimination results in:

  • Partial Pivoting: cont..Back SubstitutionSolving the equations through back substitution

  • Partial Pivoting: ExampleCompare the calculated and exact solutionThe fact that they are equal is coincidence, but it does illustrate the advantage of Partial Pivoting

  • Scaling Necessary when different units are used in the same system of equations

    WHY- to standardize the size of the coefficient in the system of equations- Minimize the round-off errors caused by having larger coefficient than others.

  • Example 3Use three significant figures to solve

    (1)(2)Gauss elimination with scaling & pivotingGauss elimination without scaling and with pivotingNaive Gauss elimination

  • 1. Gauss elimination with scaling and pivoting:Scaling:

    0.00002x 1 + x2 = 0.1(1) x1 + x 2 = 2 (2)Pivoting x 1 + x 2 = 2 (1) 0.00002x 1 + x 2 = 0.1 (2)Forward elimination x1 + x2 = 2 x2 = 0.1Back substitution x1= 1.90 and x2 = 0.10

  • 2. Gauss elimination without scaling and with pivoting:

    Pivoting x 1 + x 2 = 2 (1) 2x1 + 100000x 2 =10000 (2)Forward elimination x1 + x2 = 2 100000 x2 =10000Back substitution x1= 1.90 and x2 = 0.10

  • 3. Gauss elimination

    Forward elimination 2 x1 +100000 x2 = 10000 100000 x2 =10000Back substitution x1= 1.90 and x2 = 0.10

  • ExerciseSolve the unknown variables with partial pivoting

  • THE END

    **************************************************************************************************