How can I define a pendulus function? Suppose I have the variable $t$ that represents the time, it starts in $0$ and increases infinitely.
My goal is to define a function $p(t, L, R)$ that acts like a pendulum:



*

*At $t = 0$, it  is $0$

*At $t > 0$, it starts the pendulum movement:


*

*first it goes $L$;

*then it goes to the opposite site but walking a bit less;

*it continues until it goes to $0$.




I know that $sin(t)$ gives me a function that cross the $t$ axis regularly, but this function decreases the space between $2$ crossings, as if $t$ was being multiplied by something that is also increasing (it looks like $L \times sin(t^2))$.
As the peaks of the function get closer to $0$ over time, it seems like the function is also divided by something that is also increasing (something like $\frac{L * sin(t^2)}{t}$).
Anyway this isn't working so I'd like to know some approaches to get a function that looks like this.
 A: What about $$Le^{-t}\sin (t^2)$$
The factor $e^-t$ makes the amplitude to decrease with time and eventually approaches to zero.
A: In general, you can write such oscillations as $$f(t) = A(t) \sin (\phi(t))$$
where positive function $A(t)$ is responsible for the amplitude of oscilations and increasing function $\phi(t)$ regulates the distances between subseqent zeros of the whole function: the zeroes are given by the formula  $$t_n = \phi^{-1}(n\pi)$$
Your picture looks like the distances between subsequent zeros to drop geometrically, that is $$ t_{n+1}-t_n = q (t_n - t_{n-1}), \qquad 0<q<1$$
a recurssion that can be solved:
$$ t_n = T_0\frac{1-q^n}{1-q}$$
To get such $t_n$ one would require for example $$ \phi^{-1}(z) = T_0\frac{1-q^{z/\pi}}{1-q} $$
that is $$ \phi(t) =\pi\log_q\big( 1-\frac{t}{T_0}(1-q)\big) = \frac{\pi}{\ln q}\ln\big( 1-\frac{t}{T_0}(1-q)\big)$$
for $t\to T_k=\frac{T_0}{1-q}$ we have $\phi(t) \to \infty$, so $T_k$ is the end of oscilations, and we should have $A(T_k) = 0$. We can fit appropriate $A(t)$; your picture suggests a linear function, so let's take $$ A(t) = A_0 (1- \frac{t}{T_k})$$ for $t<T_k$ and $A(t)=0$ for $t>0$. Altogether for $t<T_k$ we get
$$ f(t) = A_0 (1- \frac{t}{T_k}) \sin \Big(\frac{\pi}{\ln q}\ln\big( 1-\frac{t}{T_0}(1-q)\big)\Big) = \\ = A_0 (1- \frac{t}{T_k}) \sin \Big(\frac{\pi}{\ln q}\ln\big( 1-\frac{t}{T_k}\big)\Big)$$
You can check here how such function looks like (for $A_0=1$, $T_k=1$, $q=\frac12$, but you can give them other values if you prefer).
It may be noted that although this function looks complicated, it can be simply written as 
$$ f(t) = {\rm Im}\Big(A_0\big(1-\frac{t}{T_k}\big)^z\Big)$$
where $z= 1+ i\frac{\pi}{\ln q}$.
A: This answer does not contain an explicit function satisfying the requirements, so it is just an extended comment, which shows how one can set up a (numerically solvable) differential equation governing a linearly dampled ideal pendulum in a constant gravitational field, and how one can approximate this differential equation with a linear one for which we can compute an explicit solution (that satisfies some of the properties).
It follows from the Second Law of Motion that the angular motion of an ideal, the angle $\theta(t)$ of an undamped pendulum in a constant gravitational field satisfies the differential equation
$$\ddot \theta(t) + k \sin \theta(t) = 0$$
for some positive constant $k$. If we modify our model to include a linear drag term---that is, a force opposing the motion of the pendulum proportional to the rate of change of angle, our differential equation becomes
$$\ddot \theta(t) + \gamma \dot \theta(t) + k \sin \theta(t) = 0$$
for some positive constant $\gamma$.
Since $\sin \theta$ is increasing on $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$, the times between successive zeros of any solution of this equation (other than the identically zero solution) decrease, albeit rather less dramatically than in your drawing, so this equation admits some solution $\theta(t)$ which satisfies the given requirements. This equation can be solved numerically for any initial values.
If you're looking for an explicit function, it is difficult to solve the above equation analytically, but for small $\theta$ we have $\sin \theta \approx \theta$, and so for small initial displacements $\theta(0)$ and velocities $\dot\theta(0)$ the qualitative behavior of the system is well-approximated by the linear differential equation
$$\ddot \theta(t) + \gamma \dot \theta(t) + k \theta(t) = 0 .$$
Every nonzero solution will be oscillatory---that is, every solution $\theta(t)$ will take on the value zero infinitely many times---if the equation is underdamped, that is, if $\gamma^2 < 4 k$; in that case, the general solution has the form
$$e^{-\beta t / 2} (A \sin \omega t + B \cos \omega t),$$
where $$4 \omega^2 = 4 k - \gamma^2.$$ The initial condition forces $B = 0$, giving the general solution
$$A e^{-\gamma t / 2} \sin \omega t$$
to the approximating linear equation. If $A > 0$ (as in the drawing) the first maximum occurs at $t = \frac{2}{\omega} \arctan \frac{\omega}{\gamma}$, and we can use this value to solve for $A$ in terms of $L$.
NB, however, that for any nonzero solution $\theta(t)$ of the linear differential equation the times between successive solutions of $\theta(t) = 0$ is always $\frac{\pi}{\omega}$, and in particular is not decreasing.
