Ordinary differential equation with boundary value condition

In summary: So, combining the information from your two conditions, you can solve for ##c##, and then get all the values of ##u(t)## for integer values of ##t## between ##0## and ##2##.
  • #1
Linder88
25
0

Homework Statement


Consider the boundary value problem
\begin{equation}
u''(t)=-4u+3sin(t),u(0)=1,u(2)=2sin(4)+sin(2)+cos(4)
\end{equation}

Homework Equations


Derive the linear system that arise when discretizating this problem using
\begin{equation}
u''(t)=\frac{u(t-h)-2u(t)+u(t+h)}{h^2}
\end{equation}
where h=0.5 is the step length.

The Attempt at a Solution


Evaluate the second derivative at the first boundary
\begin{equation}
u''(0)=-4u(0)=-4
\end{equation}
Now if iterating with step length h=0.5 we should have
for t=1:100
\begin{equation}
\begin{cases}
u''(t)=-4u(t)+3sin(t)\\
u(t+1)=u(t)+h^2u''(t)
\end{cases}
\end{equation}
end
When I do this iteration in I don't end up at u(2)=2sin(4)+sin(2)+cos(4) which make me conclude that I am doing something wrong. Can somebody please explain how I should use Equation (2) to calculate the next value?
 
Last edited:
Physics news on Phys.org
  • #2
Linder88 said:

Homework Statement


Consider the boundary value problem
\begin{equation}
u''(t)=-4u+3sin(t),u(0)=1,u(2)=2sin(4)+sin(2)+cos(4)
\end{equation}

Homework Equations


Derive the linear system that arise when discretizating this problem using
\begin{equation}
u''(t)=\frac{u(t-h)-2u(t)+u(t+h)}{h^2}
\end{equation}
where h=0.5 is the step length.

The Attempt at a Solution


Evaluate the second derivative at the first boundary
\begin{equation}
u''(0)=-4u(0)=-4
\end{equation}
Now if iterating with step length h=0.5 we should have
for t=1:100
\begin{equation}
\begin{cases}
u''(t)=-4u(t)+3sin(t)\\
u(t+1)=u(t)+h^2u''(t)
\end{cases}
\end{equation}
end
I don't know where your second equation above comes from. Let's assume for the moment that it is correct. The main problem I see is that your step of h = 0.5 is way too large. Your interval is [0, 2]. If you divide that into 100 subintervals, each is of length .02. Possibly h is half of that, or h = .01.
Linder88 said:
When I do this iteration in I don't end up at u(2)=2sin(4)+sin(2)+cos(4) which make me conclude that I am doing something wrong. Can somebody please explain how I should use Equation (45) to calculate the next value?
When t = 100, you are calculating u(101), not u(2).

Also, do you mean equation 10 rather than equation 45? That equation is only an approximation, with closer values for smaller values of h.
 
  • #3
Mark44 said:
I don't know where your second equation above comes from. Let's assume for the moment that it is correct. The main problem I see is that your step of h = 0.5 is way too large. Your interval is [0, 2]. If you divide that into 100 subintervals, each is of length .02. Possibly h is half of that, or h = .01.

When t = 100, you are calculating u(101), not u(2).

Also, do you mean equation 10 rather than equation 45? That equation is only an approximation, with closer values for smaller values of h.

Well, the original question looks like in the attached picture. Let me know if it doesn't work or if you can't see it. I am excited to hear your comments on the questions.
 

Attachments

  • Screenshot_2015-11-13-20-57-46.png
    Screenshot_2015-11-13-20-57-46.png
    18 KB · Views: 437
  • #4
I believe that the first part ("Derive the linear system that arise when discretizating this problem using... h = 0.5") is
##u''(.5) = \frac{u(0) - 2u(.5) + u(1)}{(.5)^2}##
##u''(1) = \frac{u(.5) - 2u(1) + u(1.5)}{(.5)^2}##
##u''(1.5) = \frac{u(1) - 2u(1.5) + u(2)}{(.5)^2}##
I could be wrong, but I think this is what they're looking for.
For the other part, take a look at the Matlab code that is mentioned in the problem statement in your book.
 
  • #5
