Ask Your Question
0

Symbolic computation of a series expansion | Cauchy's theorem

asked 2024-10-05 00:08:39 +0100

Emm gravatar image

updated 2024-10-05 05:16:46 +0100

Max Alekseyev gravatar image

Let us assume we do not know the series expansion at $0$ of $$S : z\mapsto\frac{1}{1-(z/2)^2}$$ (consider a more difficult rational fraction if you do not want to make this assumption).

A method to compute the coefficients (*) is to compute a complex integral on a circle: the $k$-th coefficient is given by $$ a(k)=\frac{1}{2i\pi}\int_{C(0,1)}\frac{S(z)}{z^{k+1}}dz=\int_0^1S\left(\exp\left(2i\pi t\right)\right)\exp\left(-2i\pi kt\right) dt. $$

But, even in this easy case, I am not able to help Sagemath to do the computation:

kk,k,t,z=var('kk,k,t,z')
assume(k,'integer')
assume(k>0)
S(z)=1/(1-(z/2)^2)
J(kk)=integrate(S(e^(2*I*pi*t))*e^(-2*pi*I*kk*t),t,0,1,hold=True)

Appealing J(k) returns a mistake and requires an assumption on $I$ and $\pi$ :

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(%i*%pi>0)', see `assume?` for more details)
Is %i*%pi an integer?
  1. Any idea to perform the computation of this integral for any integer $k$ (I would like to have a symbolic answer in term of $k$, not a procedure that returns a numerical result for any numeric value of $k$)?
  2. Is there another way to get the coefficients (again meaning a general formula depending on k, like 1/k! for exp).

(*) Not the only one, one also could you a general result on the form of a sequence whose generating function is a rational fraction.

NB. A similar question was asked a few years ago, without positive answer. But situation might have evolved.

The full text Sage message :

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/maxima_lib.py:817, in MaximaLib.sr_integral(self, *args)
    816 try:
--> 817     return max_to_sr(maxima_eval(([max_integrate],
    818                                   [sr_to_max(SR(a)) for a in args])))
    819 except RuntimeError as error:

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/libs/ecl.pyx:838, in sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:11700)()
    837 lispargs = EclObject(list(args))
--> 838 return ecl_wrap(ecl_safe_apply(self.obj, (<EclObject>lispargs).obj))
    839 

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/libs/ecl.pyx:358, in sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:9207)()
    357     else:
--> 358         raise RuntimeError("ECL says: {}".format(message))
    359 else:

RuntimeError: ECL says: Maxima asks: Is %i*%pi an integer?

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 J(k)

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/expression.pyx:6187, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:78521)()
   6185         z^2 + x^y
   6186     """
-> 6187     return self._parent._call_element_(self, *args, **kwds)
   6188 
   6189 def variables(self):

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/callable.py:422, in CallableSymbolicExpressionRing_class._call_element_(self, _the_element, *args, **kwds)
    420 d = dict(zip([repr(_) for _ in self.arguments()], args))
    421 d.update(kwds)
--> 422 return SR(_the_element.substitute(**d))

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:849, in sage.structure.element.Element.substitute (build/cythonized/sage/structure/element.c:15440)()
    847     5
    848 """
--> 849 return self.subs(*args, **kwds)
    850 
    851 

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/expression.pyx:5899, in sage.symbolic.expression.Expression.subs (build/cythonized/sage/symbolic/expression.cpp:76733)()
   5897     smap.insert(make_pair((<Expression>self.coerce_in(k))._gobj,
   5898                           (<Expression>self.coerce_in(v))._gobj))
-> 5899 res = self._gobj.subs_map(smap, 0)
   5900 return new_Expression_from_GEx(self._parent, res)
   5901 

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/function.pyx:1137, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (build/cythonized/sage/symbolic/function.c:16410)()
   1135 res = self._evalf_try_(*args)
   1136 if res is None:
-> 1137     return self._eval0_(*args)
   1138 else:
   1139     return res

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/integration/integral.py:254, in DefiniteIntegral._eval_(self, f, x, a, b)
    252 for integrator in self.integrators:
    253     try:
--> 254         A = integrator(*args)
    255     except (NotImplementedError, TypeError,
    256             AttributeError, RuntimeError):
    257         pass

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/symbolic/integration/external.py:46, in maxima_integrator(expression, v, a, b)
     44     result = maxima.sr_integral(expression, v)
     45 else:
---> 46     result = maxima.sr_integral(expression, v, a, b)
     47 return result._sage_()

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/maxima_lib.py:827, in MaximaLib.sr_integral(self, *args)
    825     raise ValueError("Integral is divergent.")
    826 elif "Is" in s:  # Maxima asked for a condition
--> 827     self._missing_assumption(s)
    828 else:
    829     raise

File /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/maxima_lib.py:1074, in MaximaLib._missing_assumption(self, errstr)
   1071 outstr = "Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume("\
   1072     + errstr[jj + 1:k] + ">0)', see `assume?` for more details)\n" + errstr
   1073 outstr = outstr.replace('_SAGE_VAR_', '')
-> 1074 raise ValueError(outstr)

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(%i*%pi>0)', see `assume?` for more details)
Is %i*%pi an integer?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-10-05 16:23:57 +0100

Max Alekseyev gravatar image

Putting aside a weird technical issue with Maxima engine that you observed, it is generally not a good idea to use Cauchy's formula for computing coefficients of the series expansion as the resulting integrals are tough for evaluation. In particular, evaluating the one in question is well failed by Maple as well. Mathematica does evaluate it, but I'm not sure if you'd be satisfied with its result.

A more feasible approach is to compute a few coefficients numerically and then try to guess their formula - e.g. see https://ask.sagemath.org/question/68486/

edit flag offensive delete link more

Comments

Thanks Max. Indeed, for rational functions you can also use the general form of partial fractions decomposition implying that you only need to compute a finite number of coefficients to find and prove a general formula working in an algebraic extension (see e.g. Stanley, Enumerative combinatorics 1, Theorem 4.4.1). I am pretty sure that is can implemented and was wondering 1/ if this is already implemented in Sage 2/ If an more analytical approach would do something (well, if the integral computation require ultimately a partial fraction decomposition which is certainly the case, my question is a bit artificial).

Emm gravatar imageEmm ( 2024-10-05 16:47:19 +0100 )edit

Proving a formula for the coefficients is typically easier than deriving it. For example, one can employ symbolic summation or WZ method here.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-05 17:25:11 +0100 )edit

You may be interested in ore_algebrapackage for Sage: https://doc.sagemath.org/html/en/refe...

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-05 17:30:34 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-10-05 00:08:39 +0100

Seen: 222 times

Last updated: Oct 05