Calculus of variations -- how does it make sense to vary the position and the velocity independently? In the calculus of variations, particularly Lagrangian mechanics, people often say we vary the position and the velocity independently. But velocity is the derivative of position, so how can you treat them as independent variables?
 A: While it is true that the function $\dot{q}(t)$ is the derivative of the function $q(t)$ w.r.t. time, it is not true that the value $\dot{q}$ is at all related to the value $q$ at a given point in time, since a value is just a number, not a function.  The action is a functional of $q(t)$, and so it would make no sense to vary the action both w.r.t. $q$ and $\dot{q}$.  But the
Lagrangian $L(q,\dot{q})$ is a function of the values $q$ and $\dot{q}$, not a functional of the functions $q(t)$ and $\dot{q}(t)$.  We can promote $L$ to a function of time if we plug in $q(t)$ and $\dot{q}(t)$ instead of just $q$ and $\dot{q}$.  (Remember a functional turns a function into a number, e.g., $S[q]$, whereas a function turns a value into a number, e.g., $L(q,\dot{q})$.
To solve for $q(t)$ we extremize the action $S$, by demanding that it is extremal at every point, $t$.  This is equivalent to solving the Euler-Lagrange equations at every point $t$.
Since at any point $t$ the values $q$ and $\dot{q}$ are independent, they can be varied independently.
A: Unlike your question suggests, it is not true that velocity is varied independently of position. A variation of position $q \mapsto q + \delta q$ induces a variation of velocity $\partial_t q \mapsto \partial_t q + \partial_t (\delta q)$ as you would expect.
The only thing that may seem strange is that $q$ and $\partial_t q$ are treated as independent variables of the Lagrangian $L(q,\partial_t q)$. But this is not surprising; after all, if you ask "what is the kinetic energy of a particle?", then it is not enough to know the position of the particle, you also have to know its velocity to answer that question.
Put differently, you can choose position and velocity independently as initial conditions, that's why the Lagrangian function treats them as independent; but the calculus of variation does not vary them independently, a variation in position induces a fitting variation in velocity.
A: The answer to your main question is already given -- you do not vary coordiante and speed independently. But it seems that your main problem is about using coordinate and speed as independent variables.  
Let me refer to this great book:
"Applied Differential Geometry". By William L. Burke. The very first line of the book (where an author usually says to whom this book is devoted) is this:

It is true that from time to time student do ask this question. But attempts to explain it "top down" are usually just lead to more and more questions. One really needs to make mathematical "bottom up" order in the topic. Well, as the name of the book suggest -- the mathematical discipline one needs is differential geometry. 
I cannot retell all the details, but briefly it looks like this:   


*

*You start with a configuration space $M$ of your system. $M$ is a (differentiable) manifold, and $q$ are the coordinates on this manifold. 

*Then there is a specific procedure, that allows you to add all the possible "speeds" at every given point of $M$. And you arrive at the tangent bundle $TM$, which is a manifold too, and ($q$,$\dot{q}$) are different coordinates on it. 

*Lagrangian is a function on $TM$.

A: If we have a function $f(x,v)$, the partial derivatives are defined by $$\frac{\partial f(x,v)}{\partial x} \equiv \lim_{h\to 0} \frac{f(x+h,v)-f(x,v)}{h}$$ and $$\frac{\partial f(x,v)}{\partial v} \equiv \lim_{h\to 0} \frac{f(x,v+h)-f(x,v)}{h}$$ This implies, for example, for $f=v^2$ that $$\frac{\partial v^2}{\partial x} \equiv \lim_{h\to 0} \frac{v^2-v^2}{h} =0.$$ Moreover, for $v= \frac{dx}{dt}$ we find that $x \to x+h$ implies $v = \frac{dx}{dt} \to v' = \frac{d(x+h)}{dt} = \frac{dx}{dt} =v$. Thus $$\frac{\partial \frac{dx}{dt}^2}{\partial x} \equiv \lim_{h\to 0} \frac{\frac{dx}{dt}^2-\frac{dx}{dt}^2}{h} =0.$$
Hence it makes sense to consider the partial derivatives of the Lagrangian with respect to $x$ and $v$ separately and in this sense treat them independently.

In more physical terms, recall that our goal in the Lagrangian formalism is  to figure out the correct path in configuration space between two fixed location. A path is characterized by a location and velocity at each point in time. We are as general as possible and consider really all possible paths. This implies that we consider all possible pairings of locations and velocities. The physical classical path is special for two reasons:


*

*it's a solution of the Euler-Lagrange equation (= extremum of the action)

*the locations and velocities at each moment in time are related by $v \equiv \frac{dq}{dt}$. (If you want, $v \equiv \frac{dq}{dt}$ is the second equation that we need in the Lagrangian formalism analogous to how there are two Hamilton equations in the Hamiltonian formalism. The second Hamilton equation defines the canonical momentum as a derivative of the Lagrangian. For general paths in phase space, any pairing of location and momentum is possible. Only for the physical classical path we find canonical momentum values that are given as the appropriate derivative of the Lagrangian.)

A: Considering what Greg Graviton wrote, I'll write out the derivation and see if I can make sense of it.
$$ S = \int_{t_1}^{t_2} L(q, \dot q, t)\, \mathrm{d}t $$
where S is the action and L the Lagrangian. We vary the path and find the extremum of the action:
$$ \delta S = \int_{t_1}^{t_2} \left({\partial L \over \partial q}\delta q + {\partial L \over \partial \dot q}\delta \dot q\right) \,\mathrm{d}t = 0\,. $$
Here, q and $\dot q$ are varied independently. But then in the next step we use this identity,
$$ \delta \dot q = {\mathrm{d} \over \mathrm{d}t} \delta q. $$
And here is where the relationship between q and $\dot q$ enters the picture. I think that what is happening here is that q and $\dot q$ are treated as independent initially, but then the independence is removed by the identity.
$$ \delta S = \int_{t_1}^{t_2} \left({\partial L \over \partial q}\delta q + {\partial L \over \partial \dot q}{d \over \mathrm{d}t} \delta q\right) \,\mathrm{d}t = 0 $$
And then follows the rest of the derivation. We integrate the second term by parts:
$$ \delta S = \left[ {\partial L \over \partial \dot q}\delta q\right]_{t_1}^{t_2} + \int_{t_1}^{t_2} \left({\partial L \over \partial q} - {d \over dt}{\partial L \over \partial \dot q}\right)\delta q\, \mathrm{d}t = 0\,, $$
and the bracketed expression is zero because the endpoints are held fixed. And then we can pull out the Euler-Lagrange equation:
$$ {\partial L \over \partial q} - {\mathrm{d} \over \mathrm{d}t}{\partial L \over \partial \dot q} = 0\,. $$
Now it makes more sense to me. You start by treating the variables as independent but then remove the independence by imposing a condition during the derivation.
I think that makes sense. I expect in general other problems can be treated the same way.
(I copied the above equations from Mechanics by Landau and Lifshitz.)
A: Here is my answer, which is basically an expanded version of Greg Graviton's answer.
The question of why one can treat position and velocity as independent variables arises in the definition of the Lagrangian $L$ itself, before one uses equation of motion, and before one thinks about varying the action $S:=\int_{t_i}^{t_f}\mathrm{d}t \ L$, and has therefore nothing to do with calculus of variation.
I) On one hand, let us first consider the role of the Lagrangian.
Let there be given an arbitrary but fixed instant of time $t_0\in [t_i,t_f]$. The (instantaneous) Lagrangian $L(q(t_0),v(t_0),t_0)$ is a function of both the instantaneous position $q(t_0)$ and the instantaneous velocity $v(t_0)$ at the instant $t_0$.
Here $q(t_0)$ and $v(t_0)$ are independent variables. Note that the (instantaneous) Lagrangian $L(q(t_0),v(t_0),t_0)$ does not depend on the past $t<t_0$ nor the future $t>t_0$. (One may object that the velocity profile $\dot{q}\equiv\frac{\mathrm{d}q}{\mathrm{d}t}:[t_i,t_f]\to\mathbb{R}$ is the derivative of the position profile $q:[t_i,t_f]\to\mathbb{R}$, so how can $q(t_0)$ and $v(t_0)$ be truly independent variables? The point is that since the equation of motion is of 2nd order, one is still entitled to make 2 independent choices of initial conditions: 1 initial position and 1 initial velocity.) We can repeat this argument for any other instant $t_0\in[t_i,t_f]\,.$
II) On the other hand, let us consider calculus of variation.
The action functional
$$S[q] ~:=~ \int_{t_i}^{t_f}\mathrm{d}t \ L(q(t),\dot{q}(t),t)\tag{1}$$
depends on the whole (perhaps virtual) path $q:[t_i,t_f]\to\mathbb{R}$. Here the time derivative $\dot{q}\equiv\frac{\mathrm{d}q}{\mathrm{d}t}$ does depend on the function $q:[t_i,t_f]\to \mathbb{R}\,.$ Extremizing the action functional
$$\begin{align}0~=~&\delta S \cr
~=~& \int_{t_i}^{t_f}\mathrm{d}t\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} \delta q(t) \right.\cr
&+\left.\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\delta \dot{q}(t)\right]\cr
 ~=~& \int_{t_i}^{t_f}\mathrm{d}t\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} \delta q(t) \right.\cr
