5 Sep
2017
5 Sep
'17
11:39 a.m.
For alternating sign, multiply by (-1)^k. In[524]:= "(-1)^k" //StringLength Out[524]= 6 Mathematica won't go 5: Syntax::sntxb: Expression cannot begin with "(-)^k". What's your favorite recipe for ++--++--...? In[515]:= "(-1)^Floor[k/2]" // StringLength Out[515]= 15 is a little clumsy. But Mathematica accepts Floor brackets: In[525]:= "(-1)^⎣k/2⎦" // StringLength Out[525]= 10 and then underunderstands Floor: In[518]:= Assuming[k∈Integers, FullSimplify[DiscreteRatio[(-1)^Floor[k/2], k]]] Out[518]= (-1)^(Floor[k/2] + Floor[(1 + k)/2]) I have ten characters where In[529]:= FullSimplify[DiscreteRatio[**********, k], k∈Integers] Out[529]= (-1)^k How about you? --rwg