Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for...

8

Click here to load reader

Transcript of Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for...

Page 1: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

Examples on Variational Methods for Solving Boundary

Problems for Ordinary Differential Equations (ODE) of the

Second Order (Galerkin and Ritz methods)

Problem 1. Solve the following boundary problem with the Ritz method:

, 0, (0) (1) 0y y x y y′′ + + = = =

by using the coordinate functions: 0 0ϕ = , 1 (1 )x xϕ = − , 22 (1 )x xϕ = − . Compare the

obtained approximate solution with the exact one sin( )( )sin1

xu x x= − in points from [0,

1].

Solution:

For the problem solved in (9), (see the references in the chapter “Variational

methods – Galerkin and Ritz methods”) we have: ( ) 1, ( ) 1, ( )p x q x f x x= = − = − . The

system (12), from which we will determine , has the following form: 1 2,c c

1 1

1 1 1 1 1 2 2 1 2 1 10 0

1 1

1 1 2 1 2 2 2 2 2 2 20 0

( ) ( )

( ) ( )

c dx c dx

c dx c dx

ϕ ϕ ϕϕ ϕ ϕ ϕ ϕ ϕ

ϕ ϕ ϕϕ ϕ ϕ ϕ ϕ ϕ

′ ′ ′ ′− + − =

′ ′ ′ ′− + − =

∫ ∫

∫ ∫

1

0

1

0

x dx

x dx

∫.

Or by substitution: 1

2

3 3 110 20 12

13 132020 105

cc

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟⎛ ⎞

=⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠ ⎜ ⎟⎜ ⎟⎜ ⎟

⎝ ⎠⎝ ⎠

.

The solution to the system is =0.19245 and c =0.17077. For the approximate

solution we get

1c 2

20.19245 (1 ) 0.17077 (1 )y x x x= − + x− .

Page 2: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

We compare the values of the approximate and the exact solution:

x y u 0.1 0.0189 0.0187 0.5 0.0695 0.0697 0.8 0.0527 0.0525

Problem 2. Solve the following boundary problem with Galerkin's method:

1 10, (1) 0, (2)2

y y y yx

′′ ′ ′+ = = = ,

by using this form for the solution: като решението се търси във вида

21 2

1 ( 1) (( 2) 1) (( 2) 12

y x c x c x= − + − − + − −3 ) and compare it to the exact solution

. lnu x=

Solution:

Obviously 01 ( 12

xϕ )= − , 21 (( 2) 1)xϕ = − − , 3

2 (( 2) 1)xϕ = − + are the basis

functions of the approximate solution, for which it can be verified that they satisfy the

boundary conditions as it is described in 1.

The system (6) has the following form:

( )

( )

2 2 2

1 1 1 2 2 1 0 11 1 12 2 2

1 1 2 2 2 2 0 21 1 1

.

.

c L dx c L dx f L dx

c L dx c L dx f L dx

ϕϕ ϕ ϕ ϕ ϕ

ϕϕ ϕ ϕ ϕ ϕ

+ = −

+ = −

∫ ∫ ∫

∫ ∫ ∫ ,

where we calculate 012

Lx

ϕ = , 112 .2( 2)L xx

ϕ + − , = 22

16( 2) .3( 2)L x xx

ϕ = − + − .

We integrate the obtained coefficients of (7):

1 2

1 2

0.9844 1.2033 0.21031.0748 1.4244 0.2407

c cc c

− + =− = −

and we calculate the solution of the system: =-0.0911, =0.1002. 1c 2c

The approximate solution is:

2 31 ( 1) 0.0911(( 2) 1) 0.1002(( 2) 1)2

y x x x= − − − − + − −

Page 3: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

We compare the values of the approximate and the exact solution:

x y u 1.25 0.223 0.223 1.50 0.406 0.405 1.75 0.559 0.560

Problem 3. Solve the following boundary problem with the Ritz method

1 0, (1) 0, (2) ln 2y y y yx

′′ ′+ = = = ,

by using the respective coordinate functions of type (10) for n = 2.

Solution:

We are looking for the approximate solution 2 0 1 1 2y c c 2ϕ ϕ ϕ= + + , where from

(10) we calculate 0ln 2 00 ( 1) ln 2( 1)

2 1x xϕ −

= + − = −−

22 ( 1) (2 ), , x xϕ − − . =

We write the right-hand side of the equation in a self-conjugated form after

