Dear Tim, Waldek,
Waldek Hebisch <[EMAIL PROTECTED]> writes:
> I supect that original author did not know how to leave one partial
> derivative unevaluated, while giving value of the second one (ATM this
> is not clear for me either). If you know how to to this please go
> on.
below is a patch that has the behaviour as you described it, with the exception
of polygamma, which now throws an error. If you prefer that polygamma also
allows differentiation with respect to the first argument, the change is
trivial. I don't have time to modify sttaylor right now.
Martin
Index: combfunc.spad.pamphlet
===================================================================
--- combfunc.spad.pamphlet (revision 580)
+++ combfunc.spad.pamphlet (working copy)
@@ -41,11 +41,6 @@
++ formal product;
@
-The latest change allows Axiom to reduce
-\begin{verbatim}
- sum(1/i,i=1..n)-sum(1/i,i=1..n)
-\end{verbatim}
-to reduce to zero.
<<package COMBF CombinatorialFunction>>=
)abbrev package COMBF CombinatorialFunction
++ Provides the usual combinatorial functions
@@ -690,6 +685,7 @@
OP ==> BasicOperator
K ==> Kernel F
SE ==> Symbol
+ SPECIALDIFF ==> "%specialDiff"
Exports ==> with
belong? : OP -> Boolean
@@ -818,14 +814,58 @@
-- Default behaviour is to build a kernel
evaluate(opGamma, iiGamma)$BasicOperatorFunctions1(F)
evaluate(opabs, iiabs)$BasicOperatorFunctions1(F)
+@
+\subsection{differentiation of special functions}
+
+In the following we define the symbolic derivatives of the special functions we
+provide. The formulas we use for the Bessel functions can be found in Milton
+Abramowitz and Irene A. Stegun, eds. (1965). Handbook of Mathematical
+Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover. ISBN
+0-486-61272-4, Equations~9.1.27 and 9.6.26. Up to [[patch--50]] the formula
+for $K$ missed the minus sign. (Issue~\#355)
+
+We do not attempt to provide formulas for the derivative with respect to the
+first argument currently. Instead, we leave such derivatives unevaluated.
+
+<<package FSPECF FunctionalSpecialFunction>>=
import Fraction Integer
ahalf: F := recip(2::F)::F
athird: F := recip(2::F)::F
twothirds: F := 2*recip(3::F)::F
+@
- lzero(l: List F): F == 0
+We need to get hold of the differentiation operator as modified by
+[[FunctionSpace]]. Otherwise, for example, display will be ugly. We accomplish
+that by differentiating an operator, which will certainly result in a single
+kernel only.
+<<package FSPECF FunctionalSpecialFunction>>=
+ dummyArg: SE := new()$SE
+ opdiff := operator first kernels D((operator(new()$SE)$BasicOperator)
+ (dummyArg::F), dummyArg)
+@
+
+The differentiation operator [[opdiff]] takes three arguments corresponding to
+$$
+F_{,i}(a_1,a_2,\dots,a_n):
+$$
+\begin{enumerate}
+\item $F(a_1,...,dm,...a_n)$, where the $i$\textsuperscript{th} argument is a
+ dummy variable,
+\item $dm$, the dummy variable, and
+\item $a_i$, the point at which the differential is evaluated.
+\end{enumerate}
+
+The operation [[symbolicGrad]] returns the first component of the gradient of
+[[op l]].
+
+<<package FSPECF FunctionalSpecialFunction>>=
+ dummy == new()$SE :: F
+ symbolicGrad(op: BasicOperator, l: List F): F ==
+ dm: F := dummy
+ kernel(opdiff, [op [dm, second l], dm, first l])
+
iBesselJGrad(l: List F): F ==
n := first l; x := second l
ahalf * (besselJ (n-1,x) - besselJ (n+1,x))
@@ -837,10 +877,19 @@
ahalf * (besselI (n-1,x) + besselI (n+1,x))
iBesselKGrad(l: List F): F ==
n := first l; x := second l
- ahalf * (besselK (n-1,x) + besselK (n+1,x))
- ipolygammaGrad(l: List F): F ==
- n := first l; x := second l
- polygamma(n+1, x)
+ - ahalf * (besselK (n-1,x) + besselK (n+1,x))
+
+@
+
+For the moment we throw an error if we try to differentiate [[polygamma]] with
+respect to the first argument.
+
+<<package FSPECF FunctionalSpecialFunction>>=
+ ipolygammaGrad(l: List F, x: SE): F ==
+ member?(x, variables first l) =>
+ error "cannot differentiate polygamma with respect to the first argument"
+ n := first l; y := second l
+ differentiate(y, x)*polygamma(n+1, y)
iBetaGrad1(l: List F): F ==
x := first l; y := second l
Beta(x,y)*(digamma x - digamma(x+y))
@@ -852,18 +901,17 @@
iGamma2Grad(l: List F):F ==
a := first l; x := second l
- x ** (a - 1) * exp(-x)
- derivative(opGamma2, [lzero, iGamma2Grad])
+ derivative(opGamma2, [symbolicGrad(opGamma2, #1), iGamma2Grad])
derivative(opabs, abs(#1) * inv(#1))
derivative(opGamma, digamma #1 * Gamma #1)
derivative(opBeta, [iBetaGrad1, iBetaGrad2])
derivative(opdigamma, polygamma(1, #1))
- derivative(oppolygamma, [lzero, ipolygammaGrad])
- derivative(opBesselJ, [lzero, iBesselJGrad])
- derivative(opBesselY, [lzero, iBesselYGrad])
- derivative(opBesselI, [lzero, iBesselIGrad])
- derivative(opBesselK, [lzero, iBesselKGrad])
-
+ setProperty(oppolygamma, SPECIALDIFF, ipolygammaGrad@((List F, SE)->F) pretend None)
+ derivative(opBesselJ, [symbolicGrad(opBesselJ, #1), iBesselJGrad])
+ derivative(opBesselY, [symbolicGrad(opBesselY, #1), iBesselYGrad])
+ derivative(opBesselI, [symbolicGrad(opBesselI, #1), iBesselIGrad])
+ derivative(opBesselK, [symbolicGrad(opBesselK, #1), iBesselKGrad])
@
\section{package SUMFS FunctionSpaceSum}
<<package SUMFS FunctionSpaceSum>>=
_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer