Topic: Sine, cosine error
Hi,
I am working with sin(x) and cos(x) instrinsic functions, and this x depends on the timestep for my code.
I need to run this code up to 100.000 maybe 200.000 iterations, and I have noticed that near 38.000 iterations, cos (x) returns a number beyond [1,-1], and sin(x) returned 0 value over 38.000 iterations.
I would like to know if there is any limitation on the input of these functions.
My code lines are the following:
...
y1 = 1
dx = x1 / mp
kn=pi/x1
w1 = sqrt(9.81*kn*tanh(kn*y1))
wh = 0.7*w1
ah = 0.05*y1
xt(itimestep) = ah*cos(wh*(itimestep)*dt)
vt(itimestep) = -wh*ah*sin(wh*(itimestep)*dt)
...
in this case xt(38,000) is a big number over the range of the function results [ah;-ah]
and vt (>38.000) = 0.
I would be very grateful if anyone could help me please.
Best,
Emilio