[SciPy-Dev] Feature proposal: automatic branch selection for arcsin(), arccos()
Filip Dominec
filip.dominec@gmail....
Tue Mar 12 03:41:10 CDT 2013
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
More information about the SciPy-Dev
mailing list