You are on page 1of 33

Taylor Series and Truncation Error

Sunday, 29 November 2020 9:19 PM

Steps:
1. Know the function
2. Know the Xi, Xi+1, and h = Xi+1 - Xi
3. Get the nth order derivative (1st column)
4. Substitute Xi to the derivatives (2nd column)
5. Complete the formula

6. Get Et = true value - approximate value = Xi+1 - Xi


7. Complete the table
Order n f(Xi) Et
0 Per red mark Xi+1 - f(Xi)
1 Per red mark Xi+1 - f(Xi)

NUMMETS Page 1
Bisection Method
Sunday, 29 November 2020 10:04 PM

Algorithm:
1. Determine xl and xu
2. Check if f(xl) * f(xu) < 0
3. Find xm = (xl + xu) / 2
4. If f(xl) * f(xm) < 0, xl = xl xu = xm
f(xl) * f(xm) > 0, xl = xm xu = xu
f(xl) * f(xm) = 0, stop
5. Find new xm
Find absolute relative approximate error
|ɛa| = abs(( xm new - xm old)/xm new) * 100
6. Complete the table and check stopping criteria
# xl xu xm f(xl) f(xu) f(xm) |ɛa|
1 N/A
2

NUMMETS Page 2
False Position Method
Sunday, 29 November 2020 10:42 PM

Algorithm:
1. Determine xl and xu
2. Check if f(xl) * f(xu) < 0
3. Find xr = (xu * f(xl) - xl * f(xu)) / f(xl) - f(xu)
4. If f(xl) * f(xr) < 0, xl = xl xu = xr
f(xl) * f(xr) > 0, xl = xr xu = xu
f(xl) * f(xr) = 0, stop
5. Find new xr
Find absolute relative approximate error
|ɛa| = abs(( xr new - xr old)/xr new) * 100
6. Complete the table and check stopping criteria
# xl xu xr f(xl) f(xu) f(xr) |ɛa|
1 N/A
2

NUMMETS Page 3
Newton-Raphson Method
Sunday, 29 November 2020 11:28 PM

