JuliaMath / Calculus.jl

Calculus functions in Julia
Other
278 stars 76 forks source link

Fix derivative of airyprime and add more derivatives #93

Closed giordano closed 8 years ago

giordano commented 8 years ago

The docstring of airy function is wrong (see https://github.com/JuliaLang/julia/issues/17032), that probably led to a wrong definition of the derivative of airyprime.

I also propose definition of new derivatives: frexp, deg2rad, rad2deg, erfinv, erfcinv, invdigamma.

mlubin commented 8 years ago

@giordano, could you perhaps suggest a qualified reviewer for this?

giordano commented 8 years ago

Excuse me, what do you mean by a qualified reviewer?

mlubin commented 8 years ago

@giordano, someone in the julia community who is familiar with these special functions, can check for correctness and give a :+1:

giordano commented 8 years ago

I thought that paper and pencil suffices :-) Actually, the only problem is that frexp returns a tuple, the derivative I gave is only for the first element of the tuple, for the second one is zero. I'm not sure the syntax is correct for a tuple-valued function. Please tell me what to do with this function.

The derivatives of erf*inv functions are on Mathworld Wolfram, as I wrote in the commit message, the derivatives of deg2rad and rad2deg are obvious.

I just noticed I mistype the derivative of invdigamma, should be inv(trigamma(invdigamma(x))), see https://en.wikipedia.org/wiki/Inverse_functions_and_differentiation. I'm going to fix it.

I use all these derivatives in Measurements.jl package (the derivative of invdigamma is correct there). In the runtests.jl file I use analytical relations to be sure they're correct (like ldexp(frexp(x)...) ≈ x, erfinv(erf(x)) ≈ x, erfcinv(erfc(x)) ≈ x, digamma(invdigamma(x)) ≈ x)

mlubin commented 8 years ago

@giordano, this list is only for univariate functions. frexp isn't univariate so it doesn't belong there. You could try generalizing the infrastructure that's there for bessel functions.

giordano commented 8 years ago

Fine, I removed frexp. I don't think I'm going to undertake that task, but if someone is willing to do that, the derivative is in the history.

giordano commented 8 years ago

BTW, I don't understand why the derivatives of the erfcx and dawson functions are marked as "uncertain". For what I know, they're correct. The history doesn't help in understanding why they're marked as such.

mlubin commented 8 years ago

@giordano, no idea, you're welcome to open a PR