Looking at the solution for from this site I'm a bit confused on how two quantities necessarily reduce.
I'm given this wavefunction
$$ \psi(x) = \begin{cases} Ax & 0<x<a/2 \\ A(a-x) & a/2 < x < a \\ 0 & \text{otherwise} \end{cases} $$
If I take the derivative, we can express it as a step function.
$$ \frac{\partial\ \psi(x)}{\partial x} = \begin{cases} A & 0<x<a/2 \\ -A & a/2 < x < a \\ 0 & \text{otherwise} \end{cases} $$
$$ = A[ \theta(x) - \theta(x-\frac{a}{2}) - \theta(x-\frac{a}{2}) + \theta(x-a) ] $$
** First Question **
How does the step function reduce to this?
$$ A[ \theta(x) - \theta(x-\frac{a}{2}) - \theta(x-\frac{a}{2}) + \theta(x-a) ] = -A(2 \theta(x-\frac{a}{2})-1) $$
where did the one come from?
So with that that quantity, I take second derivative to get
$$ \frac{\partial^2\ \psi(x)}{\partial^2 x} = -2A\ \delta(x-\frac{a}{2})$$
** Second Question **
So now what is left is integrating my second derivative with my step function, in which I have no idea which terms vanish.
$$ \int_{-\infty}^{\infty} \psi^{*} \frac{\partial^2\ \psi(x)}{\partial^2 x}dx = A \int_{0}^{a/2} x \delta(x-a/2) dx + A \int_{a/2}^{a} a \delta(x-a/2) dx - A \int_{a/2}^{a} x \delta(x-a/2) dx $$
How do I go about this and what is the reasoning?
For your first question, the expression $$ \psi'(x) = -A(2 \theta(x-\frac{a}{2})-1) $$ is not valid on $(-\infty,+\infty)$, it is only valid on $[0,a]$. The actual expression is $$ \psi'(x) = \left\{ \begin{array}{cl} -A(2 \theta(x-\frac{a}{2})-1) & 0\leq x\leq a \\ 0 & \mbox{otherwise} \end{array} \right.$$
Now on $[0,a]$, the two terms from the original expression $$ \forall x \in [0,a]: A[ \theta(x) +\theta(x-a)] = A $$ because in that interval, $\theta(x) = 1$ and $\theta(x-a)=0$.
Then the $-1$ comes about because you need to add $A$, but the outside multiplier is $-A$.
For your second question, first notice that the restriction to only $0\leq x \leq a$ is made implicitly because only that range is covered by the integrals on the right side.
But if you want $\int \psi^* \psi'' dx$ your expressions on the right are missing the $\psi^*$ (which equals $\psi$ here).
And here is the major point: You don't want to break up the integral at $a/2$, because integrating to the "business point" of a delta function gives you subtle results that depend on the details of the delta function limit, and that is something that is never right or necessary to do.
$$\int_{-\infty}^\infty \psi^*\psi''dx = -2A\int_0^a \psi(x)\delta(x-a/2)\,dx = -2A \psi(a/2) = -2A(\frac{Aa}{2})= -A^2a $$