Solving Ordinary differential Equations (ODE)
Typically: is given. Also given initial conditions like at .
Typical examples:
Equation 1:
Equation 2:
Equation 3:
Equation 4:
Equation 5:
Solutions of these equations for specific initial conditions and domain
Solution 1: from to and at we have
The solution:
To verify using MATLAB:
First save this function as an .m file in MATLAB work space.
function dy = g1(x,y)
% This function evaluates the first-order
% ODE usign Runge-Kutta method.
% dy stands for the derivative of y
%
%
dy = 3.0*x.^2;
Next we go tot eh command window and develop the solution there.
EDU» clear
EDU» % Obtain solution of ODE1
EDU» [x,num_y]=ode23('g1',2,4,0.5);
EDU» y=x.^3 -7.5;
EDU» hndl1=plot(x,num_y)
hndl1 =
1.0017
EDU» set(hndl1,'Linewidth',3)
EDU» hold on
EDU» hndl2=plot(x,y,'o')
hndl2 =
73.0016
EDU» set(hndl2,'Color',[1 0 0],'LineWidth',3)
EDU»
Another one. This time the function is more complicated one.
function dy = g2(x,y)
dy = 3*y + exp(2*x);
The domain and initial conditions are:
From to and at
EDU» clear
EDU» clear
EDU» [x,num_y]=ode23('g2',0,3,3);
EDU» hndl1=plot(x,num_y)
hndl1 =
1.0018
EDU» set(hndl1,'LineWidth',3)
EDU»
EDU» %
EDU» % We now attempt ode45 instead
EDU» %
EDU» hold on
EDU» [x,y1]=ode45('g2',0,3,3);
EDU» hndl2=plot(x,y1,'o')
hndl2 =
74.0011
EDU» set(hndl2,'Color',[1 0 0],'LineWidth',3);
EDU»
An Ode23 estimates the function by 2nd order and 3rd order Taylor series, i.e. using, say, three consecutive near-by tangents to the function. Here, the functional form of the differential wouldn’t be calculated a priori.
Thus, the description of the function by tangents
Solution of integration problems using functional approach. Analog computation.
An analog computational model is based on a paradigm of analogy. Here, the variables are not discrete but continuous; the solutions aren’t precise (more error prone) but at least immediate (fast).
A typical analog solution:
If we digitize this, we get the following:
And the final digitized specification would be
Normally, we think
A numerical solution a digital solution
Interpolated solution
What if we get a direct analog solution?
Example.
here, integrator is a device which outputs if it receives and .
A typical problem may appear more involved. Example.
, with at . Depicted in the diagrammatic format, it may appear as:
Suppose the problem is a little more elaborate. Instead, we have to solve
.
This could be designed as
What if our equation is
with the initial values
and
Well, we would need two integrators, multiplier, several summands, …
Share with your friends: |