# Sine Wave Without the SIne Function?

Hi there,
Is there a formula for the rate of acceleration/decay of a sine wave? Namely, if you set up a cube, place it at 0,0,0 and then applied the return value from the Sine function (incrementing 0 deg - 90 deg values as the angle argument * a 1 unit radius) to the cube’s x position it would move back and forth from -1 to 1 decelerating exponentially before it reached both -1 and 1. Is there a formula that could be used to calculate and express the exponential decay in speed as a negative force instead of using the Sine function?

a dynamic simulation of a spring will produce the spring’s displacement as a sine function of time.
the basic formula there is the restorative force is negatively proportional to the spring displacement. then you integrate that w/r/t time however you like.

Thank you, elenzil. I believe that may be what I’m after but I’ll have to play around and see. Much appreciated!

If I understand the question, you are asking whether you can create sinusoidal movement using forces. The answer is yes. You still have to use the sine function because if an object’s position at any time t is sin(t), then its acceleration is -sin(t).

Here are two pieces of code that will produce very similar motion (assuming no friction, no other forces, no obstacles):

``````// Movement by changing transform.position.
void FixedUpdate()
{
float t = Time.time;
transform.position = Mathf.Sin(t) * Vector3.right;
}

// Movement by applying a force.
Rigidbody rigidBody;
void FixedUpdate()
{
float t = Time.time;
float acceleration = -Mathf.Sin(t); // second derivative of position
float force = acceleration * rigidBody.mass; // force = mass * acceleration
``````1. Acceleration is the second time derivative of position (can be written symbolically "a(t) = (d/dt)^2 x(t)").