I am trying to solve numerically the following implicit equation, using Python:
y*sin(c)+sin(y*c)=0
where c
is a constant. How would you suggest me to do that? I implemented the classical Newton-Raphson's method, but it doesn't seem to converge.
EDIT:
Here is the code:
f = open('results.dat','w')
import math
alpha = input('Define the alpha angle: ')
print >> f, 'alpha =', alpha
lambda_0 = input('Define an initial value: ')
print >> f, 'y_0 = ', y_0
gamma = math.pi - math.radians(alpha)
# def f(x,y):
# p = 2.0 * x
# t = p * y
# val = t * math.cos(t) - math.sin(t)
# val /= (p * math.cos(t) + math.sin(p))
# return val
toll = 1e-12
itmax = 50
diff = 1.0
it = 0
while diff > toll and it <= itmax:
p = 2.0 * gamma
t = p * y_0
y_1 = t * math.cos(t) - math.sin(t)
y_1 /= (p * math.cos(t) + math.sin(p))
print >> f, 'p = ', p
print >> f, 't = ', t
print >> f, 'y at iteration ', it, ' = ', y
diff = abs(y - y_0)
y_0 = y
it += 1
print >> f, 'diff = ', diff
print >> f, 'y_0 = ', y_0
print >> f, 'it = ', it
f.close()