# How to solve this trigonometric equation / geometric problem

Is there any way to solve this type of equation exactly for x, where a-h are precalculated constants:

$a\cos(g x)+b \sin(g x)+c\cos(h x)+d\sin(hx)+ex+f=0$

Or is my only/best option some sort of approximate or iterative solution?

Update: As it seems the above equation cannot be solved exactly but here's a description what I'm trying to achieve in terms of geometric problem, in hopes somebody knows a better approach (with solvable equation) for solving that underlying problem.

Basically I have two spheres of different sizes and angular velocities, moving towards each other alongside the x-axis (linear motion can be simplified to only one moving). Both spheres contain some specific point on their surface and what I'm trying to solve is the (first) time that those points hit some common point in regard to that x-axis. That is they both hit the green line in the picture below in regard to x-axis, even though they might be at different y positions within the line. So the x variable that I'm trying to solve can be thought of either as the time of impact or the location of that green line.

As a further complication, these are actually 3D-spheres so that the axis of rotation can be anything (combined rotations around two axes) and different between the spheres. The linear motion is alongside a single axis though.

But that in essence is what I tried to model with that trigonometric equation. That e*x term models the relative linear motion and there are sin/cos terms for both spheres for getting the change alongside the x-axis for the 3D-rotation.

Any ideas if there could be some other approach in solving that?

It's a transcendental equation. No matter how you combine the sin/cos terms, if you have $x$ outside and inside the trig/exp/log functions, there is no closed form analytic solution. You have to solve it numerically (e.g. iteration/bisection/Newton's method).

EDIT: reviewing your original problem, I think that you pretty much simplified as much as you can. Projecting the motion of the spheres to the $x$ axis, you have oscillating motion of both points, there's no way to simplify that. If the angular velocity were equal, it would make the equation easier to solve, but nothing more than that.

One of the problems is, that it's hard to predict even the number of solutions. You probably need to find the first intersection. You get a rough idea about its location if you set the radius of both spheres to $0$. This gives you an initial estimate that you can use to find the true minimum with bisection. The nice part is, that you get the exact upper and lower bound for the solution: set all cos/sin to 1 and express $x$ for one bound, and all to -1 to get the other bound. This gives you an interval for bisection. Then, you can just find the solution like this, but it may not be the lowest one. However, you know the period of both rotations. So you can split the interval into subintervals of maybe half the period of short/long rotation (it sort of depends on which radius is the bigger and more important) and try with bisection on each of them. This way you ensure the first solution.

I wouldn't recommend Newton's method, at least not until you get really close to the solution. For oscillatory functions, it tends to escape away from the solution.

In summary: in both limits, the solution is easy. For $a,b,c,d\to 0$, you get the "average" intersection from linear motion. If you "sit" at the average intersection, freeze the linear motion and only rotate one of the spheres, you get regular periodic solutions with $\arctan$. The reality is a mixture: when they are in the intersection zone, they may have a few intersections, roughly periodic, but the origin moves away until you don't get any new solutions.

This is what can suggest to your intuition that there are no analytic solutions. This complexity of a transitional phenomenon where you get a couple of grouped solutions and nothing else, is hard to imagine in an analytic form.

Sorry, I wish I had better news.

• Thank you. That's what I thought/feared. I updated the description above in case there's some fundamentally better approach to the underlying problem. – JohnDoeNot Mar 28 '14 at 20:47
• Thank you again for a comprehensive answer. Obviously it's not what I hoped for but at least it is a confirmation that I didn't miss something obvious and the problem itself truly is a hard one without exact solution. And also thank you for giving me directions how to continue. – JohnDoeNot Mar 31 '14 at 10:37