Find $f(x)$ if $$f'(x)=f(x) + \int_0^1 f(x)dx,\quad f(0)=1$$
My attempt:
Let $\int_0^1 f(x)dx=C_1$ and $f(x)=y$ so $f'(x)= \frac{dy}{dx}$. We have to solve $\frac{dy}{dx}= y+C_1$ or $$x+C_2= \ln|y+C_1|$$
which implies $$e^{x+C_2}= y+C_1$$
Substituting the given initial value we get $ e^{C_2}=1+C_2$.
However my book says the function is $\frac{2e^x}{3-e} + \frac{1-e}{3-e} $ and I'm not sure how this answer is right.
Differentiating both sides of the equation we know that: $$f'(x)=f(x)+\int_0^1f(x)dx\:\Longrightarrow\:f''(x)=f'(x)$$ The latter is a second order linear ODE with constant coefficients. It's general solution is: $$f(x)=Ae^x+B$$ The fact that $f(0)=1$ tells us that $A+B=1$, so we can rewrite $f(x)$ as: $$f(x)=Ae^x+(1-A)$$ The integral from $0$ to $1$ of this function is: $$\int_0^1 f(x)dx=\left[Ae^x+(1-A)x\right]_{x=0}^{x=1}=Ae+(1-A)-A=A(e-2)+1$$ Substituting in the original equation we get: $$\begin{align*}Ae^x=Ae^x+(1-A)+A(e-2)+1\:&\Longrightarrow\:0=2+A(e-3)\\&\Longrightarrow\:A=\frac{2}{3-e}\end{align*}$$ So: $$f(x)=\frac{2}{3-e}e^x+\frac{1-e}{3-e}$$ Edit: Your reasoning was also correct. At the point where you get $x+C_2=\ln|y+C_1|$, substituting the initial value gives you $C_2=\ln|1+C_1|\:\Longrightarrow\:e^{C_2}=|1+C_1|$ (and not $e^{C_2}=1+C_2$ as you wrote, but I'm sure that was just a typo). So: $$f(x)=e^{x+C_2}-C_1=|1+C_1|e^x-C_1$$ At this point, using the definition of $C_1$, we can conclude that: $$C_1:=\int_0^1f(x)dx=\int_0^1\left(|1+C_1|e^x-C_1\right)dx=|1+C_1|(e-1)-C_1$$ It is not difficult to see that the solution of the equation written above is precisely $$C_1=-\frac{1-e}{3-e}$$ Thus: $$f(x)=|1+C_1|e^x-C_1=\frac{2}{3-e}e^x+\frac{1-e}{3-e}$$