diff --git a/changelog b/changelog
index 84a01e3..e080aa2 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,7 @@
+20071229 acr src/algebra/mathml.spad fix sum ambiguity bug in mathml (7057)
+20071229 tpd src/hyper/bookvol11 add testpage for summation mathml (7057)
+20071229 tpd src/input/Makefile add summation regression test (7057)
+20071229 tpd src/input/summation.input test mathml sum ambiguity (bug 7057)
 20071229 jap src/hyper/bookvol11 remove /home/silver path (bug 7054)
 20071228 tpd src/hyper/bookvol11 add standards compliance for gamma
 20071228 tpd src/hyper/bitmaps/gammacomplexinverse.png added
diff --git a/src/algebra/mathml.spad.pamphlet b/src/algebra/mathml.spad.pamphlet
index 4b9869f..67a8157 100644
--- a/src/algebra/mathml.spad.pamphlet
+++ b/src/algebra/mathml.spad.pamphlet
@@ -1011,10 +1011,10 @@ have to be switched by swapping names.
     formatSuperSub(expr : E, args : L E, opPrec : I) : S ==
       -- this produces prime notation ordinary derivatives.
       -- first have to divine the semantics, add cases as needed
-      WriteLine$Lisp "SuperSub1 begin"
+--      WriteLine$Lisp "SuperSub1 begin"
       atomE : L E := atomize(expr)      
       op : S := stringify first atomE
-      WriteLine$Lisp "op: "op
+--      WriteLine$Lisp "op: "op
       op ^= "SUPERSUB" => _
           "<mtext>Mistake in formatSuperSub: no SUPERSUB1</mtext>"
       #args ^= 1 => "<mtext>Mistake in SuperSub1: #args <> 1</mtext>"
@@ -1024,9 +1024,9 @@ have to be switched by swapping names.
       -- {{{SUPERSUB}{y}{ }{,,}}{x}}, expr is the first {} and args is the
       -- {x}
       funcS : S := stringify first rest atomE
-      WriteLine$Lisp "funcS: "funcS
+--      WriteLine$Lisp "funcS: "funcS
       bvarS : S := stringify first args
-      WriteLine$Lisp "bvarS: "bvarS
+--      WriteLine$Lisp "bvarS: "bvarS
       -- count the number of commas
       commaS : S := stringify first rest rest rest atomE
       commaTest : S := ","
@@ -1035,7 +1035,7 @@ have to be switched by swapping names.
         i := i+1
 	commaTest := commaTest","
       s : S := "<msup><mi>"funcS"</mi><mrow>"
-      WriteLine$Lisp "s: "s
+--      WriteLine$Lisp "s: "s
       j : I := 0
       while j < i repeat
         s := s"<mo>&#x02032;</mo>"
@@ -1046,7 +1046,7 @@ have to be switched by swapping names.
       -- This one produces ordinary derivatives with differential notation,
       -- it needs a little more work yet.
       -- first have to divine the semantics, add cases as needed
-      WriteLine$Lisp "SuperSub begin"
+--      WriteLine$Lisp "SuperSub begin"
       atomE : L E := atomize(expr)      
       op : S := stringify first atomE
       op ^= "SUPERSUB" => _
@@ -1069,6 +1069,7 @@ have to be switched by swapping names.
       s : S := "<mfrac><mrow><msup><mo>&#x02146;</mo><mn>"string(ndiffs)"</mn></msup><mi>"funcS"</mi></mrow><mrow><mo>&#x02146;</mo><msup><mi>"formatMml(first args,minPrec)"</mi><mn>"string(ndiffs)"</mn></msup></mrow></mfrac><mo>&#x02061;</mo><mo>(</mo><mi>"formatMml(first args,minPrec)"</mi><mo>)</mo>"
 
     formatPlex(op : S, args : L E, prec : I) : S ==
+      checkarg:Boolean := false
       hold : S
       p : I := position(op,plexOps)
       p < 1 => error "unknown plex op"
@@ -1077,13 +1078,21 @@ have to be switched by swapping names.
       n : I := #args
       (n ^= 2) and (n ^= 3) => error "wrong number of arguments for plex"
       s : S :=
-        op = "SIGMA"   => "<mo>&#x02211;</mo>"
+        op = "SIGMA"   => 
+         checkarg := true
+         "<mo>&#x02211;</mo>"
 	-- Sum
-        op = "SIGMA2"   => "<mo>&#x02211;</mo>"
+        op = "SIGMA2"   => 
+         checkarg := true
+         "<mo>&#x02211;</mo>"
 	-- Sum
