Hi,If we want to be able to trust the math, then the math needs to be correct. atan2() will only give us the correct angle for all four quadrants if the sign of each argument is maintained. You can't "factor it out". If you do, then there's no point using atan2() -- just use the normal atan() function.
Nope, I messed it up. I was too focused on getting the curly braces to render that I didn't pay close enough attention to the bigger picture. I've corrected that above. Thanks for catching it.
Yeah that's one thing i hate about Latex. Makes really nice math text, when it works right
Oh, about the -atan2(y,x), I did not 'factor out' the negative sign, if that's what you mean. I generalized it for a capacitor with a resistor only. I dont see any reason why we can't do this when we are concentrating on one thing only, and the numbers are bound to the problem (sometimes referred to as binding).
I think -atan2(y,x) is wrong, but when the signs are unchangeable, we can write -atan2(1,2) for example. But for more generality, when we write
-atan(n,m) when 'n' and 'm' are clearly taken to be both positive and the angle is always negative, then we can write it as -atan2(n,m). If either n or m or both can change sign, that would not be valid. I can give a few examples...(I am going to make this up randomly to keep it simpler)...
ph=atan2(-R/w,(R+w)/(w*C*L))
The imag part is negative, but all the variables are either 0 or greater than zero. This allows us to simplify.
First, 'w' is in the denominator of both imag and real parts, so it can be eliminated (but only because w>0):
ph=atan2(-R,(R+w)/(C*L))
That changes nothing.
Next, we can see that if R, w, C and L are all positive, then we have the case:
ph=atan2(-a,b)
where both a and b are positive (0 is a special case). Since 'y' is negative and 'x' is positive, the angle MUST be negative for all a and all b. Thus we can write:
ph=-atan2(a,b)
So although -atan2(a,b) is not correct all by itself, when we deal with real components we usually have positive values for R, C, and L and w, and if one or more is zero we have to check for a special case and state what it is if we want to be clear. This means:
ph=-atan2(a,b)
when it is clear that a and b are both positive and originally we had atan2(-a,b).
An example that would not work...
ph=-atan(R,K) or ph=-atan(K,R) would not work if we did not know the sign of K was fixed (we assume R is positive).
It's also true that if we do this reduction and R is not a more typical positive value, we have to be more careful. With:
ph=atan2(R,K) with R possibly being negative or positive, we cannot generalize to anything like ph=-atan2(...,...).
And that means the generalization could also be bound to the problem at hand, which for this discussion was an R and C in series.
Here is an actual example from a real circuit:
The imag part is: -(w*C*R1^2*R2)/(w^2*C^2*R1^2*R2^2+R2^2+2*R1*R2+R1^2)
and the real part is: (R1*R2+R1^2)/(w^2*C^2*R1^2*R2^2+R2^2+2*R1*R2+R1^2)
We can see that in the typical case we would assume w>0 and R1>0 and R2>0 and C>0, and that the denominators are the same, so this reduces to:
imag: -w*C*R1^2*R2
real: R1*R2+R1^2
and using the atan2() function this means we have the form:
atan2(-a,b)
where both a and b must be positive, and that reduces further to:
-atan2(a,b)
We do have to be careful though because in many cases we do include w=0 and that could lead to another result. In the case at hand we get lucky:
atan2(-a,b)=0
-atan2(a,b)=0
if w goes to zero.
I hope I did all the calculations correctly, but these kinds of generalizations are kind of typical because we usually want to get the expression into the simplest form possible. By stating -atan2(...,...) we are suggesting that the angle is always negative.
I think a lot of math software would automatically reduce the larger example above to -atan2(...,...) and then even reduce it more to:
-atan(a/b)
in cases where a and b are both positive and can never be negative (and zero is a special case of course). This probably depends on the math software.
If you spot any mistakes please let me know.