Instead of 12 I have an answer that I cannnot evaluate.
Of course I could code:
Sum[i, {i, 0, 6, 2}]
but this is not a format suitable for being incorporated afterwards into a Latex document.
My question : how can I get a correct result by sticking to traditional notation for a sum: \sum ?
(* in reply to your first first reply *)
Yes it gives the right answer but you modify my initial expression which is pefectly legible . I was expecting an answer which shows how the even condition in the indexing is coded, perhaps with a pattern with EvenQ.
To take another example is it possible to code this expression without enumerating all the allowed successive values of i and j?
Thanks. I do not quite understand the use of the the Makeboxes statements unless this one:
If I now type
Sum[ i, {i, 0, 6,2}] //HoldForm // TraditionalForm
I retrieve my original ? expression which I have to ReleaseHold to evaluate. Correct?
Does your answer also mean that you cannot natively use in MMA the traditional ? notation such as my first example without Makeboxes statements describing it with the corresponding InputForm thrown in ?
Perhaps I misunderstood. I took your goal to be one of output formatting, esp. for TeX. However, your comment to another response makes me think you might be interested in coding TeX-style input. MakeBoxes (as well as Format) formats output only. MakeExpression can be used to turn notebook input into expressions for evaluation. (Everything you type into a notebook is stored in cells in the form of “boxes”.) The Notation package can be used to create input notation, too, if that’s of interest.
Sorry, I wasn’t trying to be facetious but was more thinking that coding (2i) and (2i+1) for even and odd integers would allow for Simplify or FullSimplify potentially to find more simplified expressions that didn’t require a summation notation.
So it sounds like from the other responses that you want a simple way to input the restrictions on the indices AND have those display in a readable/visually-pleasing/standard-typesetting format (likely having j \neq i placed right below j=0).
The only thing I can offer is something like my original comment such that your example above becomes
In particular, if you replace a[i] by i, you’ll get the expected value 12.
Interesting is that the condition is placed where the upper limit would normally go. Trying, instead, to use i[Element] Select[Range[0, 6], EvenQ] as the lower limit, and no upper limit, yields a localization error.
Thanks Jim for your answers.
I think it is a lot of programming effort for a facility which should be native or will be provided in future releases of MMA (they opened already a door towards what I am looking for but not much). This is more a comment than an answer.
Yes very unexpected but not an orthodox mathematic notation, And it implies that a reader of a document with such a formula understands Mathematica input form too.
I don’t think a user who wants to deal with such restricted-domain kinds of summations would need to understand InputForm at all, provided only that the sigma-notation form was shown. After discovering it from and InputForm expression, subsequently I used the Classroom Assistant palette as usual, but adjusting the lower- and upper-limits to conform to the discovered form.