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

Gustavo Goretkin gustavo.goretkin at gmail.com
Tue Mar 12 13:59:53 EDT 2013


If the function relies on stored state, won't there be issues if you call
the function from different places in your code "simultaneously"?
On Mar 12, 2013 4:41 AM, "Filip Dominec" <filip.dominec at 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.
>
> Moreover, after having spent next few evenings experimenting, I also
> * reimplemented the algorithm so that it does not explicitly process
> the arrays point-by-point, but it only uses the numpy/scipy functions
> that operate on the whole array efficiently;
> * enabled output and input of the internal branch selection variables
> (so the x array may be split into several blocks, and still the
> arccos_continuous() does not forget the branch between consecutive
> calls).
>
> Do you think such functions could be added to scipy, probably in some
> sub-module? Branch-aware version of arccos() is crucial, e. g., for
> elegant computation of metamaterial effective parameters.
>
> I am looking forward to read your comments,
> Filip
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20130312/33f9ac00/attachment.html>


More information about the SciPy-Dev mailing list