Arc tangent of a complex number

I am trying to solve a problem that involves complex number. The original expression is extremely long but after debugging for several hours, I have identified the source of my error. When I do an arc tangent of the expression, with different values for the variable which are extremely close, the value jumps by order of magnitude.

The expression is: atan(var_z* (0.058659782 - 0.35747651i))*(161669.61 - 26529.028i)

When I use var_z = -20+3.282i, the value I get is 257585.794 - 19514.30i . When I use the value of var_z = -20+3.281i , the value I get is -250313.14 + 63829.09i .

What could be causing this? The expression is not supposed to have any step function. This is causing a big jump/discontinuity in my answer.

I feel like matlab is somehow messing up the atan function. Any help would be very much appreciated.

The real parts of the $\arctan$ function values without the factor jump by $\pi$ from $\approx -\tfrac{\pi}{2}$ to $\approx \tfrac{\pi}{2}:$

$$\arctan(( -20+3.281\cdot i)w) = -1.57079037+0.137054543\cdot i$$ $$\arctan(( -20+3.282\cdot i)w) = +1.57079553+.0137053434\cdot i$$

with $w=0.058659782 - 0.35747651\cdot i$.

Edit: For the arguments values you have

$$( -20+3.281\cdot i)w = -0.00031521069+7.34199294\cdot i$$ $$( -20+3.282\cdot i)w = +0.00004226582+7.34205160\cdot i$$ which are near the branch cut $\{ti: t\in\mathbb{R}, |t|\ge 1\}$ (see http://dlmf.nist.gov/4.23.ii), but at opposite sides. Your huge difference is the result of multiplying $\pi$ with $161669.61 - 26529.028\cdot i$.

The jump is normal, because you use the principal branch of $\arctan$.

• Why is the real part switching signs when the input was reduced by just 0.001i? – John Joe Nov 14 '17 at 21:38
• See the edit.  – gammatester Nov 14 '17 at 22:26
• Thank you! That explains the math. I think I am making some other mistakes in my code. – John Joe Nov 15 '17 at 4:08