MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Formatting Indefinite Series Expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40560] Formatting Indefinite Series Expressions
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 10 Apr 2003 03:37:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In math books one often encounters series expressions that have ellipses in
them to indicate skipped terms or an infinite number of trailing terms.
Although we cannot calculate with such expressions, it would be nice to have
an easy method to produce and format such expressions as part of a
mathematical exposition.

The notebook pasted at the end of this email contains a routine for doing
this along with a number of examples. To try it just copy the notebook
expression and paste it into a blank Mathematica notebook.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

Notebook[{

Cell[CellGroupData[{
Cell["Format Ellipsis", "Title"],

Cell["\<\
David Park
djmp at earthlink.net\
\>", "Subtitle"],

Cell[CellGroupData[{

Cell["FormatEllipsis", "Section"],

Cell[BoxData[{
    \(\(FormatEllipsis::usage = "\<FormatEllipsis[f_, \
{iter1,iter2,...}, operator:Plus] will format a sum (operator = Plus, \
the default) or a product (operator = Times) of the pure function f, \
using an ellipsis between each group of terms. Use an iterator that \
generates no terms to create a trailing ellipsis.\>";\)\), "\
\[IndentingNewLine]",
    \(FormatEllipsis[f_Function, iters : {{_, _, __} .. },
        operator_:  Plus] := \[IndentingNewLine]Module[{work, work2,
          niters = Length[iters], i,
          formatrule}, \[IndentingNewLine]formatrule =
          a_?NumericQ + b_ \[Rule]
            HoldForm[b + a]; \[IndentingNewLine]work =
          Table[f[First[Part[iters, 1]]], Evaluate[Part[iters, 1]]] /.
            formatrule; \
\[IndentingNewLine]Do[\[IndentingNewLine]work2 =
            Table[f[First[Part[iters, i]]],
                Evaluate[Part[iters, i]]] /.
              formatrule; \[IndentingNewLine]work =
            Join[work, {\[Ellipsis]}, work2], \[IndentingNewLine]{i,
            2, niters}]; \[IndentingNewLine]HoldForm @@ {work} /.
          List \[RuleDelayed]
            operator\[IndentingNewLine]]\)}], "Input",
  InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Examples...", "Section"],

Cell[BoxData[
    \(FormatEllipsis[
      x\^# &, {{n, 0, 5}, {n, 1, \(-1\)}}]\)], "Input"],

Cell[BoxData[
    \(FormatEllipsis[
      x\^# &, {{n, 0, 5}, {n, k - 1, k + 1, 1}, {n, m,
          m}}]\)], "Input"],

Cell[BoxData[
    \(FormatEllipsis[
      x\^#\/\(#!\) &, {{n, 0, 5}, {n, 1, \(-1\)}}]\)], "Input"],

Cell[BoxData[
    \(FormatEllipsis[
      x\^#\/HoldForm[\(#!\)] &, {{n, 0, 5}, {n, k, k}, {n,
          1, \(-1\)}}]\)], "Input"],

Cell[BoxData[
    \(FormatEllipsis[\((x\^#\/HoldForm[\(#!\)] /.
            HoldForm[\(0!\)] \[Rule] 1)\) &, {{n, 0, 5}, {n, k,
          k}, {n, 1, \(-1\)}}]\)], "Input"],

Cell[BoxData[
    \(FormatEllipsis[HoldForm[z - c\_#] &, {{n, 1, 3}, {n, m, m}},
      Times]\)], "Input"],

Cell[BoxData[{
    \(FormatEllipsis[# &, {{k, 1, 3}, {k, n - 2,
          n}}]\), "\[IndentingNewLine]",
    \(FormatEllipsis[# &, {{k, n, n - 2, \(-1\)}, {k, 3,
          1, \(-1\)}}]\)}], "Input"],

Cell[BoxData[
    \(FormatEllipsis[\(b\_#\) 2\^# &, {{i, m, m - 1, \(-1\)}, {i, 1,
          0, \(-1\)}}]\)], "Input"],

Cell[BoxData[
    \(\((FormatEllipsis[b\_# &, {{i, m, m - 1, \(-1\)}, {i, 1, 0, \
\(-1\)}}, Times])\)\_2\)], "Input"],

Cell[BoxData[
    \(s\_n ==
      FormatEllipsis[a\_# &, {{i, n - 1, n - 2, \(-1\)}, {i, 1, 1}},
          Times]/FormatEllipsis[
          b\_# &, {{i, n, n - 1, \(-1\)}, {i, 2, 2}},
          Times]\)], "Input"],

Cell[BoxData[{
    \(\(Unprotect[Binomial];\)\), "\[IndentingNewLine]",
    \(Format[Binomial[2  m, x_]] :=
      MatrixForm[{{2  m}, {x}}]\), "\[IndentingNewLine]",
    \(FormatEllipsis[\((\(\((\(-1\))\)\^\(# - 1\)\)
                HoldForm[Binomial[2  m, xxx]] /.
              xxx \[Rule] 2  # - 1)\) &, {{i, 1, 3}, {i, m,
            m}}] == \(2\^m\)
        Sin[m\ \[Pi]/2]\), "\[IndentingNewLine]",
    \(Format[Binomial[2  m, x_]] =. \), "\[IndentingNewLine]",
    \(\(Protect[Binomial];\)\)}], "Input"],

Cell[BoxData[
    \(\[Pi]\^2\/8 \[Equal]
      FormatEllipsis[\((\(1\/HoldForm[xxx]\^2 /.
                xxx \[Rule] 2  # - 1\) /.
              HoldForm[1] \[Rule] 1)\) &, {{i, 1, 4}, {i, k, k}, {i,
            1, \(-1\)}}]\)], "Input"]
}, Open  ]]
}, Open  ]]
},
FrontEndVersion->"4.2 for Microsoft Windows",
ScreenRectangle->{{0, 1280}, {0, 943}},
AutoGeneratedPackage->None,
WindowToolbars->"EditBar",
WindowSize->{636, 685},
WindowMargins->{{0, Automatic}, {Automatic, 0}}
]





  • Prev by Date: Re: split a list
  • Next by Date: Re: Prefix notation
  • Previous by thread: Re: '#1' raised to a power in result of a Solve[] call?
  • Next by thread: Cut and Paste under Unix