I think I found a way to do it...

I am frustrated because I typed my whole solution here and then when I sent it it turned out my account was disconnected while I was writing. So I won't bother writing it out again in detail.

But the general idea is to start with the equation given by arildno and multiply it by -1 (to get rid of the minus signs).

Then use this formula with I am not quite sure if it works in all cases:

A cos α + B cos β =

2 cos{[arccos(A cos α) + arccos(B cos β)]/2} cos{[arccos(A cos α) - arccos(B cos β)]/2}

Where A = (k-1) , α = (a-b)x , B = (k+1) and β = (a+b)x.

Divide by 2 on both sides to get rid of the 2's.

Then you have a product of cosines which equals 1. So each cosine equals 1 or -1 as well.

This gives you a system of equations.

You can solve this system easily (just take care of the range of arccos). One problem is that in the end, you'll have two expressions for x, both of which must be equal, and so you'll have to choose the appropriate integers in the + 2n[itex]\pi[/itex] and + 2m[itex]\pi[/itex] (if they even exist, I have no idea how to find them besides trial and error).

The other problem is that this formula doesn't seem to work for k between -2 and 2 because of the domain of arcsin(1/(k-1)) (you'll have to solve the system to see what I mean).

EDIT:

The final answer I have is

x = 1/(a-b) *[ħarcsec(k-1) + 2n[itex]\pi[/itex]]

x = 1/(a+b)*[ħarcsec(k+1) + 2m[itex]\pi[/itex]]

(x satisfies both conditions, so not all n and m will actually work)

A second solution is almost the same but with (1-k) and (-k-1) as the argument in arcsec.