I am having a lot of trouble with this question. It is for a homework assignment so pls do not post the entire solution for me in the answers, I just want to know how to do it so I can do it myself.
So I've been, unfortunately, very absent in class and am having a hard time finding the correct approach after searching the internet and my textbook. Problem is, everyone is describing how to find expectance when there is only 1 interval (e.g.: $3x$ if $x<1, 0$ if $x\geq 1$) however in this question there are 2 intervals and the second interval also has variables in it unlike other questions which only have numbers of 0.
Anyways here is the question.
For the random variable X with density function
$$f(x) = \begin{cases}2x+1 &:& 0 \leq x \leq 1/2 \\[0.5ex] 2x/3 &:& 1/2 < x \leq 1 \\[0.5ex] 0 &:& \text{otherwise}\end{cases}$$

I apologize in advance if this is a stupid question or the answer is very simple. Thanks. I have added the picture in case the formatting makes the question look weird.
The function is defined over all real numbers, so your integral $E(X) = \int x \cdot f(x) dx$ is an integral over $(-\infty, \infty)$. However, you can easily ignore all the bits where it's zero, because they don't contribute to the total integral. So you can integrate over $[0, 1]$.
But what do you do, since the function is defined differently on $[0, \frac{1}{2}]$ and $(\frac{1}{2}, 1)$? Well, you do what you would do for any integral - you just split it up. $\int_0^1 x f(x) dx = \int_0^{\frac{1}{2}} x f(x) dx + \int_{\frac{1}{2}}^1 x f(x) dx$, and I assume you can do the integration from there.