It is important to note that \(x\) here refers to a generalised coordinate (i.e. just apply the formula as per your degrees of freedom), and to note that partial differentiation is used rather than the normal differentiation. The beauty of the Lagrangian is in that it allows for direct application no matter which set of coordinates you use, be it polar, spherical, or Cartesian, without further processing.
You must be wondering how the Euler-Lagrange equation come about? Mathematically they are based on Newton's laws (
https://en.wikipedia.org/wiki/Lagrangian_mechanics), but they can also be derived from Hamilton's Principle of Least Action. Don't worry too much if the mathematics below seem a bit tough -- it's based on the calculus of variations, which deal with functionals (which is sort of like a function of a function!).
6.2 The Principle of Stationary Action (Hamilton's Principle)
Allow us to (for reasons you will see later) define a term Action, \(S\), as the integral of the Lagrangian with respect to time. Consider now two points \(x_1\) and\(x_2\), and a function \(x\left(t\right)\) such that \(x\left(t_1\right)\ =\ x_{1\ }\)and \(x\left(t_2\right)\ =\ x_2\). What function \(x\left(t\right)\) will produce a stationary action?