# Thread: Solving a second-order inhomogeneous differential equation

1. ## Solving a second-order inhomogeneous differential equation

Hello,

I'm having real trouble finding an analytical solution to a particular equation that my class has been given in an applied numerical methods module at my university.

It's of the form:
$\displaystyle \mathsf{\frac{d^2h(x)}{dx^2}-f(x)\cdot h(x)=g(x)}$

Where f(x) and g(x) are known and in this case are defined as follows:

$\displaystyle \mathsf{f(x)=\left(1-\frac{x}{5}\right)}$, $\displaystyle \mathsf{g(x)=x}$

And h(x) is the function to be determined.

(i.e. the equation explicitly after some rearranging is: $\displaystyle \mathsf{\frac{d^2h(x)}{dx^2}-h(x)=x\cdot \left(1-\frac{h(x)}{5}\right)}$

After studying my text books I tried to solve it using the method described for the form $\displaystyle \mathsf{\frac{d^2h(x)}{dx^2}-n^2\cdot h(x)=g(x)}$ (i.e. determining the complementary function and particular integral and defining n as 1)

My initial results were:

$\displaystyle \mathsf{CF=A\cdot \cosh{x}+B\cdot \sinh{x}}$
$\displaystyle \mathsf{PI=-x\left(1-\frac{h(x)}{5}\right)}$

And hence:

$\displaystyle \mathsf{h(x)=\frac{A\cdot \cosh{x}+B\cdot \sinh{x}-x}{1-\frac{x}{5}}}$

However after spending a long time differentiating it a couple of times to check it and not getting the answer I wanted and then evaluating numerically A and B using the boundary conditions h(1) = 5 and h(3) = -1 and using Matlab to evaluate h''(x) and compare it to $\displaystyle \mathsf{x+\left(1-\frac{x}{5}\right)\cdot h(x)}$ for a few values of x (which came out differently) I'm now convinced that method isn't suitable for this type of equation.

Is there anyone who can either tell me if I've made an error (and where) and this method is suitable for the equation, or point me towards a method that would be appropriate should one exist.

If more detailed working is needed I'll post it, I've tried to keep it to a minimum however for readability reasons.

Thanks,

Dan.

2. $\displaystyle \mathsf{\frac{d^2h(x)}{dx^2}-h(x)=x\cdot \left(1-\frac{h(x)}{5}=g(x)\right)}$

Τhis is not right, as h is the unknown and not part of the data.

Now, to solve $\displaystyle \mathsf{\frac{d^2h(x)}{dx^2}-f(x)\cdot h(x)=g(x)}$, you can use Frobenius's theorem: Expand the solution as a power series in base 0, substitute and equate coefficients on the right and left hand side of the equation.