Professional Documents
Culture Documents
Nguyen Hoai Project 7
Nguyen Hoai Project 7
912292469
ENG 180/1
16 November 2017
PROJECT 7
INTRODUCTION
The purpose of this project is to use MATLAB to solve initial value problems given ordinary
differential equations. The primary method of solving the bulk of the problems is using a 4th
order Runge-Kutta method.
METHODS
The methods we will be using to solve these initial value problems are:
Forward Difference
+1 = ( , ) +
Backward Difference
+1 ( +1 , +1 ) =
+1 1 +1 +1 +1 +1
= ( ) ( + ( , ) ) +
Central Difference
+1 = 2 ( , ) + 1
Trapezoidal Rule
+1 ( +1 , +1 ) = ( , ) +
2 2
+1 1 +1
+1 +1
+1 +1 +1
= ( ) ( + ( , ) + ( , ) ) +
2 2
Runge-Kutta: 2nd Order
1 = ( , )
1 1
2 = ( + , +2 )
2
+1 = + 2
Runge-Kutta: 3rd Order
1 = ( , )
1 1
2 = ( + , +2 )
2
3 = ( 1 + 22 , +1 )
1 + 42 + 3
+1 = +
6
Runge-Kutta: 4th Order
1 = ( , )
1 1
2 = ( + , +2 )
2
2 1
3 = ( + , +2 )
2
4 = ( + 3 , +1 )
1 + 22 + 23 + 4
+1 = +
6
Collocation Method
+1 = + + 2
= ( , )
( +1 , +1 ) ( , )
=
2
+1 ( +1 , +1 ) = ( , ) +
2 2
+1 1 +1
+1 +1
+1 +1 +1
= ( ) ( + ( , ) + ( , ) ) +
2 2
Problem 1(a)
We will be solving the following equations:
= 1 2
=
(0) = 1, (0) = 0
1. Set interval for
2. Set initial values
3. Rearrange differential equations for and
4. Derive and for the Jacobians
5. Create anonymous function to reflect the rearranged equations and Jacobians
6. Plug into all equations
a. Exceptions
i. Backward Difference, Trapezoidal Rule, and Collocation method use the
Newtons method iterative scheme (i.e. set tolerance and computer
residual)
ii. Central Difference requires an additional data point which can be
computed using Forward Difference
7. Plot
Problem 1(b)
We will be solving the following equations:
+ 2 = 0
+ 2 = 0
2 = 3
( 2 + 2 )2
(0) = 1, (0) = 0, (0) = 0, (0) = 1
1 2 1
= [ + 2 ] ( 2 + 2 )2
2
=
1. Set interval for t
2. Set initial values
3. Rearrange differential equations for and
4. Create anonymous function to reflect the rearranged equations
5. Plug into 4th Order Runge-Kutta equation
6. Plot
Problem 1(c)
We will be solving the following equations:
Duffings Equation
+ + 3 =
(0) = 0, (0) = 1
van der Pol Equation
+ ( 2 1) + = 0
(0) = 0, (0) = 1
1. Set interval for t
2. Set initial values
3. Rearrange differential equations for
4. Create anonymous function to reflect the rearranged equations
5. Plug into 4th Order Runge-Kutta equation
6. Plot
Problem 2(a)
We will be solving the following equation:
=
(0) = 1.1, = 1
1. Set interval for t
2. Set initial values
3. Rearrange differential equation for
4. Create anonymous function to reflect the rearranged equation
5. Plug into 4th Order Runge-Kutta equation
6. Plot
Problem 2(b)
We will be solving the following equation:
= ( ) + ( 4 4 )
= 0.1
1. Set = 0
2. Rearrange equation for A
3. Set initial values 1 and 2
4. Create anonymous function to reflect the rearranged equation
5. Plug into 4th Order Runge-Kutta equation
6. Plot
Problem 2(c)
We will be solving the following equations:
[1 ] = 12 [1 ]
[2 ] = 12 [1 ] 23 [2 ]
[ 3 ] = 23 [2 ]
[1 ] = 1, [2 ] = 0, [3 ] = 0
1. Set interval for t
2. Set initial values
3. Create anonymous function to reflect the equations
4. Plug into 4th Order Runge-Kutta equation
5. Plot
Problem 3(a)
We will be solving the following equation:
= 2
(0) = 1
1. Set interval for t
2. Set initial values
3. Create anonymous function to reflect the equation
4. Plug into 4th Order Runge-Kutta equation
5. Plot
Problem 3(b)
We will be solving the following equations:
= + ( 2 2 )
= + ( 2 2 )
0 (0) 3
0 (0) 3
1. Set interval for t
2. Set initial values in a mesh format
3. Create anonymous function to reflect the equation
4. Plug into 4th Order Runge-Kutta equation
5. Plot
Problem 3(c)
We will be solving the following equations:
= 10( )
= (28 )
8
=
3
(0) = 4, (0) = 4, (0) = 4
1. Set interval for t
2. Set initial values
3. Create anonymous function to reflect the equation
4. Plug into 4th Order Runge-Kutta equation
5. Plot
RESULTS
Problem 1(a)
Figure 1b-1. vs
Figure 1b-2. H vs t
Figure 1b-3. M vs t
Problem 1(c)
DISCUSSION
Problem 1a
I believe my results are accurate and my methods are efficient. The only problem I
encountered in this problem is the central difference method, since the plot for that method is
quite chaotic towards the end. I could probably preallocate arrays for faster calculations.
Problem 1b
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 1c
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 2a
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 2b
I am not sure whether my results are accurate or not since I did not know how to
approach this problem. My methods are efficient in terms of speed. I found the equilibrium
points by plotting the figure in the problem and checking the points of intersection.
Problem 2c
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 3a
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 3b
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.
Problem 3c
I believe my results are accurate and my methods are efficient. I did not have any
problems for this part.