Why does $\int xf(x) \neq 0$? Using integration by parts we get that this is equal to
$$x \int f(x)dx - \int \left(\int f(x) dx\right)dx$$ 
I thought that this is the same as
$$x \int f(x)dx - \int 1 dx\int f(x) dx$$ 
which is the same as 
$$x \int f(x) dx - x \int f(x) dx$$ 
However computing the definite integral with $f(x) = e^x$ from $0$ to $1$ gives $1$.
Which step is wrong? I am assuming it is the step where I separate the double integral into the product of two integrals but I am not sure how else to compute the double integral. For example the function I am working with is $f(x) = 1$ if $x>0.5$ and $f(x)=0 $ otherwise and I am computing the definite integral from $0$ to $1$.
 A: To avoid confusion I will use $u$ rather than $x$ for dummy and also $F(x)=\int^xf(u)du$.  $\int^xuf(u)du=xF(x)-\int^xF(u)du$.  This last term is not the same as $\int^x1duF(x)$, which is what you have.
A: Integrating by parts, say on $[a,b]$, you'll get 
$$
\int\limits_a^b xf(x)dx = \left.x\left(\int\limits_a^x f(t)dt+ C\right)\right|^b_a - \int\limits_a^b \left(\int\limits_a^x f(t) dt +C\right)dx 
$$
The inner integral that you wrote is a primitive for $f$, not a number. 
A: Call $F$ an antiderivative of $f$; thus integration by parts becomes
$$
\int xf(x)\,dx=xF(x)-\int F(x)\,dx
$$
Can you spot your false argument now?
A: When you are integrating a function f(x), 
$$\int(f(x)dx)= x*f(x) - \int(x*f’(x)dx) $$ 
Where f’(x) is the derivative of f(x).
When integrating another time, you’ll have:
$$\int xf(x).dx -\int \int xf’(x)dx dx $$
Which is different than your second term, thus the equation you are calculating won’t be equal to 0.
If you want, I can solve it for you on the f(x) = e^x  example
