You are on page 1of 30

Approximation of Functions

and
Approximate Solution of Differential
Equations
Jayadeep U. B.
M.E.D., NIT Calicut
Ref.: Finite Elements and Approximation, Zienkiewicz,
O. C., and Morgan, K., John Wiley & Sons.

Department of Mechanical Engineering, National Institute of Technology Calicut

Introduction
Why Function Approximation?
Exact variation of the primary variable is not known e.g.,
the temperature profile within an engine block is an unknown
function of spatial coordinates (and possibly of time).
We need the information of variation of field variable to
convert the P.D.E. into a system of algebraic equations, which
can be solved by using computers.
It is preferable to have simplified functions (say polynomials)
representing the field variables Integration, differentiation
etc. can be performed easily.
Before using approximations to solve differential equations,
we have to use them on known functions to ensure
convergence Calibration of the Numerical Procedure.
Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Approximation or Curve Fitting


Given Function
Quadratic
Approximation
Cubic Approximation

What is the basis for Curve Fitting?


Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Methods of Function Approximation


The given function and the approximation function matches
exactly at a finite number of points The Point Collocation
Method.
Minimize the sum of squares of the residual (or error) at each
point in the domain The Least-Square Method.
The various moments of the given function and approximation
function about an axis (say the y-axis) can be made equal.
All these methods can be considered as special cases of a
generalized procedure The Weighted Residual Method.
In the Weighted Residual Method:

)d W R d 0 for l 1, 2,..., M
W
(

- Given Function, - Approximation Function,


Wl - Weights (functions), R - Residual
Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


Examples of Weighting Functions - Polynomials:
y

Constant value Area below


the given and approximating
functions will be equal.

x=0

Linear Functions Similar to the


First Moments of the functions.

x=0

Quadratic Functions
Similar to the Second
Moments of functions

W=const

x=0

x=l
W=

1 -x W = x

x=l x
W1 = 1-x2
W2 = (1+x)
(1-x) 2
W3 = x
x=l x

If we take infinite number of such weighted residuals, any


function can be represented exactly.
Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


The Completeness Requirement As the number M tends to
infinity, we should be able to represent any given function
adequately.
We need to have systematic procedure for generating the
Approximation Function and the Weighting Function.
Weighted residual formulation should give sufficient number
of independent equations to solve for all unknowns in the
approximation function.
A systematic method for generating the approximation
M
function:

; am N m
m 1

at & N m 0 at
N m - Independent Trial (Basis or Shape) Functions
am - The unknown parameters
Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


An example: Express y = x3 for 0 x 1, as a sine series (two
terms).

=x
=x3

N1 = sin(x)
N2 = sin(2x)

; x a1 sin( x) a2 sin(2 x) for 0 x 1


To find out the best approximation, we need to determine the
constants a1 and a2. We can use weighting functions for it.
Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


Hence the weighted residual equations look like:
M

)d W ( a N )d 0 for l 1, 2,..., M
W
(

m m
l
l

m 1

Separating the terms:


M

W N
l

m 1

a d Wl ( )d for l 1, 2,..., M

m m

a1 Wl N1d a2 Wl N 2 d L aM Wl N M d

Wl ( ) d for l 1, 2,..., M

K11 W1 N1d

Lecture - 01

f1 W1 ( )d

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


The weighted residual equations:
M

)d W ( a N )d 0 for l 1, 2,..., M
W
(

m m
l
l

m 1

Leads to a set of M algebraic equations in terms of M


unknowns:

[ K ] a f

(a1 , a2 ,..., aM )

K lm Wl N m d for l , m 1, 2,..., M

f l Wl ( )d for l 1, 2,..., M

Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


In the previous problem, we can consider two weighting
functions to be x and 1-x. Hence, the WR statements are:
1

3
x
x

x a1 sin( x) a2 sin(2 x) dx 0
0

& (1 x) x 3 x a1 sin( x) a2 sin(2 x) dx 0


0

Separating the terms:


1

3
x
a
sin(

x
)

a
sin(2

x
)
dx

x
x

2
1
x dx
1

3
(1

x
)
a
sin(

x
)

a
sin(2

x
)
dx

(1

x
)
x
x dx

1
2

Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Weighted Residual Approximation


Which can be written as:
1

a1 x sin( x)dx a2 x sin(2 x)dx x x 3 x dx


1

a1 (1 x) sin( x) dx a2 (1 x) sin(2 x)dx (1 x) x 3 x dx


Writing in the matrix form:

x sin( x)dx

x sin(2 x)dx

0
0
a 1
1
1
a 2

(1

x
)
sin(

x
)
dx
(1

x
)
sin(2

x
)
dx
0
0

In general:
Lecture - 01

K a f

x x x dx
1

3
(1

x
)
x

x
dx

Department of Mechanical Engineering, National Institute of Technology Calicut

Least Square Method as a Weighted Residual Approxn.


The standard Least Square Method is to minimize:
M

I (a1 , a1 ,K , an ) ( ) d ( am N m ) 2 d
2

m 1

Minimization requires that:

I
0
al

for 1 l M

Substituting:
M
I
2( am N m ) N l d 0
al
m 1

) d 0 for 1 l M
N
(

Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

Least Square Method as a Weighted Residual Approxn.


In this case, we get the Least Square Method as equivalent to
a weighted residual approximation with Nl as the weighting
functions.
In similar manner we can prove for Point Collocation ... (H.W.
Problem Refer book by Zienkiewicz and Morgan)

Lecture - 01

Department of Mechanical Engineering, National Institute of Technology Calicut

The Galerkin Method


In Galerkin method, we use the trial functions themselves as
the weighting functions.
M

W ( )d N ( a
l

m 1

N m )d 0 for l 1, 2,..., M

This results in a set of M algebraic equations in terms of


M unknowns:

[ K ] a f

a (a1 , a2 ,..., aM )
T

K lm N l N m d

for l , m 1, 2,..., M

f l Wl ( )d

for l 1, 2,..., M

The major advantage is that we can get the stiffness matrix to


be symmetric Helps to reduce the computational reqts.
Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

The Galerkin Method - Example


For approximating function using Galerkin method,
Assume that the trial functions used are:

m x

N m sin

for m 1, 2,..., M

The Galerkin Weighted Residual Statement becomes:

Nl ( $)d

l x
sin
x0 L
L

m x

a
sin

dx 0 for l 1, 2,..., M


m 1

The familiar matrix equation is obtained as:


[ K ] a f

(a1 , a2 ,..., aM )

K lm N l N m d

Lecture - 02

x=0

sin

l x
( )d
L

f l sin

l x m x
sin
dx for l , m 1, 2,..., M
L
L

for l 1, 2,..., M

Department of Mechanical Engineering, National Institute of Technology Calicut

The Galerkin Method Example contd.


The stiffness matrix components are:

L
for l m
l x m x
2
K lm sin
sin
dx
L
L
x 0
0 for l m
L

We get the stiffness matrix in diagonal form due to the


Orthogonality Property of trial functions. Calculating the as:

2
m x
am sin
dx 0 for m 1, 2,..., M
L x 0
L
L

This is the truncated Fourier Sine Series representation of the


function .

Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations


Assume a general, linear differential equation, which can be
written as:

L p 0,
where L is a linear differential operator and
p is a function independent of .
For example, consider the 2D steady state heat transfer
equation, assuming constant conductivity:

2 2 Q
2 0
2
x
y
k
2 2
2
2
L 2 2 or L 2 2
x
y
x y
Q
& p
k
Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations: B.C.


The boundary conditions can be written as:

M r 0 on ,
where M is a linear differential operator and
r is a function independent of .

For example, considering the 1D heat transfer problem,


Dirichlet B.C.: 0 on

M or M 1
& r

q 0 on q
x

M k
or M k
x
x
& rq

Neumann B.C. gives: k

Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations contd.


Case 1: D.E. is approximated, B.C. are satisfied exactly.
Substituting the approximation for , the weighted residual
(in D.E.) statement becomes:
R (L$ p ) (L p ) (L$ p )

$
am N m p d 0 for 1 l M
Wl (L p)d Wl L
m 1

Separating the terms:


am N m d Wl L p d for 1 l M
Wl L
m 1

a W L N d W L d W pd
m 1

Lecture - 02

for 1 l M

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations contd.


Expressing in a Matrix form:

K a f

K is not symmetric,
even for the Galerkin
Method.

K lm Wl L ( N m )d

(a1 , a2 ,K , aM )

fl Wl L( ) d Wl p d

Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations contd.


Case 2: Both D.E. & B.C. are approximated
We can choose the approximation:

; am N m
m 1

Substituting the approximation for , the weighted residual


(in D.E.) statement becomes:
R R (L$ p) (L p) in (M$ r ) (M r ) on

$ p)d W l (M$ r )d
W
(
L

am N m p d Wl M
Wl L
m 1

Lecture - 02

am N m
r d 0

m 1

for 1 l M
M

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations cont.


This is a set of algebraic equations:

K a f
K lm Wl L ( N m )d Wl M ( N m )d

a (a1 , a2 ,K , aM )
T

f l Wl p d Wl r d

Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

Solution of Differential Equations cont.


Case 3: D.E. is satisfied exactly, B.C. are approximated
We have to choose the trial functions as the solutions of the
differential equations D.E. is satisfied exactly very
difficult to choose the trial functions.
Not commonly used in F.E.M.

Lecture - 02

Department of Mechanical Engineering, National Institute of Technology Calicut

1D Example The Heat Transfer Problem


Governing Differential Equation:

2 Q
L p 2 + 0
x
k

on 0 x L

Subject to the boundary conditions:

Points (x 0) & (x L)
Let 0 on ( x 0)
and

q
0 on q ( x L)
x k

The Weighted Residual Statement, for 1 l M:

W L$ p dx W M$ r
L

2 $ Q
Wl
dx Wl $
2
x

k
0

Lecture - 03

W M$ r
l

x 0

x 0

x L

q
Wl

x k

0
0
xL

Department of Mechanical Engineering, National Institute of Technology Calicut

1D Example Heat Transfer Problem contd.


Using Galerkin method, Weighted Residual Statement:
Using Wl N l & Wl N l , for 1 l M ,
2 $ Q
N $
N

dx

l
0 x 2 k l

x 0

q
Nl

x k

0
xL

Using approximation for :


M

; $ am N m , with & N m 0; 1 m M on
m 1

M
M


2
Q
q

am N m dx N l
am N m

0 Nl x 2
k
k
m 1
m 1

x
L

Lecture - 03

0
xL

Department of Mechanical Engineering, National Institute of Technology Calicut

1D Example Heat Transfer Problem contd.


Separating the terms:
L

2 M

am N m dx N l
0 Nl x 2
x
m 1


am N m

m 1

M

xL

q
2 Q
Nl
dx N l

2
k

x
0
x k
L

x L

Integrating the first term on LHS by parts:


Nl
x


am N m

m 1

M

xL

x 0

N l


am N m dx N l

m 1


am N m

m 1

xL

q
2 Q
Nl
dx N l

2
k
x
0
x k x L

This equation is called the Weak Form of the weighted


residual statement, since the continuity requirement on trial
function is lesser (first order derivative as against the second
order derivative in the Strong Form - first equation above).
L

Lecture - 03

Department of Mechanical Engineering, National Institute of Technology Calicut

1D Example Heat Transfer Problem contd.


Since the approximation function assumed to be satisfying the
Dirichlet B.C. exactly (i.e., Nm = 0 on for all m):


Nl
x


am N m

m 1

M


Nl

N l

0
xL

am N m

m 1

am N m dx

m 1

q
2 Q
Nl
dx N l

2
k

x
0
x k
L

xL

xL

The equation simplifies to:


L

N l
0 x x

q
2 Q
am N m dx N l
dx N l

2
k
m 1

x
0
x k
M

The weak form automatically satisfies Neumann B.C. Such


a boundary condition is called the Natural Boundary
Condition and the others are termed as Essential B.C.
Lecture - 03

xL

Department of Mechanical Engineering, National Institute of Technology Calicut

1D Example Heat Transfer Problem contd.


This is a set of algebraic equations:

K a f
L

N l N m
K lm
dx
x x
0

(a1 , a2 ,K , aM )

q
2 Q
fl Nl
dx N l

2
k

x
0
x k
L

xL

In this system, the essential B.C. (Dirichlet type) are exactly


satisfied by the approximation function, while the natural B.C.
(Neumann type) are automatically satisfied by the weak
formulation.
The stiffness matrix is symmetric Leads to huge
computational advantage.
Lecture - 03

Department of Mechanical Engineering, National Institute of Technology Calicut

Concluding Remarks
Starting with various approximation methods for functions,
we have seen how it can be used for approximate solution of
differential equations.
Function approximation methods (most of them) can be
considered as special forms of Weighted Residual Statements.
The most commonly used type of weighted residual
formulation is the Galerkin Method the trial functions
themselves are used as the Weighting Functions.
The weighted residual formulation leads to the Strong Form,
which can be integrated by parts (in 1D) to obtain the Weak
Form Continuity requirements on trial functions is weak.
Weak Form of Galerkin Statement leads to Symmetric
Stiffness Matrix and Natural B.C. are automatically satisfied
Trial functions need to satisfy the Essential B.C. only!
Still we are missing one of the most important aspect of
F.E.M. The Discretization!!!
Lecture - 03

Department of Mechanical Engineering, National Institute of Technology Calicut

Assignment 2

Due Date: As announced in the class

Examples 2.2, 2.3, 2.4, 2.5 & 2.6 in the book Finite Elements
and Approximation, by Zienkiewicz and Morgan.
These are solved problems!!! However, all the steps are not
explicitly given in the book. You are expected to do it
completely and submit (e.g. Show how each individual
coefficients used in the matrix equation are obtained!).
Solving these problems should give you a good grip of the
procedure Your understanding of future topics will rely very
much on it!

Lecture - 03

You might also like