-        op = "PI"      => "<mo>&#x0220F;</mo>"
+        op = "PI"      => 
+         checkarg := true
+         "<mo>&#x0220F;</mo>"
 	-- Product
-        op = "PI2"     => "<mo>&#x0220F;</mo>"
+        op = "PI2"     => 
+         checkarg := true
+         "<mo>&#x0220F;</mo>"
 	-- Product
 --        op = "INTSIGN" => "<mo>&#x0222B;</mo>"
 	-- Integral, int
@@ -1104,7 +1113,15 @@ have to be switched by swapping names.
 	  else
 	    s := concat [s,group " ","</munderover>"]
           args := rest args
-        s := concat [s,formatMml(first args,minPrec)]
+	-- if checkarg true need to test op arg for "+" at least
+	-- and wrap parentheses if so
+	if checkarg then
+          la : L E := (first args pretend L E)
+          opa : S := stringify first la
+	  if opa = "+" then
+            s := concat [s,"<mo>(</mo>",formatMml(first args,minPrec),"<mo>)</mo>"]
+          else s := concat [s,formatMml(first args,minPrec)]
+        else s := concat [s,formatMml(first args,minPrec)]
       else
         hold := group concat [hold,formatMml(first args,minPrec)]
         s := concat [s,hold]
@@ -1178,7 +1195,17 @@ have to be switched by swapping names.
       p : I := position(op,binaryOps)
       p < 1 => error "unknown binary op"
       opPrec := binaryPrecs.p
-      s1 : S := formatMml(first args, opPrec)
+      -- if base op is product or sum need to add parentheses
+      if ATOM(first args)$Lisp@Boolean then
+        opa:S := stringify first args
+      else
+        la : L E := (first args pretend L E)
+        opa : S := stringify first la
+      if (opa = "SIGMA" or opa = "SIGMA2" or opa = "PI" or opa = "PI2") _
+         and op = "**" then
+        s1:S:=concat ["<mo>(</mo>",formatMml(first args, opPrec),"<mo>)</mo>"]
+      else
+       s1 : S := formatMml(first args, opPrec)
       s2 : S := formatMml(first rest args, opPrec)
       op :=
         op = "|"     =>  s := concat ["<mrow>",s1,"</mrow><mo>",op,"</mo><mrow>",s2,"</mrow>"]
@@ -1197,6 +1224,7 @@ have to be switched by swapping names.
       group formatNaryNoGroup(op, args, prec)
 
     formatNaryNoGroup(op : S, args : L E, prec : I) : S ==
+      checkargs:Boolean := false
       null args => ""
       p : I := position(op,naryOps)
       p < 1 => error "unknown nary op"
@@ -1230,20 +1258,53 @@ have to be switched by swapping names.
 	   position("ZAG",tmpS,1) > 0 => formatZag(args)
 --	   position("ZAG",tmpS,1) > 0 => formatZag1(args)
 	   concat [formatMml(first args,minPrec) "<mo>+</mo>" formatZag(rest args)]
+      -- At least for the ops "*","+","-" we need to test to see if a sigma
+      -- or pi is one of their arguments because we might need parentheses
+      -- as indicated by the problem with 
+      -- summation(operator(f)(i),i=1..n)+1 versus
+      -- summation(operator(f)(i)+1,i=1..n) having identical displays as 
+      -- of 2007-21-21
       op :=
         op = ","     => "<mo>,</mo>" --originally , \:
         op = ";"     => "<mo>;</mo>" --originally ; \: should figure these out
-        op = "*"     => "<mo>&#x02062;</mo>"
+        op = "*"     => 
+           checkargs := true
+           "<mo>&#x02062;</mo>"
 	-- InvisibleTimes
         op = " "     => "<mspace width='0.5em'/>"
         op = "ROW"   => "</mtd><mtd>"
-	op = "+"     => "<mo>+</mo>"
-	op = "-"     => "<mo>-</mo>"
+	op = "+"     => 
+            checkargs := true
+            "<mo>+</mo>"
+	op = "-"     => 
+            checkargs := true
+            "<mo>-</mo>"
         op
       l : L S := nil
       opPrec := naryPrecs.p
+      -- if checkargs is true check each arg except last one to see if it's
+      -- a sigma or pi and if so add parentheses. Other op's may have to be
+      -- checked for in future
+      count:I := 1
       for a in args repeat
