[SciPy-user] Partial Derivatives
R. Padraic Springuel
rspringuel at smcvt.edu
Fri Mar 18 22:41:10 CST 2005
Well, after some figuring, I've come to the following conclusions.
Scientific.Functions.Derivatives is only for analytic functions. If you
have a numerical data set, you can't use it to get the derivative of the
function that describes that data set at a given point unless you know
what that function's analytical form. This means that it can be used in
place of scipy.derivative, but not scipy.central_diff_weights.
However, for its purpose it seems to work well. As written it works
with most functions within Numeric. It doesn't currently have
differentiation routines for arcsinh, arccosh, and arctanh, but adding
those is fairly easy (and a fix I've already made). It also can't
handle logn, log2, sec, csc, cot, arcsec, arccsc, arccot, sech, csch,
coth, arcsech, arccsch, and arccoth but I think that's more because
these functions are not defined by Numeric (likely because they all can
be written in terms of functions which are defined fairly easily). I'm
probably going to fix this at some point, I just have to figure out
where to put the definitions of these additional functions since ufuncs
(where the other basic mathematical functions are defined) is not editable.
The biggest issue I have with the package is an issue it inherits from
Numeric. For certain functions which have a limited domain for the real
range space, you have to explicitly tell numeric that your allowing for
the possibility of a complex answer by phrasing the input as a complex
number with a 0 imaginary component (i.e. sqrt(-3) doesn't work but
sqrt(-3+0j) does). In order for DerivVar to work in the part of the
domain that uses the non-real range you have to pull the same trick.
Now, the wrappers in scimath do quite nicely as a work around for this
difficulty for normal functions, but they don't work for DerivVar class
inputs. They weren't written with the DerivVar class in mind and raise
a TypeError when you try to put a DerivVar into them (even in the
"normal" domain for the function). I'm not quite sure how to fix this
issue yet, but I'm looking into it. I'm pretty sure it'll involve a
rewrite of _tocomplex in scimath, I'm just not sure how to do so yet.
If anyone has any ideas or suggestions, let me know. I'll make sure I
post my progress and will make the code available when its finished.
R. Padraic Springuel
More information about the SciPy-user