[sage-support] Re: Digamma Function in 4.1.1
I'm afraid I just don't know enough about this programming language yet to design this function before the final version of 4.1.2 is released. It seems to ignore any variation of a custom _integrate_. Here is what I have achieved so far if someone is interested in helping or further developing this function: class Function_psi(PrimitiveFunction): def __init__(self): """ Some description here. """ PrimitiveFunction.__init__(self, "psi", nargs=2, latex=r'\psi', conversions=dict(ginac='psi')) __call__ = SFunction.__call__ polygamma = Function_psi() def psi(a,b="default"): if b=="default": return polygamma(0,a) else: return polygamma(a,b) The definition at the bottom is necessary since Sage simplifies psi (0,x) to psi(x). Optional arguments are accepted only after the required arguments, therefore, I created this to convert back. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Tue, 22 Sep 2009 18:47:50 -0700 (PDT) The_Fool wrote: > > I managed to create the symbolic polygamma function as psi(order,x). > Psi is limited in what it can do, though. I can get it to grab > special values from Maxima's or GiNaC's table, but I still cannot get > it to approximate any value of any integer order. It can be > differentiated, but not integrated. It seems that this is a > limitation of Maxima and GiNaC, not Sage. 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 --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Sep 22, 9:47 pm, The_Fool wrote: > I managed to create the symbolic polygamma function as psi(order,x). > Psi is limited in what it can do, though. I can get it to grab > special values from Maxima's or GiNaC's table, but I still cannot get > it to approximate any value of any integer order. It can be > differentiated, but not integrated. It seems that this is a > limitation of Maxima and GiNaC, not Sage. Can you create a special _integral_ (or _integrate_, I forget which) method to do this? You can also ask for it to be LaTeXed appropriately, etc.; there are lots of good examples in the files mentioned earlier in this thread, though if Ginac knows about it, there may already be a representation. See also the upgraded Pynac package, trac ticket #6993, which you may want to work off of. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
I managed to create the symbolic polygamma function as psi(order,x). Psi is limited in what it can do, though. I can get it to grab special values from Maxima's or GiNaC's table, but I still cannot get it to approximate any value of any integer order. It can be differentiated, but not integrated. It seems that this is a limitation of Maxima and GiNaC, not Sage. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
I meant to say that I created the polygamma function as psi(order,x), not polygamma(order,x). --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
I managed to create the symbolic polygamma function as polygamma (order,x). Polygamma is limited in what it can do, though. I can get it to grab values from Maxima's or GiNaC's table, but I still cannot get it to approximate any value of any integer order. It can be differentiated, but not integrated. It seems that this is a limitation of Maxima and GiNaC, not Sage. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Mon, 21 Sep 2009 22:29:33 -0700 (PDT) The_Fool wrote: > 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. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Sep 21, 2009, at 10:29 PM, The_Fool wrote: > > On Sep 21, 9:37 pm, Jason Grout wrote: >> 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" >> > I am currently using the Ubuntu 9.04 64-bit binary. Using ./sage -br > or ./sage -b causes an error and prevents Sage from working > afterward. Starting Sage normally also no longer works after > rebuilding. > Using ./sage -br ends with this error: > > ImportError: libcsage.so: cannot open shared object file: No such file > or directory > Error importing ipy_profile_sage - perhaps you should run %upgrade? > WARNING: Loading of ipy_profile_sage failed. > > > > > 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. 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 --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Sep 21, 9:37 pm, Jason Grout wrote: > 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" > I am currently using the Ubuntu 9.04 64-bit binary. Using ./sage -br or ./sage -b causes an error and prevents Sage from working afterward. Starting Sage normally also no longer works after rebuilding. Using ./sage -br ends with this error: ImportError: libcsage.so: cannot open shared object file: No such file or directory Error importing ipy_profile_sage - perhaps you should run %upgrade? WARNING: Loading of ipy_profile_sage failed. 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. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
The_Fool wrote: > Does anyone know which files are used for Sage? I need to know where > from Sage's root directory to make this modification. 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 --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
Does anyone know which files are used for Sage? I need to know where from Sage's root directory to make this modification. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Sep 19, 10:33 am, Burcin Erocal wrote: > On Fri, 18 Sep 2009 15:47:45 -0700 (PDT) > > Defining a function psi, similar to the way arctan2 is defined in line > 422 of sage/functions/trig.py should fix this. What is the location from Sage's root directory of the files used by Sage? I found several locations of sage/functions/trig.py. I found in the pdf of the reference manual that psi can be numerically calculated by using PARI (for example, pari(2.2342).psi()), but it still cannot be used symbolically or used to plot until the function psi is defined. --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: Digamma Function in 4.1.1
On Fri, 18 Sep 2009 15:47:45 -0700 (PDT) The_Fool wrote: > 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 --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---