&+\left.\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\frac{\mathrm d}{\mathrm{d}t}\delta q(t)\right]\cr
~=~& \int_{t_i}^{t_f}\mathrm{d}t\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}\right|_{v(t)=\dot{q}(t)} \right.\cr
&-\left. \frac{\mathrm d}{\mathrm{d}t}\left(\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)} \right)\right]\delta q(t)\cr 
&+ \int_{t_i}^{t_f}\mathrm{d}t\frac{\mathrm{d}}{\mathrm{d}t}\left[\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}\right|_{v(t)=\dot{q}(t)}\delta q(t)\right] \end{align}\tag{2} $$
with appropriate boundary conditions leads to Euler-Lagrange (EL) equation, which is the equation of motion (EOM).
$$
\begin{align} \frac{\mathrm d}{\mathrm{d}t}&\left(\left.\frac{\partial L(q(t),v(t),t)}{\partial v(t)}
\right|_{v(t)=\dot{q}(t)} \right)\cr
&~=~ \left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}
\right|_{v(t)=\dot{q}(t)} ~.\tag{3}\end{align}
$$
III) Note that
$$\frac{\mathrm{d}}{\mathrm{d}t}~=~\dot{v}(t)\frac{\partial}{\partial v(t)}+\dot{q}(t)\frac{\partial}{\partial q(t)}+\frac{\partial}{\partial t} \tag{4}$$
is a total time derivative, not an explicit time derivative $\frac{\partial}{\partial t}$, so that the EL equation (3) is really a 2nd-order ordinary differential equation (ODE),
$$\begin{align} \left(\ddot{q}(t)\frac{\partial}{\partial v(t)}
+\dot{q}(t)\frac{\partial}{\partial q(t)}
\right.&\left.
+\frac{\partial}{\partial t}\right) \left. \frac{\partial L(q(t),v(t),t)}{\partial v(t)}
\right|_{v(t)=\dot{q}(t)} \cr 
~=~& \left.\frac{\partial L(q(t),v(t),t)}{\partial q(t)}
\right|_{v(t)=\dot{q}(t)}~. \tag{5}\end{align}$$
To solve for the path $q:[t_i,t_f]\to \mathbb{R}$, one should specify two initial conditions, e.g.,
$$q(t_i)~=~q_i\qquad\text{and} \qquad\dot{q}(t_i)~=~v_i.\tag{6}$$
A: The derivative of a function $f(t)$ is the function $\dot{f}(t)$ in general different than $f$, and in the general case the two are not even linearly dependent, which is simple to see if you take the Taylor expansion. It is only after you define differential equations with them that they are linked algebraically, and this is what the calculus of variations does.
