Largest value of an unknown function evaluated at a particular x value Firstly, apologies for the extremely vague title; the problem I'm working on doesn't particularly possess a specific title.
I am trying the following question but am very stuck:
Assume the function $f : \mathbb{R} \rightarrow \mathbb{R}$ is continuously differentiable on $\mathbb{R}$. Assume also that $f(0) = 0$ and $f(x)f'(x) ≤ 2$ for all $x \in \mathbb{R}$. What is the largest possible value of $f(4)$? (Hint: Show that a larger value cannot be obtained; also show that the value you give actually is attained by at least one function.)
I have seen questions similar to this before however the functions were defined on a closed, bounded interval meaning the Mean Value Theorem could be used, however that is obviously not the case here. I've been at it for a while but haven't been able to come up with anything as of yet.  
Any help is very appreciated. 
UPDATE: I've come up with this so far:
We are given that $f$ is differentiable on $\mathbb{R}$, and therefore $f$ is continuous on $\mathbb{R}$. In particular, $f$ is continuous on the closed interval $[0, 4] \subset \mathbb{R}$ and differentiable on the open interval $(0, 4)$, as is required for application of the Mean Value Theorem for $f(x)$ on the interval $[0, 4]$.
Applying the MVT to $[0, 4]$, we see that there is a number $c \in (0, 4)$ such that $$f'(c) = \frac{f(4)-f(0)}{4-0} = \frac{f(4)}{4}$$ $$ \Rightarrow f(4) = 4f'(c) \leq \frac{8}{f(c)}$$
Unsure where to go from here or if this would even lead to a solution...
 A: We know that $4$ is an upper bound, but it can't be attained. (since $2\sqrt x$ isn't $\mathcal C^1$)
If we can show that we can get arbitrarily close to $4$, then $4$ is the largest value. To do that, we'll try to "patch" $2\sqrt x$ near $0$.
Consider the function: 
$$
f(x)=\begin{cases}
ax^2 &\text{if $x\in[0,\varepsilon]$}\\
2\sqrt x -b &\text{if $x\in[\varepsilon,4]$}\end{cases}
$$
We want our function to be $\mathcal C^1$, so $f$ and $f'$ must be continuous at $\varepsilon$.
This gives us:
$$\begin{align}
&\cases{
a\varepsilon^2=2\sqrt\varepsilon - b \\
2a\varepsilon=1/\sqrt\varepsilon
} \\
&\cases{
a\varepsilon^2=2\sqrt\varepsilon - b \\
a=1/2\varepsilon^{3/2}
} \\
&\cases{
b=2\sqrt\varepsilon-\sqrt\varepsilon/2=3\sqrt\varepsilon/2 \\
a=1/2\varepsilon^{3/2}
}
\end{align}$$
Now we need to check if our function satisfies the condition: For $x\in[0,\varepsilon]$
$$ax^2 2ax=2a^2x^3\leq 2\frac{1}{4\varepsilon^3}\varepsilon^3\leq1/2<2 $$
And for $x\in[\varepsilon,4]$
$$\frac{2\sqrt x-b}{\sqrt x}=2-b/\sqrt x \leq2$$
So our function is valid, ($\mathcal C^1$ and satisfies the inequality) now we just need to check its value at $4$:
$$f(4)=4-3\sqrt\varepsilon/2 $$
Which gets arbitrarily close to $4$ as $\varepsilon$ gets closer to $0$.
A: Let $g=f^2$. Then $g$ is non-negative, $C^1$, $g(0)=0$ and $g'(x)\le4$. It follows that $g(x)\le4\,x$ and $f(x)\le2\,\sqrt x$ for $x\ge0$. Suppose that $g(a)<a$ for sone $a\in(0,4)$. Then
$$
g(4)=g(a)+\int_a^4g'(t)\,dt\le g(a)+4(4-a)<16.
$$
Thus, ig $g(4)=16$, then $g(x)=4\,x$. This implies that if $f(4)=4$ then $f(x)=2\,\sqrt x$, which is not $C^1$.
