Scientific Computing
Finite Differences
• In our last lecture we looked at the oldest, and perhaps the simplest, method for solving the
Poisson Equation – the method of Finite
Differences using the 2 nd order Centered difference formula.
• While this method is suitable for a wide range of problems, it suffers from the restriction of the domain being rectangular in shape.
Finite Element Method
• The Finite Element Method was developed to address this problem. This method can handle a variety of complex domain geometries.
• In this method, we do not approximate derivatives to find a solution.
• Rather, we change the problem to an associated minimization principle from the
Calculus of Variations .
Calculus of Optimization
• Recall from single variable calculus:
• Continuous functions must take extreme values on a bounded domain.
• A necessary condition for an extremum at x
0
, if f is differentiable, is f’(x
0
)=0
Calculus of Optimization
• For scalar multi-variable functions F(x) = F(x
1
, . . . , x n
) how do we find an extremal value?
• Consider the function g(t) = F(x + t v) = F(x
1
+ t v
1
, . . . , x n
+ t v n
) where v is some non-zero vector. If x is an extremum for F, then d/dt g(t)| t=0
= 0
Calculus of Optimization
• Using the chain rule, we get: g ' ( t )
d dt
F ( x
1
tv
1
, , x n
tv n
)
F
x
1
( x
t v ) v
1
F
x n At t=0:
0
g ' ( 0 )
F
x
1
( x ) v
1
F
x n
( x ) v n
F ( x ) v
This equation must be true for all vectors v.
( x
t v ) v n
• Thus, if F has an extremum at x, then
F ( x )
0
Calculus of Variations
• In the calculus of variations, we extend this optimization principle from optimizing functions to optimizing functionals .
• Example: The minimal curve problem is to find the shortest path between two specified locations. In simplest form, we are given two points a = (a
1
, a
2
) and b = (b
1
, b
2
). We want to find the curve of shortest length connecting them.
b a
Calculus of Variations
• Let us assume the curve is the graph of a differentiable function y=u(x). Then, the length of the curve is given by the standard arclength integral:
I [ u ]
b
1
1
u ' ( x )
2 dx a
1
We would require that u(x) satisfy the boundary condition s: a
2
=u(a
1
) and b
2
=u(b
1
).
• Then, the task is to find the function u(x) that will minimize the integral, among all possible functions satisfying the boundary conditions.
• The integral is called a functional .
Calculus of Variations
• The general problem in the calculus of variations is to find a function that optimizes some functional.
• Note the difference between optimizing a function and optimizing a functional:
• Function: Find optimum for f(x) among points on an interval .
• Functional: Find optimum for I[u] among a space of possible functions (often this space is infinite-dimensional)
• What is the condition for optimizing a functional that is analogous to analogous to for functions?
Calculus of Variations
• Single Variable : Suppose that the functional I[u] is an b integral value of x,u,and u x
:
I [ u ]
F ( x , u , u x
) dx a
• As we did before, let’s add a term to vary the function u w ( x )
u ( x )
tv ( x ) where v(x) is a function satisfying the same boundary conditions as u(x). We get g ( t )
b
a
F ( x , w , w x
) dx
b a
F ( x , u
tv , u x
tv x
) dx
If u(x) optimizes the functional, we must have g’(0)=0.
Calculus of Variations
• Assuming the integral and functions u and v are sufficiently smooth, we can bring the derivative inside the integral to get: g ' ( t )
b
a d dt
F ( x , w , w x
) dx
b
a
F
w
w
t
F
p
p
t dx where we let p = w x
. Then, using w = u+tv, we get g ' ( t )
b
a
F
w v ( x )
F
p v x
( x ) dx
If u is an optimum, then g’(0)=0. Also, w| t=0 w x
| t=0
=u x
. Thus,
0
b a
F
u v ( x )
F
u x v x
( x ) dx
=u and
Calculus of Variations
Now,
0
b
a
F
u v ( x )
F
u x v x
( x ) dx
b
a
F
u v ( x ) dx
b
a
F
u x v x
( x ) dx
0
For the second integral, we use integration by parts: b
a
F
u x v x dx
F
u x v
b a
b
a d dx
F
u x
v dx
To insure that u and w satisfy the same boundary conditions, we must have v(a)=v(b)=0. Thus, we have b
a
F
u x
b a
F u
d dx
u
F x
v v x dx
b
a d dx
F
u x
v dx
Calculus of Variations b
a
F
u
d dx
F
u x
v dx
0
Since this formula holds for all variation functions v(x), then it must be the case that the integrand is identically zero.
That is,
F u
d dx
F u x
• This result is known as the Euler-Lagrange Equation
Calculus of Variations
• Multi-Variable : Consider the task of finding the optimum function u(x,y) for an integral functional
I
D
, , , , x y
dxdy
• As with the single variable case, we create a variational function w(x,y) = u(x,y)+tv(x,y) where v is zero on the boundary of D.
d dt t
0
I [ w ]
D
F
w v
F
w x v x
F
w y v y dx dy
0
Calculus of Variations
• Again, by using integration by parts on the second and third terms, we get
D
F
w
d dx
F
w x
d dy
F
w y
v dx dy
0 for all variation functions v and so,
F u
d dx
F u x
d dy
F u y
Calculus of Variations
• With this method, the E-L equation can be extended to n variables:
F
u
i n
1 d dx i
F
u x i
Note:
– Process gives an extremum: distinguishing mathematically between max/min is difficult. We usually have to use geometry of physical setup to tell if we have a max or min.
– Solution function u must have continuous second-order derivatives - requirement from integration by parts
Calculus of Variations
• Example: Curve of shortest length had functional
E-L :
F u
d dx
F u x
I [ u ]
b
1 a
1
1
u ' ( x )
2 dx
Here, the integrand is F ( x , u , p )
1
p
2
Now, and u
F
p
p
1
p
2
Calculus of Variations
• Example: So,
1
u x
2 u xx
u x
0
d dx u x
1
u x
2
(1
u x
2
) u xx
(1
u x
2
u
)
3 / 2 x
2 u xx
1
u x u xx
(1
u x
2
2
)
3 / 2 u x u xx
1
u x
2
The only solution of this is u’’=0, that is a linear function in x, which is not surprising!
The Poisson Equation
u xx
u yy
f ( x , y )
• This equation can be generated as the solution to a Calculus of Variations problem.
•
I [ u ]
u x
2 u y
2
D
• The E-L equation is
2 f ( x , y ) u ( x , y ) dx dy
F u
d dx
F u x
d dy
F u y
The Poisson Equation
I [ u ]
D u x
2 u y
2
2 f ( x , y ) u ( x , y ) dx dy
F u
d dx
F u x
d dy
F u y
So,
2 f
d dx
d dy
y
2 u xx
2 u yy
u xx
u yy
Thus, we get the E-L equations lead to the
Poisson Equation.
f