Algorithm:
1. Evaluate f(x) and f'(x)
2. Solve xi+1 = xi - (f(x) / f'(x))
3. Find absolute relative approximate error
|ɛa| = abs(( xi+1 - xi)/xi+1) * 100
4. Complete the table
# x f(x) f'(x) f(xi) |ɛa|
0 xi - - - -
1 xi+1
Suggested:
# x f(x) f'(x) xi+1 |ɛa|
1
2

NUMMETS Page 4
Secant Method
Sunday, 29 November 2020 11:47 PM

Algorithm:
1. Solve xi+1 = xi - ( (f(xi) (xi - xi-1) ) / ( f(xi) - f(x-1) )
2. Find absolute relative approximate error
|ɛa| = abs(( xi+1 - xi)/xi+1) * 100
3. Complete the table
# xi-1 xi xi+1 |ɛa| f(xi+1)
1
2

NUMMETS Page 5
Müller's Method
Monday, 30 November 2020 1:02 AM

Steps:
1. Determine function and x(0), x(1), and x(2) (first column)
2. Solve f(x0), f(x1), and f(x2) (second column)
3. C = f(x2)
4. H0 = x1 - x0
5. H1 = x2 - x1
6. ∆0 = (f(x1) - f(x0)) / x1 - x0
7. ∆1 = (f(x2) - f(x1)) / x2 - x1
8. A = (∆1 - ∆0) / h1 + h0
9. B = (A * h1) + ∆1
10. X3 = x2 + (-2c / (b ± sqr((b^2) - 4ac)))

11. Calculate error


|ɛa| = |(x3 - x2)/x3| x 100
12. If only real roots are being located, choose the original points that are nearest the new root
estimate, x3
If both real and complex roots are estimated, employ a sequential approach just like in secant
method, x1, x2, and x3 to replace x0, x1, and x2

NUMMETS Page 6
Fixed Point Iteration
Monday, 7 December 2020 9:47 AM

Steps:
1. Solve for x as g(x)
2. xi+1 = g(xi)
3. xr - xi+1 = g(xr) - g(xi)
4. Solve for εa (xi)
|ɛa| = abs((new-old)/new) * 100
5. Solve for εt [if true value is given]
|ɛt| = abs((new-true)/new) * 100
6. If more than 1 g(x), use them all
7. Complete the table and check stopping criteria
i Xi g(Xi) ɛa ɛt
1 - -
2
3
4
5 -

NUMMETS Page 7
Bairstow Method
Saturday, 26 December 2020 10:27 PM

NUMMETS Page 8
Naïve Gaussian Method
Saturday, 26 December 2020 10:28 PM

Steps:
1. Determine number of steps: N-1
2. Show two forms
[A][X] = [C]
[A : C]

3. Multiply equation 1 by (reference: eq 1)


4. Subtract product from equation 2
5. Update matrix
6. Multiply equation 2 by
7. Subtract product from equation 3
8. Update matrix
9. Repeat steps to form right triangle (reference: eq 2… and so on)
10. Show new equations in form [UX: Z] = FA1 + EA2 + DA3 = C (optional)
11. Find A3 (last variable)
12. Find A2
13. Find A1 and so on…
14. Show values of A in matrix

NUMMETS Page 9
Gauss Elimination with Partial Pivoting
Saturday, 26 December 2020 10:38 PM

Steps:
1. Determine number of steps: N-1
2. Show two forms
[A][X] = [C]
[A : C]

1. SWAP equations with highest value in Column 1 (absolute value)


2. Multiply equation 1 by (reference: eq 1)
3. Subtract product from equation 2
4. Update matrix
5. Multiply equation 2 by
6. Subtract product from equation 3
7. Update matrix
8. SWAP equations with highest value in Column 2 (absolute value)
9. Repeat steps to form right triangle (reference: eq 2… and so on)
10. Show new equations in form [UX: Z] = FA1 + EA2 + DA3 = C
11. Find A3 (last variable)
12. Find A2
13. Find A1 and so on…
14. Show values of A in matrix

NUMMETS Page 10
Determinant of a Square Matrix
Sunday, 27 December 2020 10:06 PM

Steps:
1. Perform forward elimination with partial pivoting
2. After solving for the upper triangular matrix, solve for the determinant by multiplying the
values in its hypotenuse
B11 x B22 x B33 = det(U) = det(A)

NUMMETS Page 11
LU Decomposition
Sunday, 27 December 2020 10:09 PM

Steps:
1. Show equations in [A][X] = [C] format
2. Solve for upper triangular matrix using forward elimination (without partial pivoting)
3. Solve for lower triangular matrix using the multipliers
L21 =

L31 =

L32 =

4. Write the matrices in the format

[A] = [L][U] =

5. Show [L][Z] = [C]


6. Solve for Z using reverse back substitution
7. Show Z in the format

[Z] = =

8. Show [U][X] = [Z] (X = A)


9. Solve for X using back substitution

[A] = =

Inverse of a Matrix ( [A] -1 )


1. Solve [L][Z] = [C] using reverse back substitution

For 1st column, use as C

For 2nd column, use as C

For 3rd column, use as C

2. Show Z in matrix form


3. Solve [U] = [Z] using back substitution

For 1st column, use [U] = [Z]

For 2nd column, use [U] = [Z]

For 3rd column, use [U] = [Z]

NUMMETS Page 12
For 3rd column, use [U] = [Z]

4. Show ColN in matrix form


5. Repeat steps 1-4 to complete each column
6. Show inverse of [A] in the format

[A] -1 =

NUMMETS Page 13
Gauss-Seidel Method
Monday, 28 December 2020 9:54 PM

Steps:
1. Show equations in [A][X] = [C] format
2. Make sure that A is a diagonally dominant matrix (may use partial pivoting [absolute values])
3. Assume initial guesses in the format

4. Rewrite equations to find a1, a2, and a3


C1 A1 + C2 A2 + C3 A3 = C4
5. Solve a values using initial guesses. Once the previous equations are solved, use the updated
value of a1, a2, and a3
6. Show the new values in the format

7. Solve for the absolute relative approximate error of each a value


|ɛa|n = abs((new - old)/ new) * 100
8. Repeat steps 5-7 using the new initial guesses from previous iteration until the stopping
criteria is reached
9. Fill up the table
# a1 |ɛa|1 % a2 |ɛa|2 % a3 |ɛa|3 %

NUMMETS Page 14
Linear Regression
Monday, 28 December 2020 10:14 PM

Steps:
1. Write equation in y = a0 + a1 x
2. Know n
3. Complete the table
i x y x2 xy
1
2
3
3

i=1

4. Find ∑x, ∑y, ∑x2, and ∑xy


5. Solve for a0 and a1

6. Rewrite first equation with the a0 and a1 values

NUMMETS Page 15
Polynomial Regression
Tuesday, 29 December 2020 11:11 PM

Steps:
1. Write equation in y = a0 + a1 x + a2 x2
2. Know n
3. Complete the table
i x x2 x3 x4 y xy xy2
1
2
3
3

i=1

4. Complete the matrix

5. Perform gaussian method (*clarify kay sir)


6. Rewrite first equation with the a0, a1 and a2 values

NUMMETS Page 16
Exponential Regression
Tuesday, 29 December 2020 11:11 PM

Steps:
1. Write equation = Ae^λ , ln( ) = ln(A) + λ , z = ln , a0 = ln(A), a1 = λ, and z = a0 + a1 x
2. Know n
3. Complete the table
i x y x2 xy
1
2
3
3

i=1

4. Find ∑x, ∑y, ∑x2, and ∑xy


5. Solve for a0 and a1

6. Solve for A = ea0


7. Show λ = a1
8. Rewrite first equation with the A and λ values

NUMMETS Page 17
Trapezoidal Rule of Integration
Thursday, 7 January 2021 4:14 PM

Steps:
1. Write integral and intervals
2. Solve for I

3. Solve for true value


4. Compute for true error
Et = true value - approximate value (I)
5. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100
6. More than 2 values:

Multiple-Segment Trapezoidal Rule


Steps:
1. Write integral, n, a and b
2. Solve for h

3. Solve for I

4. Solve for true value


5. Compute for true error
Et = true value - approximate value (I)
6. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

Table
n Value Et |ɛt|% *|ɛa|%
1 -
2
3

NUMMETS Page 18
Simpson's 1/3rd Rule of Integration
Thursday, 7 January 2021 4:40 PM

Steps:
1. Write integral and intervals
2. Solve for x

3. Solve for true value


4. Compute for true error
Et = true value - approximate value (I)
5. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

Multiple-Segment Simpson's 1/3rd Rule


Steps:
1. Write integral, n, x0 = a and xn = b
2. Solve for h

Find
f(t0) = f(x0)
f(t1) = f(t0 + h)
f(t2) = f(t1 + h)
f(tn) = f(xn)

3. Solve for x

4. Solve for true value


5. Compute for true error
Et = true value - approximate value (I)
6. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

Table
n Value Et |ɛt|%
2
4
6

*** n must always be even

NUMMETS Page 19
Richardson's Extrapolation Formula for Trapezoidal Rule
Thursday, 14 January 2021 11:15 AM

Steps:
1. Construct the table
n Trapezoidal |ɛt|% for Richardson's |ɛt|% for Richardson's
Rule Trapezoidal Rule Extrapolation Extrapolation
1 - -
2
4
8

2. Use Richardson's extrapolation formula to find the true value

3. Solve for true value


4. Compute for true error
Et = true value - approximate value (I)
5. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

NUMMETS Page 20
Romberg Rule of Integration
Thursday, 14 January 2021 11:25 AM

Steps:
1. Construct the table
n Trapezoidal Rule
1 I1,1
2 I1,2
4 I1,3
8 I1,4

2. Use the formula to compute estimated values

3. Solve for true value


4. Compute for true error
Et = true value - approximate value (I)
5. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

NUMMETS Page 21
Gauss Quadrature Rule of Integration
Thursday, 14 January 2021 11:36 AM

Steps:
1. Change the limits of integration from [a, b] to [-1, 1] and solve using the formula given

One-point:

N-point:

2. Get weighting factors and function argument values from the table below
Points Weighting Factors Function Arguments
2 C1 = 1 X1 = -0.57735
C2 = 1 X2 = 0.57735
3 C1 = 0.55555 X1 = -0.77459
C2 = 0.88888 X2 = 0
C3 = 0.55555 X3 = 0.77459
4 C1 = 0.34785 X1 = -0.86113
C2 = 0.65214 X2 = -0.33998
C3 = 0.65214 X3 = 0.33998
C4 = 0.34785 X4 = 0.86113
5 C1 = 0.23692 X1 = -0.90617
C2 = 0.47862 X2 = -0.53846
C3 = 0.56888 X3 = 0
C4 = 0.47862 X4 = 0.53846
C5 = 0.23692 X5 = 0.90617
6 C1 = 0.17132 X1 = -0.93246
C2 = 0.36076 X2 = -0.66120
C3 = 0.46791 X3 = -0.23861
C4 = 0.46791 X4 = 0.23861
C5 = 0.36076 X5 = 0.66120
C6 = 0.17132 X6 = 0.93246

NUMMETS Page 22
3. Solve using the Gauss quadrature formula

Two-point: Ao C1 f(X1) + A1 C2 f(X2)

Three-point: Ao C1 f(X1) + A1 C2 f(X2) + A2 C3 f(X3)

4. Solve for true value


5. Compute for true error
Et = true value - approximate value (I)
6. Compute for absolute relative true error
|ɛt|= | true error / true value | x 100

NUMMETS Page 23
Direct Method
Friday, 22 January 2021 9:54 AM

Linear

Steps:
1. Write v(t) = ao + a1t and t = 16
2. Get values closest to guess
t0 = 15, v(t0) = 362.78
t1 = 20, v(t1) = 517.35

3. Solve
v(15) = ao + a1(15) = 362.78
v(20) = a1 + a1(20) = 517.35

ao = -100.93
a1 = 30.914

v(t) = -100.93 + 30.914 t

v(16) = 393.694

Quadratic

Steps:
1. Write v(t) = ao + a1t + a2t2 and t = 16
2. Get values closest to guess
t0 = 10, v(t0) = 227.04
t1 = 15, v(t1) = 362.78
t2 = 20, v(t2) = 517.35

3. Solve
v(10) = ao + a1(10) + a2(10)2= 227.04
v(15) = ao + a1(15) + a2(15)2 = 362.78
v(20) = a1 + a1(20) + a2(20)2 + + a2(10)3= 517.35

1 1 22
1 22 2
2 1

a0 = 12.05
a1 = 17.733
a2 = 0.3766

v(t) = 12.05 + 17.733 t + 0.3766 t2

v(16) = 392.19

4. Compute for absolute relative true error


|ɛa|= | quadratic - linear / quadratic | x 100

Quadratic

NUMMETS Page 24
Steps:
1. Write v(t) = ao + a1t + a2t2 + a3t3 and t = 16
2. Get values closest to guess
t0 = 10, v(t0) = 227.04
t1 = 15, v(t1) = 362.78
t2 = 20, v(t2) = 517.35
t3 = 22.5, v(t3) = 602.97

3. Solve
v(10) = ao + a1(10) + a2(10)2 + a3(10)3 = 227.04
v(15) = ao + a1(15) + a2(15)2 + a3(15)3 = 362.78
v(20) = a1 + a1(20) + a2(20)2 + a3(20)3 = 517.35
v(22.5) = a1 + a1(22.5) + a2(22.5)2 + a3(22.5)3 = 602.97

a0 = -4.254
a1 = 21.266
a2 = 0.13204
a3 = 0.0054347

v(t) = -4.254 + 21.266 t + 0.13204 t2 + 0.0054347 t3

v(16) = 392.06

4. Compute for absolute relative true error


|ɛa|= | cubic - quadratic / cubic | x 100

NUMMETS Page 25
Newton's Method
Friday, 22 January 2021 10:08 AM

Linear

Steps:
1. Get values closest to guess and t
t0 = 15, v(t0) = 362.78
t1 = 20, v(t1) = 517.35
t= 16

2. Solve
f1(t) = bo + b1 (t - t0)
f1(t) = f(t0) + (t - t0)

f1(t) = 362.78 + 30.914 (t - 15)

f1(16) = 393.694

Quadratic

Steps:
1. Get values closest to guess and t
t0 = 10, v(t0) = 227.04
t1 = 15, v(t1) = 362.78
t2 = 20, v(t2) = 517.35
t = 16

2. Solve
f2(t) = bo + b1 (t - t0) + b2 (t - t0)(t - t1)

f2(t) = f(t0) + (t - t0) + (t - t0)(t - t1)

f2(t) = 227.04 + 27.148 (t - 10) + 0.3766 (t - 10) (t - 15)

f2(16) = 392.1876

3. Compute for absolute relative true error


|ɛa|= | quadratic - linear / quadratic | x 100

Cubic

Steps:
1. Get values closest to guess and t
t0 = 10, v(t0) = 227.04
t1 = 15, v(t1) = 362.78
t2 = 20, v(t2) = 517.35
t3 = 22.5, v(t3) = 602.97
t = 16

2. Solve
f3(t) = bo + b1 (t - t0) + b2 (t - t0)(t - t1) + b3 (t - t0)(t - t1)(t - t2)

f3(t) = f(t0) + (t - t0) + (t - t0)(t - t1) + b3 (t - t0)(t - t1)(t - t2)

NUMMETS Page 26
f3(t) = 227.04 + 27.148 (t - 10) + 0.3766 (t - 10) (t - 15) + 5.4347 x 10-3 (t - 10) (t - 15) (t - 20)

f3(16) = 392.06

3. Compute for absolute relative true error


|ɛa|= | cubic - quadratic / cubic | x 100

NUMMETS Page 27
Lagrange Method
Friday, 22 January 2021 10:22 AM

Linear

Steps:
1. Get values closest to guess and t
t0 = 15, v(t0) = 362.78
t1 = 20, v(t1) = 517.35
t= 16

2. Solve
v(t) = v(t0) + v(t1)

v(16) =

Quadratic

Steps:
1. Get values closest to guess and t
t0 = 10, v(t0) = 227.04
t1 = 15, v(t1) = 362.78
t2 = 20, v(t2) = 517.35
t = 16

2. Solve
v(t) = v(t0) + v(t1) + v(t2)

v(16) =

3. Compute for absolute relative true error


|ɛa|= | quadratic - linear / quadratic | x 100

Cubic

v(t) = v(t0) + v(t1) + v(t2) + v(t3)

NUMMETS Page 28
Spline Method
Friday, 22 January 2021 10:36 AM

Linear

Steps:
1. Get values closest to guess and t
t0 = 15, v(t0) = 362.78
t1 = 20, v(t1) = 517.35
t= 16

2. Solve
v(t) = v(t0) + (t - t0)

v(16) =

NUMMETS Page 29
Euler's Method
Friday, 22 January 2021 10:38 AM

Steps:
1. Write given equation in dy/dx, y(x) = value, and step size, h
2. Transform to f(x,y)
3. Start iteration

i = n, x = value, y = value, h = value

y i + 1 = y i + f(x i, y i) h

4. Update values in equations above

x= x+h

y = y i+1

NUMMETS Page 30
Heun's Method
Sunday, 24 January 2021 8:25 PM

Steps:
1. Write given equation in dy/dx, y(x) = value, and step size, h
2. Transform to f(x,y)
3. Start iteration

i = n, x = value, y = value, h = value

k1 = f(xi, yi)

k2 = f(xi + h, yi + k1 h)

4. Update values in equations above

x= x+h

y = y i+1

NUMMETS Page 31
Midpoint Method
Sunday, 24 January 2021 8:28 PM

Steps:
1. Write given equation in dy/dx, y(x) = value, and step size, h
2. Transform to f(x,y)
3. Start iteration

i = n, x = value, y = value, h = value

k1 = f(xi, yi)

k2 = f(xi + 1/2 h, yi + 1/2 k1 h)

y i + 1 = y i + k2 h

4. Update values in equations above

x= x+h

y = y i+1

NUMMETS Page 32
Ralston Method
Sunday, 24 January 2021 8:31 PM

Steps:
1. Write given equation in dy/dx, y(x) = value, and step size, h
2. Transform to f(x,y)
3. Start iteration

i = n, x = value, y = value, h = value

k1 = f(xi, yi)

k2 = f(xi + 3/4 h, yi + 3/4 k1 h)

4. Update values in equations above

x= x+h

y = y i+1

NUMMETS Page 33

You might also like