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:

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

,

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

(i.e. the equation explicitly after some rearranging is:

After studying my text books I tried to solve it using the method described for the form (i.e. determining the complementary function and particular integral and defining n as 1)

My initial results were:

And hence:

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 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.