I am trying to solve the following ODE:
$$ \frac{d^2y}{dx^2}=y(x) $$ Where I have two boundary conditions: $ y(0)=10 $; and $ \frac{dy(x\rightarrow\inf)}{dx}=0 $
I am trying to solve the problem through finite difference by central approximation, so:
$$ y''(x_i)=\frac{f(x_{i+1})-2\cdot y(x_i)+y(x_{i-1})}{h^2} $$
Which if plugged into my initial ODE:
$$ y(x_{i+1})+(-2-h^2)\cdot y(x_i)+y(x_{i-1})=0 $$
In this case I am discretizing over a range of: $ 0\leq x \leq 5$, with 500 nodes (so $h=0.01$), and $I$ goes from 1 to $N+1$, where the approximated ODE would be valid for $2\leq i \leq N$ (all discretized points except for the boundaries.
Hope I made sense so far and you are still with me here, my question is, how do I set up the right hand side boundary condition $ (\frac{dy(x\rightarrow\inf)}{dx}=0) $, since I do not have a specific value to set it to?
Thanks for your time!
At the risk of coming across as overbearing, I will answer my own question (XD)... I came across this MIT post that solves exactly this problem. The condition can be evaluated again by using finite difference, where by central approximation: $$ \frac{dy(x_i)}{dx}=\frac{y(x_{i+1})-y(x_{i-1})}{2\cdot h} $$ Applied to the BC: $$ \frac{dy(x_N)}{dx}=\frac{y(x_{N+1})-y(x_{N-1})}{2\cdot h}=0\rightarrow y(x_{N+1})-y(x_{N-1}) \approx y(x_{N+2})-y(x_{N})=0$$ Where the approximation works under the assumption of $ h\rightarrow 0$. Here we are adding an additional term $(y_{N+2})$, so the system of equations used to solve the approximated ODEs at each of the discretized points will also have to grow from N+1, to N+2, where the new value added to the end will be "fictitious", and should later be removed from the final solution.
I'm unsure as to how well I explained this, but in case of any doubt, follow the link if it's still up, they do a far better job at explaining it than me :').