This paper contains the algebraic analog for idempotent matrices of the Chern-Weil theory of characteristic classes. This is used to show, algebraically, that the canonical line bundle on the complex projective space is not stably trivial. Also a theorem is proved saying that for any smooth manifold there is a canonical epimorphism from the even dimensional algebraic de Rham cohomology of its algebra of smooth functions onto the standard even dimensional de Rham cohomology of the manifold