-        l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+--        WriteLine$Lisp "checking args"
+        if checkargs then
+	  if count < #args then
+	    -- check here for sum or product
+	    if ATOM(a)$Lisp@Boolean then
+	      opa:S := stringify a
+	    else
+	      la : L E := (a pretend L E)
+	      opa : S := stringify first la
+	    if opa = "SIGMA" or opa = "SIGMA2" or _
+               opa = "PI" or opa = "PI2" then
+	      l := concat(op,concat(_
+                    concat ["<mo>(</mo>",formatMml(a,opPrec),_
+                            "<mo>)</mo>"],l)$L(S))$L(S)
+	    else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+	  else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+	else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+	count := count + 1
       s : S := concat reverse rest l
       opPrec < prec => parenthesize s
       s
diff --git a/src/hyper/bookvol11.pamphlet b/src/hyper/bookvol11.pamphlet
index 3a73f1c..293066e 100644
--- a/src/hyper/bookvol11.pamphlet
+++ b/src/hyper/bookvol11.pamphlet
@@ -1177,6 +1177,36 @@ is currently ignored.
    value="(progn (setq |$options| '((|operations|))) (|show| '|Integer|))" />
   <div id="ansp3"><div></div></div>
  </li>
+ <li>
+  <input type="submit" id="p4" class="subbut" 
+    onclick="makeRequest('p4');"
+   value="summation(i^2,i=a..b)^(d-c)" />
+  <div id="ansp4"><div></div></div>
+ </li>
+ <li>
+  <input type="submit" id="p5" class="subbut" 
+    onclick="makeRequest('p5');"
+   value="summation(i^2^(d-c),i=a..b)" />
+  <div id="ansp5"><div></div></div>
+ </li>
+ <li>
+  <input type="submit" id="p6" class="subbut" 
+    onclick="makeRequest('p6');"
+   value="sum(operator(f) (i)+1,i=1..n)" />
+  <div id="ansp6"><div></div></div>
+ </li>
+ <li>
+  <input type="submit" id="p7" class="subbut" 
+    onclick="makeRequest('p7');"
+   value="sum(operator(f) (i),i=1..n)+1" />
+  <div id="ansp7"><div></div></div>
+ </li>
+ <li>
+  <input type="submit" id="p8" class="subbut" 
+    onclick="makeRequest('p8');"
+   value="sum(operator(f) (i)+1,i=1..n)^3" />
+  <div id="ansp8"><div></div></div>
+ </li>
 </ul>
 
 <<page foot>>
diff --git a/src/input/Makefile.pamphlet b/src/input/Makefile.pamphlet
index f1f937b..8b79668 100644
--- a/src/input/Makefile.pamphlet
+++ b/src/input/Makefile.pamphlet
@@ -354,7 +354,8 @@ REGRES= algaggr.regress algbrbf.regress  algfacob.regress alist.regress  \
     sincosex.regress  sint.regress     skew.regress     slowint.regress \
     solvetra.regress  space3.regress   sqmatrix.regress sregset.regress \
     stbl.regress      stream2.regress  stream.regress   streams.regress \
-    string.regress    strtbl.regress   symbol.regress   t111293.regress \
+    string.regress    strtbl.regress   summation.regress \
+    symbol.regress    t111293.regress \
     table.regress     tanatan.regress  textfile.regress torus.regress \
     triglim.regress   tsetcatvermeer.regress            tutchap1.regress \
     void.regress      uniseg.regress
@@ -622,7 +623,8 @@ FILES= ${OUT}/algaggr.input  ${OUT}/algbrbf.input    ${OUT}/algfacob.input \
        ${OUT}/spiral.input \
        ${OUT}/sqmatrix.input ${OUT}/sregset.input    ${OUT}/stbl.input \
        ${OUT}/stream2.input  ${OUT}/stream.input     ${OUT}/streams.input \
-       ${OUT}/string.input   ${OUT}/strtbl.input     ${OUT}/symbol.input \
+       ${OUT}/string.input   ${OUT}/strtbl.input     ${OUT}/summation.input \
+       ${OUT}/symbol.input \
        ${OUT}/synonym.input  ${OUT}/t111293.input \
        ${OUT}/table.input    ${OUT}/tanatan.input    ${OUT}/test.input \
        ${OUT}/tetra.input    ${OUT}/textfile.input   ${OUT}/tknot.input \
@@ -931,6 +933,7 @@ DOCFILES= \
   ${DOC}/stbl.input.dvi        ${DOC}/stream2.input.dvi    \
   ${DOC}/stream.input.dvi      ${DOC}/streams.input.dvi    \
   ${DOC}/string.input.dvi      ${DOC}/strtbl.input.dvi     \
+  ${DOC}/summation.input.dvi \
   ${DOC}/symbol.input.dvi      ${DOC}/synonym2.input.dvi   \
   ${DOC}/synonym.input.dvi     ${DOC}/t111293.input.dvi    \
   ${DOC}/table.input.dvi       ${DOC}/tanatan.input.dvi    \
