Prove that if $|f'(x)| \leq M$, for all $x \in [a,b]$, then $$f(a)-M(b-a)\leq f(b) \leq f(a)+M(b-a)$$
What I tried so far:
Proof. Let $$x \in [a,b]$$
Assume $$|f'(x)|\leq M$$
Show $$f(a)-(Mb-Ma)\leq f(b) \leq f(a)+(Mb-Ma)$$
By assumption that $f'$ defined on $[a,b]$, we have following:
$f$ is cts on [a,b], Also differentiable on (a,b)
By MVT have $\exists c \in (a,b) s.t.$
$$f'(c)=\frac{f(b)-f(a)}{b-a}$$
by assumption also have $-M\leq f'(x) \leq M$
That $$c \in (a,b),\text{ have }-M \leq f'(c) \leq M$$
Have $$-M \leq \frac{f(b)-f(a)}{b-a} \leq M$$
Therefore $$f(a)-M(b-a)\leq f(b) \leq f(a)+M(b-a)\tag*{$\square$}$$
Is this proof correct, any suggestion would be appreciated.
This is false. (Perhaps you have copied $|f'(x)| \leq M$ as $|f(x)| \leq M$).
Counterexample: if $f(x)=\sqrt x$ on $[0,1]$ then the hypothesis holds with $M=1$ but the right hand inequality in the conclusion fails for $a$ and $b$ close to $0$.
Answer to the edited question: just apply MVT: $f(b)-f(a)=(b-a)f'(x)$ for some $x$ and $-M \leq f'(x) \leq M$. Can you complete the proof using this?