Ordinary differential equation with boundary value condition

Click For Summary
The discussion focuses on solving a boundary value problem defined by the differential equation u''(t) = -4u + 3sin(t) with boundary conditions u(0) = 1 and u(2) = 2sin(4) + sin(2) + cos(4). A finite difference method is proposed for discretization using a step length of h = 0.5, but participants note that this step size is too large for the interval [0, 2]. The correct approach involves using smaller step sizes, such as h = 0.01, to ensure accurate calculations. The iterative method requires an assumption for u(h) as an unknown parameter to derive a linear equation that can be solved to find the value of u(2). This approach emphasizes the need for careful discretization and consideration of boundary conditions in solving differential equations.
Linder88
Messages
25
Reaction score
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
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.
 
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: 471
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.
 
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:
You should also look in your textbook and class notes for a similar problem to see how it was done.
 
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:

Similar threads

Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 14 ·
Replies
14
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
8
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K