Understanding the definition and meaning of cotangent space I would like to understand definition and also meaning of cotangent space. Let's first of all define tangent space: generally  we know that equation of  tangent line of function  $f(x)$ at point $x_0$  is equal to
$$y=f(x_0)+f'(x_0)*(x-x_0)$$
Is tangent space somehow related to  tangent lines? For example, family of tangent  lines? According to Wikipedia, cotangent space is a dual of tangent space; as I know duality  for example in vectors means that take a vector and produce scalar, general definition of  tangent space is given  on the following mathematics site
http://mathworld.wolfram.com/TangentSpace.html
According to this, I understood that if we have point $x$ in compact manifold $M$, and  if we attach at $x$ a copy of  $n$-dimensional  real space   as a  tangent to $M$, then resulting space is tangent space, so does it means that at given point $x$, we are   attaching $\mathbb{R}^n$ space as a  tangent  to $M$? If so, then what does  cotangent do? Does it take  vector from tangent space and produce  scalar?
 A: One possible way of defining tangent space to a manifold is to say that it is the possible values of tangencies that a path $\gamma(t)$ in the space can have. i.e. it is the vector space of all possible derivatives of maps from the interval into the manifold.
If you consider a surface embedded in $\mathbb{R}^3$ (picture a sphere or something simple... like a soccer ball), and you imagine an ant who is condemned to live on the surface of the ball. Consider all velocity vectors the ant is allowed to have when he passes through a specific spot on the ball. This gives you the tangent space at that point.
The cotangent bundle is indeed the dual space to this, but I often find it hard to imagine dual spaces. Instead, I would think of the cotangent bundle as being where differentials of functions live. Picture a function defined on the sphere -- maybe the temperature at that location. The derivative of this function at a given point is something that eats a direction and spits out a number -- this is the infinitesimal change of temperature as you consider displacing the point an infinitesimal amount in that direction. 
In other words, the tangent bundle consists of values of derivatives of maps $\gamma \colon \mathbb{R} \to M$ and the cotangent bundle tells you about differentials of maps $f \colon M \to \mathbb{R}$.