performing the necessary transformations: 1 0 0 (y y xy y xyx

) 0′′ ′ ′′ ′ ′ ′+ = → + = → = .

The system (12), from which we will determine , for 1 2,c c ( )p x x= , ( ) 0q x = ,

( ) 0f x = is of the following type:

2 2 2

1 1 1 2 2 1 0 11 1 12 2 2

1 1 2 2 2 2 0 21 1 1

c x dx c x dx x dx

c x dx c x dx x dx

ϕ ϕ ϕ ϕ ϕ ϕ

ϕ ϕ ϕ ϕ ϕ ϕ

′ ′ ′ ′+ = −

′ ′ ′ ′+ = −

∫ ∫ ∫

∫ ∫ ∫.

In order to write it down in the following form we calculate the

coefficients:

2

1

, 1,ik i ki

A c B k=

= − =∑ 2

2 22

11 1 11 1

1(3 2 )2

A x dx x x dxϕ ϕ′ ′= = −∫ ∫ = ,

Page 4: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

2 2

21 1 21 1

17(3 2 )( 1)(5 3 )60

A x dx x x x x dxϕ ϕ′ ′= = − − −∫ ∫ = ,

12 21A A= ,

2 22 2

22 2 21 1

14 7( 1) (5 3 )60 30

A x dx x x x dxϕ ϕ′ ′= = − − =∫ ∫ = ,

2 2

1 0 11 1

ln 2ln 2(3 2 )6

B x dx x x dxϕ ϕ= = − = −∫ ∫ ,

2 2

2 0 21 1

ln 2ln 2( 1)(5 3 )12

B x dx x x x dxϕ ϕ= = − − = −∫ ∫ .

The solution of the system:

1 2

1 2

1 17 ln 2 60 617 7 ln 260 30 12

c c

c c

+ =

+ =

2

x

is: , and approximate solution is 1 20.2910, 0.1058c c= = −

22 ln(2( 1)) 0.2910( 1)(2 ) 0.1058( 1) (2 )y x x x x= − + − − − − − .

We compare the values of the approximate and the exact solution:

x y u 1.25 0.2228 0.2231 1.50 0.4055 0.4061 1.75 0.5596 0.5595

Problem 4. Solve the following boundary problem with the Ritz method

, (0) 0, (1)y x y y′′ = = 1=

2

,

by using 0 1, ,ϕ ϕ ϕ from (10).

Solution:

We are looking the approximate solution in the following form

0 1 1 2 2 1 2, ?,y c c c c ?ϕ ϕ ϕ= + + = = , where 0 xϕ = , ( )1 1x xϕ = − , ( )22 1x xϕ = − ,

1,p f x= = .

After calculating the integrals, the system (12), from which we will determine

Page 5: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

1 2,c c , is:

1 2

1 2

1 1 3 6 11 26 15 2

c c

c c

+ = −

+ = −

12

10

and its solution is: 1 21 1,6 6

c c= − = − , or 31 ( )6

y x x x= − − .

Problem 5. Solve the following boundary problem with Galerkin's method

2 2 , (0) 0, (1)y xy y x y y′′ ′ ′− + = = =1

2

,

by using 0 1, ,ϕ ϕ ϕ following the formulas (10).

Solution:

We represent the approximate solution in the following form:

0 1 1 2 2 1 2, ?,y c c c c ?ϕ ϕ ϕ= + + = = , where 0 xϕ = , 21 2( 2), ( 3x x x xϕ ϕ )= − = − are

chosen in such a way that 0ϕ satisfies the boundary conditions, and 1 2,ϕ ϕ are zero

boundary conditions, as it is described in 1.

We calculate 0 0Lϕ = , 21 2 2L xϕ = − + , 3

2 6 4L x xϕ = − and the system (7) is:

1 1 1

1 1 1 2 2 1 0 1 10 0 01 1 1

1 1 2 2 2 2 0 2 20 0 0

c L dx c L dx L f dx

c L dx c L dx L f dx

ϕϕ ϕ ϕ ϕ ϕ ϕ

ϕϕ ϕ ϕ ϕ ϕ ϕ

+ = −

+ = −

∫ ∫ ∫

∫ ∫ ∫

After calculating the integrals we get:

1 2

1 2

11 47 5 15 30 124 104 43 35 5

c c

c c

− − = −

− − = −.

The solution of this system is: 1 20.169, 0.34507c c= − = .

Problem 6. Find the approximate solution of the given boundary problem with

