Pendulum with a moving pivot

for a 2D game I want to simulate pendulum with a moving pivot. I don’t want to use rigid body objects, I want to manually calculate this.

the pivot point moves along x axis left or right, I know the rate of movement
the pendulum is at distance l and mass m from the pivot point. I need to calculate the movement of the pendulum.

If anyone has done this before, can you provide some help on this?

Start with an empty game object for the pivot. Make the arm/bob a child object of the pivot. Then rotate the empty game back and forth using Lerp(). Use Mathf.Sin() to get the speed of motion right through the swing. Here is an example script for the empty game object:

public class Pend : MonoBehaviour {
	public float angle = 40.0f;
	public float speed = 1.5f;
	
	Quaternion qStart, qEnd;
	
	void Start () {
		qStart = Quaternion.AngleAxis ( angle, Vector3.forward);
		qEnd   = Quaternion.AngleAxis (-angle, Vector3.forward);
	}
	
	void Update () {
	  transform.rotation = Quaternion.Lerp (qStart, qEnd, (Mathf.Sin(Time.time * speed) + 1.0f) / 2.0f);
	}
}

I have somewhat modified the code. But still not giving the result I wanted. I have to modify the angle by 10000 to get some meaningful swing. The pendulum jumps to the new angle after I stop the movement. There is no smooth transition.

I found the actual equations for this here Here

Can anyone help me improve this code?

public class Pend : MonoBehaviour {
    public float angle = 0.0f;
    public float speed = 1.5f;
    public float frictionFactor = .999f;
    public float factor = 1.0f;
	
	private Vector3 lastPosition;
	private float xDirectionShift;
 
    Quaternion qStart, qEnd;
	
 
    void Start () 
	{
		
		lastPosition = transform.position;
		xDirectionShift = 0.0f;
		
       qStart = Quaternion.AngleAxis ( 0, Vector3.forward);
       qEnd   = Quaternion.AngleAxis (0, Vector3.forward);
    }
 
    void Update () 
	{
		float shift = transform.position.x - lastPosition.x;
		
		if (Mathf.Abs(shift) > 1.0f)
		{	
			xDirectionShift = shift;
			lastPosition = transform.position;
		
			angle = Mathf.Atan2(xDirectionShift,200.0f);
			
			qStart = Quaternion.AngleAxis ( angle*10000, Vector3.forward);
       		qEnd   = Quaternion.AngleAxis (-angle*10000, Vector3.forward);
		}
		else
		{
			transform.rotation = Quaternion.Lerp (qStart, qEnd, (Mathf.Sin(Time.time * speed)*factor + 1.0f) / 2.0f);
       		factor *= frictionFactor;
		}
		
       
    }