You keep having the same misunderstandings.
This is true.
TE = 1/2*m*v^2 + 1/2*k*x^2
This is where you've introduced terms without any reason, and begun to make your false conclusion:
TE = 1/2*m*v^2*cos(theta) + 1/2*k*x^2*i*sin(theta)
Neither component of total energy should ever go negative in this situation. KE can't be negative, since rest is the slowest it can move. By convention of letting PE equal zero at x=0, the lowest PE can also be is zero. So it doesn't make sense to just multiply them by cos(theta) and i*sin(theta) like you have done.
This is how you really should approach what you are trying to do.
x(t) = A*sin(w*t)
v(t) = A*w*cos(w*t)
The known general solutions for x as a function of time, and its derivative, v as a function of time. A is amplitude and w is angular frequency. You can make A & w both equal to 1 for simplicity, but I'll keep them for the general case.
Take these equations, and substitute them in to the equation for each form of energy:
PE = 1/2*k*x^2
PE = 1/2*k*(A*sin(w*t))^2
PE = 1/2*k*A^2*sin(w*t)^2
sin(w*t)^2 = 1/2 - 1/2*cos(2*w*t)
PE = 1/4*k*A^2*(1 + cos(2*w*t))
KE = 1/2*m*v^2
KE = 1/2*m*(A*w*cos(w*t))^2
KE = 1/2*m*A^2*w*cos(w*t)^2
cos(w*t)^2 = 1/2 + 1/2*cos(2*w*t)
KE = 1/4*m*A^2*w^2*(1 + cos(2*w*t)
Using the standard known solution that w^2 = k/m, we can see that:
KE = 1/4*k*A^2*(1 + cos(2*w*t))
Neither of these energy values are ever negative, or imaginary. These both are based on cosine functions of time that always add up to the same total energy (TE = 1/2*k*A^2), but not at the same frequency as the original functions x(t) and v(t), and they are not centered on zero.