Given this dynamics:
$$x_{k+1} = x_k + a\cos(u_k)$$ $$y_{k+1} = y_k + a\sin(u_k)/\cos(x_k) $$
I want the input that would make this system ($x$ and $y$ states) follow this trajectory (lemniscate):
$$x^* = x_c + r\cos(t)/(1+\sin^2(t))$$ $$y^* = y_c + r\cos(t)\sin(t)/(1+\sin^2(t))$$
The problem is that if I compute from this the input that matches this dynamics it is:
$$\cos(u_k) = (x_{k+1}-x_k)/a$$ $$\sin(u_k) = (y_k+1-y_k)\cos(x_k)/a $$
And therefore:
$$\tan(u_k) = \frac{(y_{k+1}-y_k)\cos(x_k)}{(x_{k+1}-x_k)}$$
I compute this and apply it to the linearized system (with a controller) and it does not follow the given trajectory. However, if I go from a sinusoidal input and tune some parameters, I am completely able to follow a trajectory that is close to the lemniscate. I don't know why I cannot do this going the other way around.
Thanks!