(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 24710, 419]*) (*NotebookOutlinePosition[ 25799, 456]*) (* CellTagsIndexPosition[ 25755, 452]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{Cell[TextData[ "(*\n *\t\tGlobal controls.\n *)\n\nshowproof\t\t=\tFalse;\nshowreason\t\t=\t\ True;\nshowHeuristics\t=\tTrue;\n\n(*\n *\t\tWe represent the simple \ symmetric sum, [a,b,c],\n *\t\tby the function SS[a,b,c].\n *\t\tThis \ function can have any number of arguments\n *\t\t(but at least 2).\n *\t\tWe \ always print this function as \"[a,b,c]\".\n *)\n\n\ Format[SS[x__]]:=SequenceForm[\"[\",Infix[{x},\",\"],\"]\"];\n\n(*\n *\t\tFix \ the builtin \"Variables\" function to work properly\n *\t\twith inequalities.\ \n *)\n\nUnprotect[Variables];\nVariables[x_> \ y_]:=Union[Variables[x],Variables[y]];\n\ Variables[x_>=y_]:=Union[Variables[x],Variables[y]];\nVariables[x_< \ y_]:=Union[Variables[x],Variables[y]];\n\ Variables[x_<=y_]:=Union[Variables[x],Variables[y]];\n\ Variables[x_==y_]:=Union[Variables[x],Variables[y]];\nProtect[Variables];\n\n\ (*\n *\tCreate a function that finds the apparent sign of a term.\n *)\n\n\ apparentSign[x_?NumberQ] := If[x<0,-1,1,1];\napparentSign[x_?AtomQ] := 1;\n\ apparentSign[x_+y_] :=\n\tIf[apparentSign[x]===apparentSign[y],\n\t\t\ apparentSign[x],\n\t\tunknownSign\n\t ];\napparentSign[x_ * y_] :=\n\t\ If[IntegerQ[apparentSign[x]]\n\t &&IntegerQ[apparentSign[y]],\n\t\t\ apparentSign[x]*apparentSign[y],\n\t\tunknownSign\n\t ];\n\ apparentSign[x_^n_Integer] :=\n\tIf[IntegerQ[apparentSign[x]],\n\t\t\ apparentSign[x]^n,\n\t\tunknownSign\n\t ];\napparentSign[Sqrt[x_]] := 1;\n\n\ (*\n *\tMove a term to the lhs or rhs depending on its sign.\n *)\n\n\ Sep[term_]:=\nBlock[{numf},\n\tnumf = numfactor[term];\n\tIf[!NumberQ[numf],\n\ \t\tnumf = Factor[numf];\n\t\tnumf = First[numf];\n\t ];\n\t\n\t\ If[!NumberQ[numf],\n\t\tIf[apparentSign[term]==1, numf=1];\n\t\t\ If[apparentSign[term]==-1, numf=-1];\n\t ];\n\n\tIf[numf<0,\n\t\tright -= \ term,\n\t\tleft += term,\n\t\tleft += term\n\t\t];\n\t];\n\n\ checksymm[expr_]:=\nBlock[ {vars},\n vars = Variables[expr];\n \ Return[symm[expr,vars,checkit,expr]];\n\t];\n\ncheckit[expr1_,expr2_] :=\n\ Block[{temp},\n\tIf[Together[expr1-expr2]==0,Return[True]];\n\tReturn[False];\ \n\t];\n\n(*\n *\tMove all positive terms to the left\n *\tand negative terms \ to the right.\n *)\n\nsignseparate[]:=\n(* Implicit arguments: left, right, \ op. *)\nBlock[{expr},\n expr = Expand[Together[left-right]];\n\n left = expr;\ \n right = 0;\n\n If[NumberQ[expr] && expr<0,\n\tright =\t-left;\n\tleft =\t\ 0;\n\tReturn[];\n ];\n\n If[AtomQ[expr],Return[]];\n\n If[Head[expr] =!= \ Plus,\n \t\tIf[apparentSign[expr]==(-1),\n\t\t\tright =\t-left;\n\t\t\tleft \ =\t0;\n \t\t ];\n \t\tReturn[];\n ];\n\n (*\n \tThe expression is a sum \ of terms.\n Scan these terms and move the\n positive ones to the left\n \ and the negative ones to the right.\n *)\n\n left = 0;\n right = 0;\n \ Map[Sep,expr];\n Return[];\n \t];\n\n(*\n *\tCollect together terms of the \ same sign.\n *)\n\ncollect[]:=\n (* Implicit arguments: left, right, op. *)\n \ Block[ {oldleft,oldright},\n\n oldleft =\tleft;\n oldright =\tright;\n\n \ signseparate[];\n\n If[showproof &&\n \t(Together[left-oldleft]=!=0 ||\n \t \ Together[right-oldright]=!=0),\n \tPrint[\"Expanding and collecting terms \ of the same sign gives:\"];\n\t\tPrint[op[left,right]];\n ];\n\n];\n\n(*\n \ *\tBreak an inequality into 3 parts:\n *\tthe lhs, the operator, and the rhs.\ \n *\tStore in \"left\", \"op\", and \"right\" respectively.\n *)\n\n\ getop[inequal_]:=\nBlock[{op},\n op = Head[inequal];\n\n left = \ Part[inequal,1];\n right = Part[inequal,2];\n\n If[op =!= Less &&\n op \ =!= LessEqual &&\n op =!= Greater &&\n op =!= GreaterEqual &&\n op \ =!= Equal,\n\t\tPrint[\"Expression, \",inequal,\" is not an inequality.\"];\n \ Print[\"Main operator is: \", op];\n Error[inequal];\n ];\n\n \ Return[op];\n\t];\n\nhomogineq[inequal_,varlist_]:=\n\ Block[{left,right,op,temp,vleft,vright,vl,vr,result},\n\n \ If[showproof,showreason=True];\n\n op = getop[inequal];\n\n normalorder[];\n\n\ clearfractions[];\n\n result = checkobvious[];\n If[result==True || \ result==False,Return[result]];\n\n gcdize[];\n\n collect[];\n\n vleft =\t\ vec[left,varlist];\n vright =\tvec[right,varlist];\n\n (* clear fractions by \ multiplying both\n sides by the lcm of the denominators *)\n\n vl =\t\ Apply[Plus,vleft];\n vl =\tDenominator[Together[vl]];\n vr =\t\ Apply[Plus,vright];\n vr =\tDenominator[Together[vr]];\n temp =\t\ PolynomialLCM[vl,vr];\n vleft =\ttemp*vleft;\n vright =\ttemp*vright;\n\n \ If[showreason,\n Print[\"Expressing in terms of symmetric polynomials \ gives:\"];\n\tPrint[op[Apply[Plus,vleft],Apply[Plus,vright]]];\n ];\n\n \ result = majorize[vleft,vright];\n\n If[supressbanner=!=True && \ result=!=True,\n Print[\"left side: \",vleft];\n\tPrint[\"right side: \ \",vright];\n ];\n\n Return[result];\n\n\t];"], "Input", InitializationCell->True, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"right\"\n \ is similar to existing symbol \"Right\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"left\"\n \ is similar to existing symbol \"Left\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"collect\"\n \ is similar to existing symbol \"Collect\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"vleft\"\n \ is similar to existing symbol \"left\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"vright\"\n \ is similar to existing symbol \"right\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{Cell[TextData[ "ApplyMuirhead[reason_,Lindex_,Rindex_]:=\n(* implicit inputs and outputs:\n\t\ leftsum, rightsum, left, right, change\n*)\nBlock[{lentry,rentry,con,\n\t\ rawleft,rawright,lfactor,rfactor},\n\tlentry =\tleft[[Lindex]];\n\trentry =\t\ right[[Rindex]];\n\tlfactor =\tnumfactor[lentry];\n\trawleft =\t\ lentry/lfactor;\n rfactor =\tnumfactor[rentry];\n rawright =\t\ rentry/rfactor;\n\tcon =\t\tMin[lfactor,rfactor];\n\tIf[showreason,\n\t \ Print[con*rawleft>=con*rawright];\n\t\tIf[showHeuristics,\n\t\t\tPrint[\"... \ by Heuristic \",reason,\".\"]];\n\t ];\n\trightsum =\trightsum - \ con*rawright;\n\tleftsum =\tleftsum - con*rawleft;\n\tleft =\t\t\ listerize[leftsum];\n\tright =\t\tlisterize[rightsum];\n\tchange =\tTrue;\n\t\ ];\n\n(*\n\tmajorize takes two vectors of symmetric sums [a,b,c],\n\tand \ returns true if the left one majorizes the right one\n\tor if the inequality \ can be proven false.\n\tIt returns false if right majorizes left and returns\n\ \tnotsure if it is not sure.\n*)\n\nmajorize[lefty_,righty_] :=\n\ Block[{lfactor,rfactor,rawright,rawleft,len,result,termsize,p,d,m1,m2,con,\n\t\ leftsum,rightsum,whileresult,change,temp,lcount,lentry,\n\t \ rcount,rentry,res2,every,some,Li,Ri,applied},\n\n left = lefty;\n right = \ righty;\n\n \t(*\n \t Heuristic 0: If there is one term on each side,\n\t\t \ then the result is determined by Muirhead's Theorem.\n\t *)\n\n \ If[Length[left]==1 && Length[right]==1,\n \tleft =\t\tFirst[left];\n\tright =\ \t\tFirst[right];\n\n\tresult =\tmajor[left,right];\n\n\tIf[showreason && \ result==True,\n\t Print[\"This result follows from the majorization \ theorem.\"];\n\t ];\n\n\tReturn[result];\n\t];\n\n If[showreason,\n \ Print[\"This follows from the following majorizations:\"];\n\t];\n\n\ While[Length[right]>0,\n leftsum =\tApply[Plus,left];\n rightsum =\t\ Apply[Plus,right];\n\n change = False;\n \n (* Heuristic 1:\n See if there \ is some term on the left that does not majorize\n anything on the right. \ If that is the case, then see if we\n can apply Schur's theorem, either\n\n\ \t\t\t[p+2d,0,0] + [p,d,d] > 2 [p+d,d,0]\t\tcase a\n\n or\t\t[p+d,p+d,0] \ + [2p,d,d] > 2 [p+d,d,p]\t\tcase b, d<=2p\n\n or\t\t[p+d,p+d,0] + [2p,d,d] \ > 2 [p+d,d,p]\t\tcase c, d>2p\n *)\n\n temp =\t\tFirst[left];\n temp =\t\t\ temp/numfactor[temp];\n termsize =\tLength[temp];\n\n If[termsize==3,\n \ For[i=1,i<=Length[left],i++,\n\tlfactor =\tnumfactor[left[[i]]];\n rawleft \ =\tleft[[i]]/lfactor;\n\n For[j=1, j<=Length[right],j++,\n\t\trfactor =\t\ numfactor[right[[j]]];\n\t\trawright =\tright[[j]]/rfactor;\n\t\t\ If[major[rawleft,rawright],Break[]];\n ];\n \ If[j<=Length[right],Continue[]];\n\n If[Part[rawleft,2]==Part[rawleft,3], \ (* i.e. [x,d,d] *)\n\t\td =\tPart[rawleft,2];\n\t p =\tPart[rawleft,1];\n\t\ m1 =\tCoefficient[leftsum,SS[p+2*d,0,0]];\n\t m2 =\t\ Coefficient[rightsum,SS[p+d,d,0]];\n\t If[m1=!=0 && m2>1,\n\t \tcon = \ Min[lfactor,m1,Floor[m2/2]];\n\t\t\tleftsum = \ leftsum-con*SS[p+2*d,0,0]-con*SS[p,d,d];\n\t\t\trightsum = \ rightsum-2*con*SS[p+d,d,0];\n\t\t\tIf[showreason,\n\t\t \t\ Print[con*SS[p+2*d,0,0]+con*SS[p,d,d]>=2*con*SS[p+d,d,0]];\n\t\t\t\t\ If[showHeuristics,Print[\"... by Heuristic 1a.\"]];\n\t\t\t ];\n\t\t\tleft =\ \tlisterize[leftsum];\n\t\t\tright =\tlisterize[rightsum];\n\t\t\tchange = \ True;\n\t\t\tBreak[];\n\t (* else *),\n\t If[EvenQ[p],\n\t \t\tp =\t\ p/2;\n\t\t\tm1 =\tCoefficient[leftsum,SS[p+d,p+d,0]];\n\t\t\tm2 =\t\ Coefficient[rightsum,SS[p+d,d,p]];\n\t\t\tIf[m1!=0 && m2>1,\n\t\t\t\tcon = \ Min[lfactor,m1,Floor[m2/2]];\n\t\t\t\tleftsum = \ leftsum-con*SS[p+d,p+d,0]-con*SS[2p,d,d];\n\t\t\t\trightsum = \ rightsum-2*con*SS[p+d,d,p];\n\t\t\t\tIf[showreason,\n\t\t\t \t \t\ Print[con*SS[p+d,p+d,0]+con*SS[2p,d,d]>=2*con*SS[p+d,d,p]];\n\t\t\t\t\t\ If[showHeuristics,Print[\"... by Heuristic 1b.\"]];\n\t\t\t \t ];\n\t\t\t\t\ left =\tlisterize[leftsum];\n\t\t\t\tright =\tlisterize[rightsum];\n\t\t\t\t\ change = True;\n\t\t\t\tBreak[];\n\t\t\t ];\n\t ]; (* end if EvenQ *)\n\ \t ]; (* end if m1!=0 *)\n ];\t(* end if [x,d,d] *)\n \ If[Part[rawleft,1]==Part[rawleft,2], (* i.e. [d,d,x] *)\n\t\td =\t\ Part[rawleft,1];\n\t p =\tPart[rawleft,3];\n\t If[EvenQ[p],\n\t \tp \ = p/2;\n\t\t m1 =\tCoefficient[leftsum,SS[p+d,p+d,0]];\n\t\t m2 =\t\ Coefficient[rightsum,SS[p+d,d,p]];\n\t\t If[m1=!=0 && m2>1,\n\t\t \tcon \ = Min[lfactor,m1,Floor[m2/2]];\n\t\t\t\tleftsum = \ leftsum-con*SS[p+d,p+d,0]-con*SS[d,d,2p];\n\t\t\t\trightsum = \ rightsum-2*con*SS[p+d,d,p];\n\t\t\t\tIf[showreason,\n\t\t\t \t\ Print[con*SS[p+d,p+d,0]+con*SS[d,d,2p]>=2*con*SS[p+d,d,p]];\n\t\t\t\t\t\ If[showHeuristics,Print[\"... by Heuristic 1c.\"]];\n\t\t\t\t ];\n\t\t\t\t\ left =\tlisterize[leftsum];\n\t\t\t\tright =\tlisterize[rightsum];\n\t\t\t\t\ change = True;\n\t\t\t\tBreak[];\n\t\t ]; (* end if m1!=0 *)\n\t\t ]; \ (* end if EvenQ *)\n ];\t(* end if [d,d,x] *)\n ];\t(* end for i *)\n \ If[i<=Length[left],Continue[]];\n\n ]; \t(* end if termsize==3 *)\n\n(*\n\t \ Heuristic 2: If there is only one term on the right,\n\t\t then the terms on \ the left must majorize it away.\n *)\n\n If[Length[right]==1,\n\tlen =\t\t\ Length[left];\n\n\tFor[i=len, i>0, i--,\n\t\t\ If[Length[right]==0,Return[True]];\n\t\trfactor =\tnumfactor[right[[1]]];\n\t\ \tIf[rfactor<=0,Return[True]];\n\t\trawright =\tright[[1]]/rfactor;\n\t \ lfactor =\tnumfactor[left[[i]]];\n\t rawleft =\tleft[[i]]/lfactor;\n\t \ If[major[rawleft,rawright],\n\t \tApplyMuirhead[\"2\",i,1];\n\t ];\n\t\ ];\n\t];\n\n If[leftsum==0 && rightsum=!=0,Return[False]];\n \ If[rightsum==0,Return[True]];\n\n (*\n \tHeuristic 3:\n If there is a term \ on the right that is majorized by\n precisely one term on the left, then \ we may as well\n remove that term now.\n *)\n\n applied = False;\n \ For[j=1, j<=Length[right], j++,\n rfactor =\tnumfactor[right[[j]]];\n \ rawright =\tright[[j]]/rfactor;\n lcount =\t0;\n\n For[i=1, \ i<=Length[left], i++,\n\t\tlfactor =\tnumfactor[left[[i]]];\n\t\trawleft =\t\ left[[i]]/lfactor;\n\t\tIf[major[rawleft,rawright],\n\t \tlcount++;\n\t\t\t\ Li = i;\n\t ];\n ];\n\n If[lcount==1,\n \t\ ApplyMuirhead[\"3\",Li,j];\n \tapplied = True;\n\t\tBreak[];\n ];\n \ ];\n If[applied,Continue[]];\n\n If[leftsum==0 && \ rightsum=!=0,Return[False]];\n If[rightsum==0,Return[True]];\n\n (* Heuristic \ 4:\n If there is a term on the left that majorizes\n precisely one term \ on the right, then we may as well\n remove that term now.\n *)\n\n \ applied = False;\n For[j=1, j<=Length[left], j++,\n lfactor =\t\ numfactor[left[[j]]];\n rawleft =\tleft[[j]]/lfactor;\n rcount =\t0;\n\n\ For[i=1, i<=Length[right], i++,\n\t\trfactor =\tnumfactor[right[[i]]];\n\t\ \trawright =\tright[[i]]/rfactor;\n\t\tIf[major[rawleft,rawright],\n\t \t\ rcount++;\n\t \tRi = i;\n\t ];\n ];\n\n If[rcount==1,\n \t\ ApplyMuirhead[\"4\",j,Ri];\n \tapplied = True;\n\t\tBreak[];\n ];\n \ ];\n If[applied,Continue[]];\n\n If[leftsum==0 && \ rightsum=!=0,Return[False]];\n If[rightsum==0,Return[True]];\n\n (* Heuristic \ 5:\n If every term on the left majorizes every term on the right,\n \ then we can pair them off any way we want.\n *)\n\n every = True;\n \ For[j=1, j<=Length[right], j++,\n rfactor =\tnumfactor[right[[j]]];\n \ rawright =\tright[[j]]/rfactor;\n\n For[i=1, i<=Length[left], i++,\n\t\t\ lfactor =\tnumfactor[left[[i]]];\n\t\trawleft =\tleft[[i]]/lfactor;\n\t\t\ If[!major[rawleft,rawright],\n\t\t\tevery = False;\n\t\t\tBreak[];\n\t\t ];\n\ ];\n If[!every,Break[]];\n ];\n\n If[every,\n \t\ ApplyMuirhead[\"5\",1,Length[right]];\n ];\n\n If[leftsum==0 && \ rightsum=!=0,Return[False]];\n If[rightsum==0,Return[True]];\n\n (* Heuristic \ 6:\n If some term on the left majorizes some term on the right,\n then \ we can remove this pair.\n *)\n\n For[j=Length[right], j>0, j--,\n \ rfactor =\tnumfactor[right[[j]]];\n rawright =\tright[[j]]/rfactor;\n\n\t\ some = False;\n For[i=1, i<=Length[left], i++,\n\t\tlfactor =\t\ numfactor[left[[i]]];\n\t\trawleft =\tleft[[i]]/lfactor;\n\t\t\ If[major[rawleft,rawright],\n\t\t\tApplyMuirhead[\"6\",i,j];\n\t\t\tsome = \ True;\n\t\t\tBreak[];\n\t\t ];\n \t ];\n If[some, Break[]];\n ];\n\n\ If[leftsum==0 && rightsum!=0,Return[False]];\nIf[rightsum==0,Return[True]];\n\ \nIf[!change, Break[]];\n\n];\n\n If[Length[right]==0,Return[True]];\n \ If[Length[left]>1 && Length[right]>1,Return[notsure]];\n \ Return[notyetimplemented];\n\n];\n \n(*\n *\tTurn \ n1[a1,b1,c1]+n2[a2,b2,c3]+n3[a3,b3,c3] into the list\n *\t{n1[a1,b1,c1] , \ n2[a2,b2,c3] , n3[a3,b3,c3]}.\n *)\n\nlisterize[expr_]:=\nBlock[{temp},\n \t\ If[AtomQ[expr],\n\t\tIf[expr===0, Return[{}], Return[{expr}]];\n\t ];\n \ If[Head[expr]===Plus,\n \tReturn[ReplacePart[expr,List,0]];\n ];\n \t\n \ Return[{expr}];\n ];\n"], "Input", InitializationCell->True, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"rentry\"\n \ is similar to existing symbol \"lentry\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"rfactor\"\n \ is similar to existing symbol \"lfactor\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"rcount\"\n \ is similar to existing symbol \"lcount\"."], "Message", Evaluatable->False, AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData[ "(* major takes two symmetric sums, such as [a,b,c] and [d,e,f]\n and \ returns true if the left one majorizes the right one.\n*)\n\n\ major[left_,right_] :=\n\ Block[{lfactor,rfactor,lterm,rterm,lsum,rsum,len,result,ineqList},\n\t(* \ Extract a and {x,y,z} from a{x,y,z} *)\n\t{lfactor,lterm} =\t\ FactorTermsList[left];\n\t{rfactor,rterm} =\tFactorTermsList[right];\n\t\ If[lfactor < rfactor,Return[funnyratio]];\n\n\t(* turn SS[a,b,c] into normal \ list {a,b,c} *)\n\n \tlterm = lterm/.{SS[x__]->{x}};\n \trterm = \ rterm/.{SS[x__]->{x}};\n\n\tIf[Length[lterm] != Length[rterm],\n\t\t\ Print[\"Length error.\"];\n\t \tPrint[lterm,\" \",rterm,\" \",lfactor,\" \ \",rfactor];\n\t\tReturn[lengthsdiffer];\n\t ];\n\tlen = Length[lterm];\n\n\t\ (* compute the partial sums of each one\n\tand check for majorization *)\n\n\t\ lsum = Drop[FoldList[Plus,0,lterm],1];\n\trsum = \ Drop[FoldList[Plus,0,rterm],1];\n\n\t(* form sequence of inequalities *)\n\t\ ineqList = MapThread[GreaterEqual,{lsum,rsum}];\n\t\n\t(* \"and\" them all \ together *)\n\t\n\tresult = Apply[And,ineqList];\n\tReturn[result];\n\t];"], "Input", InitializationCell->True, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"lterm\"\n \ is similar to existing symbol \"term\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell: \n Possible spelling error: new symbol name \"rterm\"\n \ is similar to existing symbols {lterm, term}."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"rsum\"\n \ is similar to existing symbol \"lsum\"."], "Message", Evaluatable->False, AspectRatioFixed->True]}, Open]], Cell[CellGroupData[{Cell[TextData[ "(*\n\tCall a function \"fn\" once for each\n\tpermutation of the variables \ in \"expr\".\n\tThe list of variables is given in \"varlist\".\n\tThe \ function is called as\n\t\tfn(permutedExpr,arg)\n\tand returns True to \ continue, False to abort.\n*)\nsymm[expr_,varlist_,fn_,arg_]:=\n\ Block[{val,permList,len,i,perm,permExpr,permRule},\n\tpermList = \ Permutations[varlist];\n\tlen = Length[permList];\n\tFor[i=1,i<=len,i++,\n\t\t\ perm = permList[[i]];\n\t\tpermRule = MapThread[Rule,{varlist,perm}];\n\t\t\ permExpr = expr/.permRule;\n\t\tval = fn[permExpr,arg];\n\t\t\ If[val==False,Return[False]];\n\t ];\n\tReturn[True];\n\t];\n\n\ numfactor[term_]:=\nBlock[{flist},\n\tflist = FactorTermsList[term];\n\t\ Return[First[flist]];\n\t];\n\n\nvec[exp_,varlist_] :=\nBlock[ \ {resultvec,vector,term,size,sym,nn,\n \tco,coef,ratio,newsize,\n\t\ powlist,powterm,powco,expr},\n\n\texpr = exp;\n\tresultvec = {};\n\texpr =\t\t\ Expand[Together[expr]];\n\tnn = \t\tLength[varlist];\n\n\tWhile[expr=!=0,\n \ \tIf[isterm[expr],\n\t \tsize = 1,\n\t \tsize = Length[expr]\n\t \ ];\n\t\tIf[isterm[expr],\n\t \tterm = expr,\n\t \tterm = First[expr]\n\t\ ];\n\t\tcoef =\tnumfactor[term];\n\t\tterm =\tterm/coef;\n\t\tsym =\t\ symmetrize[term,varlist];\n\t\tco =\tCoefficient[sym,term];\n\t\t\ If[isterm[sym],\n\t\t \tco = nn!,\n\t\t \tco = numfactor[First[sym]]\n\t\t \ ];\n\t\tIf[co==0,\n\t \t\tPrint[\"co=0 term=\",term,\" sym=\",sym,\n\t \t\t\ \t\" expr=\",expr,\" coef=\",coef];\n\t \t ];\n\t\tratio =\tcoef/co;\n\n\t\t\ vector =\tExponent[term,varlist,Identity];\n\n\t\tpowlist =\t\ MapThread[Power,{varlist,vector}];\n\t\tpowterm =\tApply[Times,powlist];\n\t\t\ powco =\t\tTogether[term/powterm];\n\n\t\tvector =\t\ Apply[SS,Reverse[Sort[vector]]];\n\t\tvector =\tratio*powco*vector;\n\t\t\ PrependTo[resultvec,vector];\n\t\texpr =\t\tExpand[expr - ratio*sym];\n\t\t\ If[isterm[expr],\n\t \tnewsize = 1,\n\t \t\tnewsize = Length[expr]\n\t \ \t ];\n\t\tIf[newsize >= size && expr =!= 0,\n\t\t\tPrint[\"internal error, \ expression got larger\"];\n\t\t\tPrint[\"term=\",term,\" ratio=\",ratio,\" \ coef=\",coef,\" co=\",co];\n\t\t\tPrint[\"size=\",size,\" newsize=\",newsize,\ \" sym=\",sym];\n\t\t\tPrint[expr];\n\t\t\terror[expr];\n\t\t ];\n \t];\n\ \n Return[resultvec];\n\t];\n\nisterm[expr_] :=\nBlock[{},\n\t\ If[AtomQ[expr],Return[True]];\n\tIf[Head[expr]=!=Plus,Return[True]];\n\t\ Return[False];\n\t];\n\nsymmetrize[term_,varlist_]:=\nBlock[ {result},\n\n\t\ cumulate[tem_,arg_]:= {result+=tem;Return[True];};\n\n\tresult = 0;\n\t\ symm[term,varlist,cumulate,0];\n\tReturn[result];\n\t];\n\ntest[expr_] :=\n\ Block[ {varlist,result},\n\tvarlist = Variables[expr];\n\tPrint[\" \"];\n\t\ Print[\"----------\"];\n\tPrint[expr];\n\tresult = homogineq[expr,varlist];\n\ \tIf[result=!=True,\n\t\tPrint[\"********* COULD NOT PROVE THIS INEQUALITY \ *********\"];\n\t ];\n\t];\n\nclearfractions[] :=\n(* Implicit arguments: \ left, right, op. *)\nBlock[ {dl,dr,prod,pr},\n\tleft =\tTogether[left];\n\t\ right =\tTogether[right];\n\tdl = Denominator[left];\n\tdr = \ Denominator[right];\n\tprod = PolynomialLCM[dl,dr];\n\n \tIf[prod=!=1,\n \t\ \tleft =\tNumerator[left]*(prod/dl);\n\t\tright =\t\ Numerator[right]*(prod/dr);\n\t\tleft =\tExpand[Together[left]];\n\t\tright =\ \tExpand[Together[right]];\n\t\tIf[showproof,\n\t \t\tpr = Factor[prod];\n\t \ \t\tPrint[\"Multiplying both sides by \",pr,\" gives:\"];\n\t \t\t\ Print[op[left,right]];\n\t \t ];\n\t ];\n\t];\n\ngcdize[] :=\n(* Implicit \ arguments: left, right, op, showproof. *)\nBlock[ {temp},\n\n\tIf[left==0 || \ right==0, Return[]];\n\n\ttemp = PolynomialGCD[left,right];\n\n\t\ If[NumberQ[temp] && temp<0,\n \t\tPrint[\"Oops: gcd was negative.\"];\n\t ];\ \n\n \t(* Should really confirm that temp is positive. *)\n\n \t\ If[temp==1,Return[]];\n\n\tleft =\tExpand[Together[left/temp]];\n\tright =\t\ Expand[Together[right/temp]];\n\tIf[showproof,\n\t temp = Factor[temp];\n\t\ \tPrint[\"Dividing both sides by \", temp, \" gives:\"];\n\t\t\ Print[op[left,right]];\n\t ];\n\tIf[!NumberQ[temp],collect[]];\n\t];\n\n\ normalorder[] :=\n(* Returns left, right and op making\n left side larger \ than right. *)\n(* Implicit inputs: left, right, op *)\nBlock[{},\n\n\t\ If[op===Less || op===LessEqual,\n \t{left,right} = {right,left};\n\t\t\ If[op===Less,op=Greater];\n\t\tIf[op===LessEqual,op=GreaterEqual];\n\t ];\n\n\ \t];\n\ncheckobvious[] :=\n (* Implicit inputs: left, right, op, showreason. \ *)\n Block[ {},\n\n collect[];\n\n If[right==0 && op=!=Equal,\n \ If[showreason,\n Print[\"This is true because a sum of positive terms \ must be positive.\"];\n\t ];\n Return[True];\n ];\n\n If[left==0 && \ right=!=0 && op=!=Equal,\n If[showreason,\n Print[\"This is false \ because a sum of positive terms must be positive.\"];\n ];\n \ Return[False];\n ];\n\n Return[undecided];\n\n\t];"], "Input", InitializationCell->True, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"perm\"\n \ is similar to existing symbol \"term\"."], "Message", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "General::spell1: \n Possible spelling error: new symbol name \"error\"\n \ is similar to existing symbol \"Error\"."], "Message", Evaluatable->False, AspectRatioFixed->True]}, Open]]}, Open]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 1152}, {0, 850}}, AutoGeneratedPackage->Automatic, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{520, 740}, WindowMargins->{{12, Automatic}, {Automatic, 13}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, MacintoshSystemPageSetup->"\<\ 02P0001804P000000^L2D_ogooL33`9K8085:0?l0000005X0FP000003X<;VP5d 038;VTRX04/00@4100000BL?00400@000000000000000000000000000040I0<0 00000000002@X@@08@000000000e@b/P\>" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 4899, 69, 70, "Input", InitializationCell->True], Cell[6633, 122, 199, 4, 70, "Message", Evaluatable->False], Cell[6835, 128, 197, 4, 70, "Message", Evaluatable->False], Cell[7035, 134, 203, 4, 70, "Message", Evaluatable->False], Cell[7241, 140, 198, 4, 70, "Message", Evaluatable->False], Cell[7442, 146, 200, 4, 70, "Message", Evaluatable->False], Cell[CellGroupData[{ Cell[7665, 152, 9112, 126, 70, "Input", InitializationCell->True], Cell[16780, 280, 201, 4, 70, "Message", Evaluatable->False], Cell[16984, 286, 203, 4, 70, "Message", Evaluatable->False], Cell[17190, 292, 201, 4, 70, "Message", Evaluatable->False] }, Open ]], Cell[CellGroupData[{ Cell[17423, 298, 1189, 19, 70, "Input", InitializationCell->True], Cell[18615, 319, 198, 4, 70, "Message", Evaluatable->False], Cell[18816, 325, 203, 4, 70, "Message", Evaluatable->False], Cell[19022, 331, 197, 4, 70, "Message", Evaluatable->False] }, Open ]], Cell[CellGroupData[{ Cell[19251, 337, 5036, 69, 70, "Input", InitializationCell->True], Cell[24290, 408, 197, 4, 70, "Message", Evaluatable->False], Cell[24490, 414, 199, 4, 70, "Message", Evaluatable->False] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)