2

How can I determine the initial guess of the equation Ax+Bsin(x)=C in terms of A,B and C ? I am trying to solve it using Newton Raphson. A,B and C will be given during runtime.

Is there any other method more efficient than Newton Raphson for this purpose ?

Hemesh Singh
  • 1,105
  • 2
  • 9
  • 13

4 Answers4

4

The optimal initial guess is the root itself, so finding an "optimal" guess isn't really valid.

Any guess will give you a valid solution eventually as long as f'(x0) != 0 for any step, which only occurs at the zeroes of cos(x), which are k*pi + pi/2 for any integer k.

I would try x0 = C * pi, just to see if it works.

Your biggest problem, however, would be the periodic nature of your function. Newton's method will be slow (if it even works) for your function as sin(x) will shift x0 back and forth over and over.


Precaution:

In Newton's method, do you notice how f'(xn) is in the denominator? f'(x) approaches 0 infinitely many times. If your f'(x) = 0.0001 (or anywhere close to zero, which has a chance of happening), your xn+1 gets thrown really far away from xn.

Worse yet, this can happen over and over due to f'(x) being a periodic function, which means that Newton's method might never even converge for an arbitrary x0.

Community
  • 1
  • 1
Blender
  • 289,723
  • 53
  • 439
  • 496
  • The problem I am trying to solve is http://www.spoj.pl/problems/TRIGALGE/ . Now I see the problem with the Newton Raphson's approach. Normal Bisection gives TLE(Time limit exceeded). Now I am thinking of mixing Bisection with Newton Raphson's. Is there any better approach ? – Hemesh Singh Apr 05 '12 at 04:45
  • 1
    I would first try Bisection for a few iterations to find a decent guess for Newton's method and then use Newton's method for a more accurate approximation. – Blender Apr 05 '12 at 04:58
  • The statement that *any* guess will give a valid solution is incorrect: see [here](http://en.wikipedia.org/wiki/Newton%27s_method#Failure_of_the_method_to_converge_to_the_root) for example. The statment that `f'(x)` approaches zero infinitely many times is also not *per se* correct -- that depends entirely on the value of `A` (and if `B = 0`, there is no obviously periodic component). The whole question is ill-posed, since there might be infinitely many solutions, and the usefulness of each one is not indicated by the OP. Just saying. – Rody Oldenhuis Aug 19 '12 at 21:05
  • @RodyOldenhuis: I didn't give my answer too much thought when writing it, so I did overlook a few details and assumed some things that I shouldn't have. – Blender Aug 19 '12 at 21:41
  • Well, it's been a while, and, I understand your position completely given the OP at the time. I commented mainly to make random passers-by more aware of the shortcommings in this answer. – Rody Oldenhuis Aug 19 '12 at 21:55
2

The simplest "good" approximation is to just assume that sin(x) is approximately zero, and so set:

x0 = C/A
RBarryYoung
  • 55,398
  • 14
  • 96
  • 137
0

Well, if A,B and C are real and different from 0, then (B+C)/A is an upper quote to the highest root and (C-B)/A is a lower quote to the lowest root, as -1 <= sin(x) <= 1. You could start with those.

Javier Garcia
  • 539
  • 1
  • 4
  • 15
0

Newton method can work with any guess. the problem is simple, if there is an equation and I guessed x0=100 and the best close solution for it is x0=2 and I know the answer is 2.34* by using any guess in the world you will eventually get to 2.34* the method says to choose a guess because without a valid guess it will take many solutions which aren't comfortable no one wants to repeat the method 20 times and guessing a solution is not hard you just find a critical point- for example, 3 is too big and 2 is too small so the answer is between 2 and 3 but if instead guessing 2 you guess 50 you will still get to the right solution. like I said it will just take you much longer I tested the method by myself I guessed 1000 to a random equation and I knew the best guess was 4 the answer was between 4 and 5 I chose 1000 it took me much time but after a few hours, I got down from 1000 to 4.something if you somehow can't find a critical point you can actually put a random number equals to x0 and then eventually you will get to the right solution no matter what number you guessed.