Galerkin's method

Page 6: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

cos sin sin , ( ) ( ) 2y y x y x x y yπ π′′ ′− + = − = = ,

by choosing the following functions as a basis:

0 1 2 3 42, sin , cos 1, sin 2 , cos2 1x x x xϕ ϕ ϕ ϕ ϕ= = = + = = − .

Solution:

We verify the conditions for the basis functions:

1. , 0,...,4i iϕ = are linearly independent,

2. 0ϕ satisfies the boundary conditions,

3. , 0,...,4i iϕ = satisfy zero boundary conditions.

We look for the approximate solution in the following form

4

01

, ?i i ii

y c cϕ ϕ=

= + =∑

We calculate

0 1 2

3 4

2sin , sin cos2 , sin cos sin 2 ,1 3 3 14sin 2 cos cos3 , 4cos2 sin3 sin .2 2 2 2

L x L x x L x x x

L x x x L x x x

ϕ ϕ ϕ

ϕ ϕ

= = − − = − +

= − − − = − + −

We substitute in the system (7) and calculate its coefficients:

1 2 4

2 3

2 3

1 4

0.5 10.5 04 0

4 0

c c cc cc c

c c

− + =+ =

− =+ + =

.

The solution of this system is: 1 2 3 48 2, 0,7 7

c c c c= = = = − .

We compare the values of the approximate and the exact solution:

x y u -π /2 1.429 1.368 0 2 2 π /2 3.714 3.718

Problem 7. Find the approximate solution of the given boundary problem with

Galerkin's method

Page 7: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

( )3

2( 1) , 0 1, (1) 0.( 1)

y x y y y yx

′′ ′− + − = = =+

5,

by choosing the following functions as a basis: 0 1 0.5xϕ = − , ( )1 1x xϕ = − ,

( )22 1x xϕ = − and compare the approximate solution with the exact one 1

1u

x=

+.

Solution:

We calculate 0 0.5L xϕ = − , 21 3 3L xϕ = − , 3

2 4 8 3L x xϕ = − + and we substitute

in the system (7), where 1

11 1 10

0.35A L dxϕϕ= = −∫ , 1

21 2 10

0.2A L dxϕ ϕ= = −∫ , , 1

12 1 20

0.15A L dxϕϕ= = −∫1

22 2 20

0.138095A L dxϕ ϕ= = −∫ , , 1

1 1 0 10

0.113706B f L dxϕ ϕ ϕ= − =∫1

2 2 0 20

0.0368441B f L dxϕ ϕ ϕ= − =∫ .

The solution of the system:

1 2

1 2

0.35 0.2 0.1137060.15 0.138095 0.0368441

c cc c

− − = −− − =

is . 1 20.454552, 0.226935c c= − =

We compare: and 21 21 0.5 (1 ) (1 )y x c x x c x= − + − + − x 1

1u

x=

+ in the points x =

0.2, 0.5, 0.7:

(0.2) 0.83453, (0.2) 0.83333(0.5) 0.66473, (0.5) 0.66667(0.7) 0.58790, (0.7) 0.58824

y uy uy u

= == == =

.

Problem 8. Solve the following boundary problem with the Ritz method:

( )(( 1) ) , 0 (1) 0x y ax b y y′ ′+ = + = = , where a, b are parameters, taking values from

0 to 9.

Solution:

Page 8: Examples on Variational Methods for Solving Boundary ... · Examples on Variational Methods for Solving Boundary Problems for Ordinary Differential Equations (ODE) of the Second Order

We are looking for 0 1 1 2 2 1 2, ?,y c c c c ?ϕ ϕ ϕ= + + = = for

( ) ( )20 1 20, 1 , 1x x xϕ ϕ ϕ= = − = − x . In this case (1 ), 0,p x q f ax b= + = = + . In the

system (12), from which we will determine , after calculating the integrals we

obtain:

1 2,c c

1 1

11 1 1 12 21 1 20 0

1 1,2 6

A p dx A A p dxϕ ϕ ϕ ϕ′ ′ ′ ′= = = =∫ ∫70

= ,

1

1 10

212

aB f dxϕ += =∫

b , 1

2 20

3 560

a bB f dxϕ += =∫ .

The solution of the system:

11 1 21 2 1

12 1 22 2 2

A c A c BA c A c B

+ = −+ = −

are coefficients in the approximate solution.

Author: Luba Popova

Plovdiv University