# Solve finite differences linear equation

Given

$$(\textrm{Pe}-1)u_{i+1} + 2u_i - (\textrm{Pe}-1)u_{i-1} = \frac{h^2}{\mu}$$

where $\textrm{Pe}$ stands for Péclet number, $h$ is the step size of the mesh and $\mu$ is the diffusion (constant)

How to solve such equation? I'm trying to solve it to understand why there are no oscillations in a finite element method approximation with the upwind schema.

UPDATE 1

The roots I got are: $r_1 = 1$ and $r_2 = \frac{1+\textrm{Pe}}{1-\textrm{Pe}}$

So I have the following guess for the general solution

$$u_i = C_1r_1^i + C_2r_2^i$$

To find the constants $C_1$ and $C_2$ I need to initial conditions. What are those? Are they related to the boundary conditions? I have $u(0) = 1$ and $u'(1) = 1$. How to proceed?

UPDATE 2

According to this text, I replace the roots in my guess for the solution to the homogeneous part.

$$u_i = C_1(1)^i + C_2\Big(\frac{1+\textrm{Pe}}{1-\textrm{Pe}}\Big)^i$$

Applying the initial conditions I have

$$u_0 = 1 = C_1(1)^0 + C_2\Big(\frac{1+\textrm{Pe}}{1-\textrm{Pe}}\Big)^0$$ $$1-C_1 = C2$$

for the other initial condition, what should I do, I mean I don't know how to proceed with that Neumann condition there.

UPDATE 3

Before applying the initial conditions to find the values of $C_1$ and $C_2$ I tried to solve for the particular case following the example on the information of this site

So I came up with using a guess like $f_i = ki$. Replacing on the original equation I have

$$(\textrm{Pe}-1)k(i+1) + 2ki - (\textrm{Pe}-1)k(i-1) = \frac{h^2}{\mu}$$

which after rearranging gives me

$$\big[(\textrm{Pe}-1)+2-(\textrm{Pe}-1)\big]ki + \big[(\textrm{Pe}-1)+(\textrm{Pe}+1)\big]k = \frac{h^2}{\mu}$$

finally $$k = \frac{h^2}{\mu \big[(\textrm{Pe}-1)+(\textrm{Pe}+1)\big]}$$

Hence, the complete (I think) equation is:

$$u_i = C_1(1)^i + C_2\Big(\frac{1+\textrm{Pe}}{1-\textrm{Pe}}\Big)^i+\frac{h^2 i}{\mu \big[(\textrm{Pe}-1)+(\textrm{Pe}+1)\big]}$$

Am I right? I just need to apply initial conditions. The $u(0) = 1$ is easy but the other one $u'(1) = 1$ how to apply that?

-
Solve for what? In Which Context? Are $A,B,C$ matrices? A little bit more explanation. – k1next Dec 19 '12 at 12:21
Your solution should be of the form $u(i)=u_h(i)+u_p(i)$, where $u_h$ and $u_p$ are the corresponding solutions of the homogeneous and particular solutions. $Here is a related problem. – Mhenni Benghorbal Dec 19 '12 at 18:46 This being a finite difference representation of a diffusion eq'n, I would set$u_0 = 1$and$u_1 - u_0 = h$, or$u_1 = 1+h$. The initial conditions are different from boundary conditions: initial conditions deal with the behavior at$t=0$while boundary conditions deal with the solution on a manifold. For a boundary-value problem, you would have to use a very different numerical representation of the equation. – Ron Gordon Dec 19 '12 at 18:49 @rlgordonma but this problem I'm trying to solve is the steady case. So there are no initial conditions. It's an elliptic 1D steady problem. – BRabbit27 Dec 19 '12 at 19:07 OK then, do this. You have mixed bounday conditions: Dirichlet on the left, Neumann on the right. For Dirichlet conditions, you have$u_0=1$. For Neumann, if there are N steps, you have$u_{N}-u_{N-1} = h$. You then need to apply the discrete equation successively into the interior of the region. To do this, you may be able to use the solution you derived in the initial value case to get the values of$u_{1}$, etc. Then take those new "boundary" values and propagate into the interior. Another way is to simply use a relaxation method (average until you reach equilibrium). – Ron Gordon Dec 19 '12 at 19:41 ## 1 Answer It depends. Do A and B depend on the index$i$? If A and B are constant, then you can split the solution up into a homogeneous solution$u_{i}^{(H)}$and an inhomogeoneous solution$u_{i}^{(I)}$. The homogeneous solution satisfies $$A u_{i+1}^{(H)} + 2 u_{i}^{(H)} + B u_{i-1}^{(H)} = 0$$ with initial conditions such as$u_{0}^{(H)} = u_0$and$u_{1}^{(H)} = u_1$. In this case, with constant coefficients, you can assume that$u_{i}^{(H)}$takes the form$\exp{(i r)}$and find$r$from the following equation: $$A r^2 + 2 r + B = 0$$ which I leave to you; the solutions are then$r_1$and$r_2$, and the general solution to the homogeneous equation is$u_{i}^{(H)} = C_1 \exp{(i r_1)} + C_2 \exp{(i r_2})$.$C_1$and$C_2$are found by using the initial conditions. The inhomogeneous solution satisfies $$A u_{i+1}^{(I)} + 2 u_{i}^{(I)} + B u_{i-1}^{(I)} = C$$ with initial conditions such as$u_{0}^{(I)} = 0$and$u_{1}^{(I)} = 0$. For a constant$C$,$u_{i}^{(I)}$can be a constant, with such constant being offset in the homogeneous initial conditions. For the case where$A$and/or$B\$ is not constant, then methods specific to the forms of their variation should be employed.

-
I have edited my post to give more context. I'll check your answer and see if that helps, though. – BRabbit27 Dec 19 '12 at 16:54