Q:

Indefinite integral with product rule

Assume the following integral:
$$\int \sin x \cos x\ \ dx $$
My understanding now is, that I can choose both for $f(x)$ and $g'(x)$ respectively, leading to different results:
$$f(x) = \sin x$$
$$g'(x) = \cos x$$
Leads to the result:
$$\frac{\sin^2x}{2} + c$$
Switching it around:
$$f(x) = \cos x$$
$$g'(x) = \sin x$$
Leads to:
$$-\frac{\cos^2x}{2} + c$$
Now, I know that deriving both results will give $\sin x \cos x$, so I guess it is correct, but I just find it strange that there are different possible results. According to this question this is not a problem, so what I am asking here is simply:

If I derive the result of my integration and I get back the original term, is this sufficient to know that my answer is correct or are there cases where deriving the result yields the original term but the result is still incorrect?
(Less important) Are both my answers correct?

A:

$$
\left(\frac{\sin^2 x}{2} +\text{constant}\right) \text{ is the same thing as }\left(\frac{-\cos^2 x}{2} +\text{constant}\right),
$$
but the two "constants" are different.  It's just a trigonometric identity:
$$
\frac{\sin^2 x}{2} +\text{constant} = \frac{1-\cos^2 x}{2}+\text{constant} = \frac{-\cos^2 x}{2} + \frac12+\text{constant}
$$
and then $\dfrac12+\text{constant}$ is also a constant.
I'm not sure exactly what you have in mind in your question #1, but if you do things correctly, the result will be correct.
You appear to be integrating by parts in a problem in which integration by substitution would be quicker.  You have
$$
\int f(x)g'(x)\,dx = f(x)g(x) - \int f'(x)g(x)\,dx.
$$
That means that if you find any antiderivative of $f'(x)g(x)$ and any antiderivative of $f'(x)g(x)$ and put the former in place of the integral on the right and the latter in place of the integral on the left, then the expressions on the two sides of the equality will differ by some constant.  Which constant it is depends on which antiderivative you find.
However, there is this other complication: the difference between the two sides, casually reported to be a "constant", is actually constant on each connected component of the domain separately.  For example, suppose the functions on the two sides of the equality are undefined at $x=5$.  That "disconnects" the domain into separate components: numbers greater than $5$ and numbers less than $5$.  It may happen that the "constant" on one of those two components differs from the "constant" on the other component.  In that sense the function is not actually constant, but its restriction to any connected component of the domain is constant.  None of this affects the present problem.

A:

The indefinite integral of a function is defined to be the same as an anti-derivative.  This means if you take the derivative of the resulting function, and it matches what you had at the beginning, then you have performed the indefinite integral correctly.
In general if two functions are differentiable on an interval $[a,b]$ and they have the same derivative, then the two functions must differ by a constant.  Both of your answers are correct.
In fact if you want to have some fun, take a real number, $a$, and compute the derivative of $$f(x) = a \frac{\sin^2(t)}{2} + (1-a) \frac{\cos^2(t)}{2} + C$$ and you will see that this also has the same derivative.

