Smoothness is local Let us consider a map $f:M\to R$ where $M$ is a smooth manifold. If every point $p\in M$ has a neighborhood $U$ such that $f|_U$ is smooth, prove that $f$ is a smooth function.
My idea is to prove that any two coordinate charts from any two atlases are smoothly compatible (if $f|_U$ is smoothly than $f\circ \varphi^{-1}$ is smoothly for any $\varphi$ from the atlas that defines the smooth structure on $U$). Is that ok? If yes, how can I prove that?
Thank you!

I think that is better to prove the statement by definition. Given $p\in M$ and $U$ neighborhood of $p$ such that $f|_U$ is smooth, there exists coordinate charts $(U\cap U_\alpha, \varphi_\alpha|_{U\cap U_\alpha})$ (where $(U_\alpha, \varphi_\alpha)$ is a chart of $M$) and $(V,\psi)$ of $p$ and $f|_U(p)=f(p)$ respectively such that $\psi\circ f\circ \varphi_\alpha^{-1}|_{U\cap U_\alpha}:\varphi_\alpha(U\cap U_\alpha)\to \psi(V)$ is smooth, but this is the definition of smoothness of $f:M\to N$ using the charts $(U\cap U_\alpha, \varphi_\alpha|_{U\cap U_\alpha})$ and $(V,\psi)$ where $f(U\cap U_\alpha)=f|_U (U\cap U_\alpha)\subset V$.
