2
$\begingroup$

I need to code up the correct way my computer (in python) views the function $\sqrt(z^2+1)$. I want the branch cuts to extend from $i \to i\infty$ and from $-i \to -i\infty$.

I was hoping someone could suggest a way to write some pseudo code on how to do this, or give me a hint. It is more the implementation part I am having troubles understanding.

Edit: I do have some code I, but not sure this is the best place to post such a question. If someone could point me in the right direction that would also be helpful- i.e which stackexchange site.

$\endgroup$
6
  • $\begingroup$ The coding depends on the available functions and data types. If you have complex functions there is normally no need to do special things, i.e. just code your function as sqrt(z*z+1). The exception occurs, if the available sqrt function does not handle its branch cut $z\in \mathbb{R}, z<0$ correctly. $\endgroup$ – gammatester May 22 '14 at 9:57
  • $\begingroup$ What would be the best way to test that the function is actually doing what I think it is doing? Should I plot the real and imaginary parts of the function as I encircle a branch point? $\endgroup$ – Dipole May 22 '14 at 10:09
  • $\begingroup$ I would test the function values (escpecially the signs of the imaginary parts) for z values near or on the imaginary axis, e.g. for $$\;s\times 10^{-10} \pm 2i, \quad s\times 10^{-10} \pm 0.5i, \quad s=-1,0,1.$$ Here some values (compatible with Maple and Wolfram Alpha): $$f(-10^{-10} +2i) = 0.00000000011547 - 1.73205080756888\cdot i$$ $$f(+2i) = 1.73205080756888\cdot i$$ $$f( 10^{-10} +2i) = 0.00000000011547 + 1.73205080756888\cdot i$$ $$f(-10^{-10} -2i) = 0.00000000011547 + 1.73205080756888\cdot i$$ $\endgroup$ – gammatester May 22 '14 at 10:56
  • $\begingroup$ Thanks a lot! So my interpretation is then that, once you decide on the branch cuts you want for your function (after which we can assume the function is continuous along any path that does not cross these cuts) then, a method for checking that your function indeed performs as desired is to check that there is the expected 'jump' across the branch cuts (as you showed). Is that correct? $\endgroup$ – Dipole May 22 '14 at 11:02
  • $\begingroup$ Yes, assuming the function is computed 'correctly' otherwise (which can be difficult to show for numerical software where rounding/truncation errors or even bugs may be present). $\endgroup$ – gammatester May 22 '14 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.