I am trying to find the MLE of $\theta=(\theta_1,\theta_2)$ in a random sample $\{X\}_{i=1}^n$ with the following pdf
$$f(x\mid\theta)= \begin{cases} (\theta_1+\theta_2)^{-1}\exp\left(\frac{-x}{\theta_1}\right) &, x>0\\ (\theta_1+\theta_2)^{-1}\exp\left(\frac{x}{\theta_2}\right) &, x\le0\\ \end{cases} $$
If I let $\bar{X}_1$ be the average of the $n_1$ values where $X_1>0$ and $\bar{X}_2$ the average of $n_2$ values where $X_i\le 0$ and $n_1+n_2=n$ Then the likelihood function is: $$L(\theta\mid X)=\left(\frac 1 {\theta_1+\theta_2}\right)^n\exp\left(\frac{-n_1\bar{X}_1}{\theta_1}+\frac{n_2\bar{X}_2}{\theta_2}\right)$$
but I am having trouble maximizing this function.
Working with the log-likelihood is easier. We write $$\ell(\theta_1, \theta_2 \mid n_1, n_2, \bar x_1, \bar x_2) = -(n_1 + n_2) \log (\theta_1 + \theta_2) - \frac{n_1 \bar x_1}{\theta_1} + \frac{n_2 \bar x_2}{\theta_2}.$$ Note that this function is subject to the restrictions $$\theta_1, \theta_2 > 0, \quad n_1, n_2 \in \mathbb Z^+, \quad \bar x_1 > 0, \quad \bar x_2 \le 0.$$ Taking the partial derivatives with respect to $\theta_1$, $\theta_2$ and equating these to $0$ yield respectively $$\frac{\partial \ell}{\partial \theta_1} = -\frac{n_1 + n_2}{\theta_1 + \theta_2} + \frac{n_1 \bar x_1}{\theta_1^2} = 0, \\ \frac{\partial \ell}{\partial \theta_2} = -\frac{n_1 + n_2}{\theta_1 + \theta_2} - \frac{n_2 \bar x_2}{\theta_2^2} = 0.$$ I leave it as an exercise for you to solve this simultaneous system (it is not difficult) and show that the unique critical point is $$(\theta_1, \theta_2) = \left(\frac{n_1 \bar x_1 + \sqrt{-n_1 \bar x_1 n_2 \bar x_2}}{n_1 + n_2}, \frac{-n_2 x_2 + \sqrt{-n_1 \bar x_1 n_2 \bar x_2}}{n_1 + n_2}\right),$$ which would suggest that it is better to use the sufficient statistics $$T_1 = \sum_{i=1}^n X_i \mathbb 1(X_i > 0), \quad T_2 = - \sum_{i=1}^n X_i \mathbb 1(X_i \le 0);$$ that is to say, $T_1$ is the sample total of positive observations, and $T_2$ is the negative of the sample total of negative or zero observations (thus is negative or zero). Then we may rewrite the joint MLE as $$(\hat \theta_1, \hat \theta_2) = \left(\frac{T_1 + \sqrt{T_1 T_2}}{n}, \frac{T_2 + \sqrt{T_1 T_2}}{n} \right),$$ which makes the symmetry apparent and does away with the auxiliary variables $n_1, n_2$.