Mark44 said:
I believe that the first part ("Derive the linear system that arise when discretizating this problem using... h = 0.5") is
##u''(.5) = \frac{u(0) - 2u(.5) + u(1)}{(.5)^2}##
##u''(1) = \frac{u(.5) - 2u(1) + u(1.5)}{(.5)^2}##
##u''(1.5) = \frac{u(1) - 2u(1.5) + u(2)}{(.5)^2}##
I could be wrong, but I think this is what they're looking for.
For the other part, take a look at the Matlab code that is mentioned in the problem statement in your book.
Thank you, this at least gives me something to write in the report :)
 
Last edited by a moderator:
  • #6
You should also look in your textbook and class notes for a similar problem to see how it was done.
 
  • #7
Linder88 said:

Homework Statement


Consider the boundary value problem
\begin{equation}
u''(t)=-4u+3sin(t),u(0)=1,u(2)=2sin(4)+sin(2)+cos(4)
\end{equation}

Homework Equations


Derive the linear system that arise when discretizating this problem using
\begin{equation}
u''(t)=\frac{u(t-h)-2u(t)+u(t+h)}{h^2}
\end{equation}
where h=0.5 is the step length.

The Attempt at a Solution


Evaluate the second derivative at the first boundary
\begin{equation}
u''(0)=-4u(0)=-4
\end{equation}
Now if iterating with step length h=0.5 we should have
for t=1:100
\begin{equation}
\begin{cases}
u''(t)=-4u(t)+3sin(t)\\
u(t+1)=u(t)+h^2u''(t)
\end{cases}
\end{equation}
end
When I do this iteration in I don't end up at u(2)=2sin(4)+sin(2)+cos(4) which make me conclude that I am doing something wrong. Can somebody please explain how I should use Equation (2) to calculate the next value?

No: you do not have ##u(t+1)=u(t)+h^2u''(t)##; if anything, you should have ##u(t+h) \approx u(t) + h u'(t) + \frac{1}{2} h^2 u''(t)##. However, when you make the finite-difference approximation to ##u''(t)## and substitute that into the DE, you will get an equation linking ##u(t-h), u(t)## and ##u(t+h)##, so if you know ##u(0)## and ##u(h)## you can get ##u(2h)##, then ##u(3h)##, etc. However, this is a so-called two-point boundary value problem (because your boundary conditions are given at two separate point ##t = 0## and ##t = 2##), so your condition at ##t = 0## is not enough, by itself. You do know ##u(0)##, so if you assume a value ##u(h)= c## as an unknown problem parameter, you will be able to carry out all the iterations in terms of a symbolic ##c##, until you reach ##t = 2##. At that point you will have ##u(2)## expressed as a linear function of the parameter ##c##, so you get an equation that determines ##c##.
 
Last edited:

FAQ: Ordinary differential equation with boundary value condition

What is an ordinary differential equation (ODE)?

An ordinary differential equation is a mathematical equation that describes how a function changes over a continuous range of values. It involves derivatives of the function with respect to one or more independent variables.

What is a boundary value condition?

A boundary value condition is a condition that specifies the values of a solution to an ODE at the boundary points of the independent variable. It is used to determine a unique solution to the ODE.

How is an ODE with boundary value conditions solved?

ODEs with boundary value conditions are typically solved using numerical methods, such as the shooting method or the finite difference method. These methods involve breaking the problem down into smaller, simpler equations and using iterative techniques to approximate the solution.

What are some real-world applications of ODEs with boundary value conditions?

ODEs with boundary value conditions are commonly used in physics, engineering, and other scientific fields to model and solve a wide range of problems. Examples include heat transfer in a metal rod, population growth, and the motion of a pendulum.

What are the limitations of using ODEs with boundary value conditions?

ODEs with boundary value conditions can be challenging to solve analytically, and numerical methods may not always provide an exact solution. Additionally, the accuracy of the solution can be affected by the chosen discretization and the convergence of the numerical method.

Similar threads

Back
Top