[SciPy-Dev] Feature proposal: automatic branch selection for arcsin(), arccos()

Nathaniel Smith njs@pobox....
Tue Mar 12 13:56:23 CDT 2013

On Tue, Mar 12, 2013 at 8:41 AM, Filip Dominec <filip.dominec@gmail.com> wrote:
> Dear scipy developers,
> it is well known that arccos(cos(x)) or similar expressions do not
> always return the value of the original argument, x. In this case, the
> sign as well as any 2*pi*n offset are lost by this operation; in other
> words, the solution of arccos() has many branches.
> For certain applications, however, it is necessary to reconstruct the
> original data, x, without any discontinuities. I have implemented such
> a proof-of-concept function for arccos_continuous(), which
> automatically switches the branch of solution so that the result of
> arccos_continuous(cos(x))==x, if the initial offset and sign are
> supplied.

It's hard to say without seeing the code, but certainly something like
this could be useful... my main concern personally would be to make
sure that the branch selection problem is sufficiently generic that it
has a single, general solution appropriate for implementation in a
generic, low-level library like numpy/scipy. If there's one sort of
automatic branch selection that the metamaterial people use, and
another that another field uses, then it makes a mess...

How arccos_continuous(x) different from unwrap(arccos(x))? I assume
arccos_continuous() uses a similar heuristic to unwrap() to select


More information about the SciPy-Dev mailing list