- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Wave)
I want to solve numerically the following boundary value problem:
$\left\{\begin{matrix}
-u''+qu=f & , x \in [a,b]\\
-u'(a)+d_1 u(a)=0 & \\
u'(b)+d_2 u(b)=0 &
\end{matrix}\right.$
where $q(x) \geq 0 \forall x \in [a,b], d_1, d_2 \geq 0$.
We consider the uniform partition of $[a,b]$ with step $h=\frac{b-a}{N}$.
The approximations $U_i$ of $u(x_i), i=1, \dots, N+1$ have to be calculated with the following finite difference method:
$\\ \frac{2}{h^2}(U_1-U_2)+2 \frac{d_1}{h} U_1+q(x_1)U_1=f(x_1)
-\frac{1}{h^2}(U_{i-1}-2U_i+U_{i+1})+q(x_i)U_i=f(x_i), i=2, \dots, N \\
-\frac{2}{h^2}(U_N-U_{N+1})+2\frac{d_2}{h}U_{N+1}+q(x_{N+1})U_{N+1}=f(x_{N+1})$
There are given specific functions for $f$ and $q$.
I have to compute approximations of the solution, and the errors for uniform partitions with $N=25,50,100$ subintervals.
So does this mean that we have to write the whole $N+1$-sized vector $U$ that we get for each $N$ ?Also, I have to find the order of accuracy of the method.
This can be done as follows:
Let $\epsilon (N)$ the error of the numerical method for $N$ subintervals and let's assume that $\epsilon (N) \approx C h^p$, where $C$ doesn't depend on $h$ and $N$. Then:
$$\frac{\epsilon (N)}{ \epsilon (2N)} \approx \frac{Ch^p}{C \left(\frac{h}{2} \right)^p} \Rightarrow p \approx \frac{\log \left( \frac{\epsilon (N)}{\epsilon (2N)}\right)}{\log 2}$$So can I run the program for any $N$ that I want and then for the corresponding $2N$ in order to find the order of accuracy?
I want to solve numerically the following boundary value problem:
$\left\{\begin{matrix}
-u''+qu=f & , x \in [a,b]\\
-u'(a)+d_1 u(a)=0 & \\
u'(b)+d_2 u(b)=0 &
\end{matrix}\right.$
where $q(x) \geq 0 \forall x \in [a,b], d_1, d_2 \geq 0$.
We consider the uniform partition of $[a,b]$ with step $h=\frac{b-a}{N}$.
The approximations $U_i$ of $u(x_i), i=1, \dots, N+1$ have to be calculated with the following finite difference method:
$\\ \frac{2}{h^2}(U_1-U_2)+2 \frac{d_1}{h} U_1+q(x_1)U_1=f(x_1)
-\frac{1}{h^2}(U_{i-1}-2U_i+U_{i+1})+q(x_i)U_i=f(x_i), i=2, \dots, N \\
-\frac{2}{h^2}(U_N-U_{N+1})+2\frac{d_2}{h}U_{N+1}+q(x_{N+1})U_{N+1}=f(x_{N+1})$
There are given specific functions for $f$ and $q$.
I have to compute approximations of the solution, and the errors for uniform partitions with $N=25,50,100$ subintervals.
So does this mean that we have to write the whole $N+1$-sized vector $U$ that we get for each $N$ ?Also, I have to find the order of accuracy of the method.
This can be done as follows:
Let $\epsilon (N)$ the error of the numerical method for $N$ subintervals and let's assume that $\epsilon (N) \approx C h^p$, where $C$ doesn't depend on $h$ and $N$. Then:
$$\frac{\epsilon (N)}{ \epsilon (2N)} \approx \frac{Ch^p}{C \left(\frac{h}{2} \right)^p} \Rightarrow p \approx \frac{\log \left( \frac{\epsilon (N)}{\epsilon (2N)}\right)}{\log 2}$$So can I run the program for any $N$ that I want and then for the corresponding $2N$ in order to find the order of accuracy?