Specifying a limit for a symbolic function?

asked 2022-03-28 12:08:18 +0100

eatdust gravatar image

updated 2022-03-31 22:30:48 +0100

slelievre gravatar image

Hi there,

I am working with symbolic functions, and I do have a lot of integration by parts to be done, in which I have to evaluate some exact derivative terms at infinity.

I am defining this symbolic function, specifying its derivative.

def deriv_F_0(self, *args, **kwds):
    return -exp(2*i*args[kwds['diff_param']])/args[kwds['diff_param']]

F_0 = function('F_0', nargs=1, derivative_func=deriv_F_0)

It works fine, but, I would also like to add to it an option like "limit_func" doing this:

F_0 = function('F_0', nargs=1, derivative_func=deriv_F_0, limit_func=mylimit_F_0)

where "mylimit_F_0" would be a function of mine. Notice that my problem is just that "limit_func" does not exist :)

For instance, I could set:

def mylimit_F_0(self, x):
   if bool(x==infinity):
      return pi

the goal being to specify various asymptotic limits, and makes this

F_0(x).limit(x=infinity)

returning the value I specify, here pi.

I have started SageMath a few days ago, so any help welcome! Let me know if there are any alternative methods for setting limit on symbolic functions!

Cheers, chris.

edit retag flag offensive close merge delete

Comments

A similar argument could be made in favor of specifying an antiderivative...

As far as I know, the only way is to define a new function by deriving a new class from the appropriate parent class : how to do this exactly depends, IIRC, of what exactly you want to implement.

The "right" source of inspiration is probably Sage's symbolic functions source files. I have played a bit with them and implemented a couple of toys, but I couldn't for dear life recall exactly how tonight...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-03-31 22:20:07 +0100 )edit