> While working with the derivative of the Gamma function, the digamma
> function is obviously involved. The sage "diff" function does show Γ
> '(x) == Γ(x)ψ(x) like it should, however, the digamma function (called
> psi in sage) is not defined whenever I try to do anything with it. It
> seems as if only the output of "diff" can use this function.
This is because GiNaC (the library Sage uses for symbolic expressions)
knows about the digamma function, but Sage doesn't.
> Is there any way to permanently keep this function defined so I can
> plot with it, conduct symbolic and numeric calculations with it, and
> so on like any other function?
Defining a function psi, similar to the way arctan2 is defined in line
422 of sage/functions/trig.py should fix this.
I opened a ticket:
http://trac.sagemath.org/sage_trac/ticket/6961
Thanks.
Burcin
I have my root sage installation in ~/sage
The files for me are in ~/sage/devel/sage/
So the trig.py file mentioned previously is in
~/sage/devel/sage/sage/functions/trig.py
After modifying a file, do:
sage -br
which copies the modified files to the build directory and rebuilds Sage
and then runs Sage. To just rebuild, just do "sage -b"
Jason
--
Jason Grout
sage -b is still a bit rocky for binary downloads. (It shouldn't be,
it's a known bug.) I'd recommend compiling from source, it's not that
hard (though does take a while) and then you'll probably have a lot
fewer issues developing.
- Robert
<snip info on how sage -br renders a binary install useless>
> Typing %upgrade tells me to delete a hidden file and retry the
> command. Sage still doesn't work after I do. The same situation
> occurred after I reinstalled Sage, ran the program, upgraded, modified
> a file, and rebuilt again. I may just download the source code, make
> the modification, and completely build Sage for my system.
As a workaround you can also just implement the function in a .py file
somewhere and use the "load" or "attach" commands to make it available
from Sage.
If you go this way, it would be great if you upload your implementation
somewhere, so someone can turn it into a patch for the Sage library.
Thanks.
Burcin
P.S. Sorry for not replying earlier. I'm very busy trying to finish
things before I leave for vacation next week.
You're right, looking at the functions py_psi() and py_psi2() in
sage/symbolic/pynac.pyx (I'm not giving line numbers since my file is
heavily patched.), I see that they just raise NotImplementedError.
You could have a go at implementing these functions using the psi
function from mpmath:
http://mpmath.googlecode.com/svn/tags/0.13/doc/build/functions/gamma.html#mpmath.functions.psi
There is an example of how to call mpmath in the function py_li of
sage/symbolic/pynac.pyx.
If you post your code I can give some more pointers on how to use the
pynac library better. For now, if you derived you class from
sage.symbolic.function.PrimitiveFunction, I suggest not using the approx
option, and using the __call__ = SFunction.__call__ line to bypass the
__call__ method implemented in that class. This was done by the arctan2
function in sage/functions/trig.py which I gave as an example.
I will not have internet access for a few days starting tomorrow. I'll
try to catch up with e-mails once I'm back.
Thanks.
Cheers,
Burcin