Robert Dodier suggests :

(%i12) sumcontract (intosum (sum(X(i),i,1,n+1)-sum(X(i),i,1,n)));
(%o12)                             X(n + 1)


Indeed :

sage: 
maxima.sumcontract(maxima.intosum(sum(X(j),j,1,p+1)-sum(X(j),j,1,p))).sage
....: ()
X(p + 1)

But :

sage: 
(sum(X(j),j,1,p+1)-sum(X(j),j,1,p)).maxima_methods().intosum().maxima_meth
....: ods().sumcontract()
sum(X(j), j, 1, p + 1) - sum(X(j), j, 1, p)

That seems to indicate that relevant methods/functions might be of interest 
in Sage...

I also note that our use of Maxima's product() is wrong, wrong, wrong :

sage: maxima.product(X(j),j,1,p).sage()
X(j)^p

Mamma mia !!! I'll check the list of known bugs and, if not present, file 
the relevant ticket.

BTW, a quick look at Sympy's, Mathematica's and Maple's possibilities in 
this domain seems to indicate that the "sum and products" department has 
been somewhat neglected.

Similarly, I think that special cases for sums and product could be 
implemented in log() and exp() (and possibly for (hyperbolic) trig 
functions). But that needs a bit (!) of further thought...

HTH,

--
Emmanuel Charpentier

Le jeudi 29 décembre 2016 17:31:31 UTC+1, Emmanuel Charpentier a écrit :
>
> Dear Nils, dear list,
>
> Le mercredi 28 décembre 2016 20:59:50 UTC+1, Nils Bruin a écrit :
>>
>> On Wednesday, December 28, 2016 at 6:18:28 AM UTC-8, Emmanuel Charpentier 
>> wrote:
>>>
>>> I d not understand what is possible and not possible about sums with 
>>> Sage (and its minions).
>>>
>>> I am interested in the symbolic manipulation of a sum of (unspecified) 
>>> data series X. Since Sage does nott (yet) admits indiced symbolic variable, 
>>> it is reprsented by a function of an integer argument.
>>>
>>> Sage seems unable to show that 
>>> $\sum_{i=1}^{p+1}X_i-\sum_{i=1}^pX_i==X_{p+1}$ :
>>>
>>> sage: var("p,j", domain="integer")
>>> ....: assume(p,"integer",j,"integer",p>0)
>>> ....: X=function("X")(j)
>>>
>>
>> You can avoid the warning downstairs by simply setting X=function("X") or 
>> (because of the side-effects of toplevel function, just function("X") . 
>>
>>> ....: foo(p)=sum(X(j),j,1,p)
>>>
>>
>> This has the nasty sideeffect of clobbering "p" (which in your case 
>> doesn't make any difference, I think). Calling
>>
>> foo = sum(x(j),j,1,p).function(p)
>>
>
> A nice one ! I didn't think of it. 
>
>>
>> has a cleaner result. 
>>
>>
>> ....: print foo
>>> ....: bool(foo(p+1)-foo(p)==X(p+1))
>>> ....: 
>>> (p, j)
>>> /usr/local/sage-7/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2881:
>>>  
>>> DeprecationWarning: Substitution using function-call syntax and unnamed 
>>> arguments is deprecated and will be removed from a future release of Sage; 
>>> you can use named arguments instead, like EXPR(x=..., y=...)
>>> See http://trac.sagemath.org/5930 for details.
>>>   exec(code_obj, self.user_global_ns, self.user_ns)
>>> p |--> sum(X(j), j, 1, p)
>>> False
>>>
>>> I understand the warning, and think it's irrelevant. But I do not 
>>> understand why the "obvious" expansion is not used. Similarly :
>>> sage: (foo(p+1)-foo(p)).maxima_methods().sumcontract()
>>> sum(X(j), j, 1, p + 1) - sum(X(j), j, 1, p)
>>>
>>> Am I missing something ?
>>>
>>
>> It seems to me that this is an unnecessary limitation in the maxima 
>> routines. It clearly knows something about sum manipulations. Perhaps it's 
>> worth reporting to the Maxima tracker. I'm not so sure this will ever be 
>> very powerful, though, but the following example shows that some 
>> improvements should be within reach:
>>
>> sage: T=foo(p+1)+foo(p)
>> sage: T.maxima_methods().sumcontract()
>> X(p + 1) + 2*sum(X(j), j, 1, p)
>>
>> It does agree with the documentation of sumcontract, which deals with 
>> addition of sums. Apparently, that does not include differences of sums ...
>>
>
> This is now Maxima's bug 3267 
> <https://sourceforge.net/p/maxima/bugs/3267/>. Do you think that a 
> Sage-specific ticket would be usefuil ?
>
> HTH,
>
> --
> Emmanuel Charpentier
>  
>
>>  
>>
>>> --
>>> Emmanuel Charpentier
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to