Printing head of list of examples

Mathematica program

(* Printing head of list of examples *)

Get["\\sergeev\\purdue\\math\\packages\\printing.m"];

<< Graphics`Graphics`; << Graphics`MultipleListPlot`;

rndm := ToString[Random[Integer, {0, 999999}]];

p[s_String] := Write[of, s];

Discriminant[p_?PolynomialQ, x_] := 
    With[{n = Exponent[p, x]}, 
      Cancel[((-1)^(n(n - 1)/2)Resultant[p, D[p, x], x])/
          Coefficient[p, x, n]^(2n - 1)]];

(* Printing navigation line at bottom of each table or figure *)
printnav := (
"<FONT SIze=\"-2\"><A HREF=\"#top\"><IMG SRC=\"../../../../iconz/top.gif\" WIDTH=13 HEIGHT=9 BORDER=0 ALT=\"Top of Page\" ALIGN=\"MIDDLE\"></A>&nbsp;&nbsp;<A HREF=\"#top\">Top&nbsp;of&nbsp;the&nbsp;page</A>&nbsp;&nbsp;&nbsp;&nbsp;" // p;
If[nser != 1,
   namem = names[[nser-1]];
   nameml = StringReplace[ToLowerCase[namem], "+" -> "-"];
   ref = "../" <> nameml <>"/index.htm#" <> sect;
   "&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" <> ref <> "\"><IMG SRC=\"../../../../iconz/top270.gif\" WIDTH=9 HEIGHT=13 BORDER=0 ALT=\"Previous Example\" ALIGN=\"MIDDLE\"></A>&nbsp;&nbsp;<A HREF=\"" <> ref <> "\">Prev.&nbsp;(" <> namem <> ")</A>" // p];
"&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"#" <> sect <> "\"><IMG SRC=\"../../../../iconz/top.gif\" WIDTH=13 HEIGHT=9 BORDER=0 ALT=\"Top of" <> entity <> "\" ALIGN=\"MIDDLE\"></A>&nbsp;&nbsp;<A HREF=\"#" <> sect <> "\">Top&nbsp;of&nbsp;this&nbsp;" <> entity <> "&nbsp;(" <> name <> ")</A>" // p;
If[nser != mser,
   namep = names[[nser+1]];
   namepl = StringReplace[ToLowerCase[namep], "+" -> "-"];
   ref = "../" <> namepl <>"/index.htm#" <> sect;
   "&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" <> ref <> "\"><IMG SRC=\"../../../../iconz/top90.gif\" WIDTH=9 HEIGHT=13 BORDER=0 ALT=\"Next Example\" ALIGN=\"MIDDLE\"></A>&nbsp;&nbsp;<A HREF=\"" <> ref <> "\">Next&nbsp;(" <> namep <> ")</A>" // p];
"&nbsp;&nbsp;&nbsp;&nbsp;" // p;
"&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"../" <> sect <> ".htm\"><IMG SRC=\"../../../../iconz/smalldig.gif\" WIDTH=12 HEIGHT=17 BORDER=0 ALT=\"Mathematica program\" ALIGN=\"MIDDLE\"></A>&nbsp;&nbsp;<A HREF=\"../" <> sect <> ".htm\"><I>Mathematica</I>&nbsp;program</A>" // p;
"</FONT><BR><BR>" // p;
);

(* Printing Mathematica program in HTML-format *)
htmlrepl[s_String] := StringReplace[s, {"<"->"&lt;", ">"->"&gt;", "&"->"&amp;", "\""->"&quot;"}];
flankblank[s_String]:=
Module[{s0,s9},
 If[s=="",s,
  If[s0=StringTake[s,1];s0==" "||s0=="\n",flankblank[StringDrop[s,1]],
   If[s9=StringTake[s,-1];s9==" "||s9=="\n",flankblank[StringDrop[s,-1]],s]]]
       ];
printprogrs = {};
printprogr[sect_String] := If[!MemberQ[printprogrs, sect],
progfile = ToFileName[dirhome, sect <> ".m"];
progtext = Import[progfile, "Text"];
sp1 = StringPosition[progtext, "(*"];
sp2 = StringPosition[progtext, "*)"];
progtitle = 
  If[sp1 =!= {} && sp2 =!= {}, 
    StringTake[progtext, {sp1[[1, 2]] + 1, sp2[[1, 1]] - 1}], ""];
{progtext,progtitle} = htmlrepl/@flankblank/@{progtext,progtitle};
outfile = ToFileName[dirhtml, sect <> ".htm"];
of1 = OpenWrite[outfile, PageWidth -> Infinity, FormatType -> OutputForm];
proghtml = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n
<HTML><HEAD>\n
<TITLE>" <> progtitle <> "</TITLE>\n
<META http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n
<META name=\"description\" content=\"Source text of Mathematica program used for study of MP perturbation series\">\n
<META name=\"keywords\" content=\"Mathematica, programming, computation, Moller Plesset perturbation theory, summation, Pade approximants\">\n
</HEAD><BODY BACKGROUND=\"../../../iconz/bg-calc.gif\">\n
<H1>" <> progtitle <> "</H1>\n
<H2><I>Mathematica</I> program</H2>\n
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 BGCOLOR=\"#FEF8CB\"><TR>\n
<TD><PRE>" <> progtext <> "</PRE></TD></TR></TABLE>\n
<BR>\n
<TABLE><TR ALIGN=\"CENTER\">\n
<TD ALIGN=\"CENTER\" VALIGN=\"CENTER\"><A HREF=\"proglist.htm\">All <I>Mathematica</I> programs used to study M. - P. series</A></TD>\n
<TD ALIGN=\"CENTER\" VALIGN=\"TOP\"><img SRC=\"../../../blank.gif\" WIDTH=32 HEIGHT=43 ALT=\"Blank\"></TD>\n
<TD ALIGN=\"CENTER\" VALIGN=\"CENTER\"><A HREF=\"../index.htm\">Work in UMassD</A></TD>\n
<TD ALIGN=\"CENTER\" VALIGN=\"TOP\"><IMG SRC=\"../../../blank.gif\" WIDTH=32 HEIGHT=43 ALT=\"Blank\"><IMG SRC=\"../../waste.gif\" WIDTH=32 HEIGHT=43 ALT=\"Waste icon\"></TD>\n
<TD ALIGN=\"CENTER\" VALIGN=\"CENTER\"><A HREF=\"../../reports.htm\">Unpublished reports</A></TD>\n
</TR></TABLE>\n
<P><FONT SIZE=\"-2\">Designed by <A HREF=\"../../../index.htm\">A. Sergeev</A></FONT>.</P>\n
</BODY>\n
</HTML>";
Write[of1, proghtml];
Close[of1];
plist = "
<TR ALIGN=\"CENTER\" VALIGN=\"MIDDLE\" BGCOLOR=\"#" <> If[EvenQ[Length[printprogrs]],"FFFFFF","E0E0E0"] <> "\">\n
<TD><TT><A HREF=\"" <> sect <> ".htm\">" <> sect <> "</A></TT></TD>\n
<TD>" <> progtitle <> "</TD></TR>";
Write[oproglist, plist];
printprogrs = Append[printprogrs, sect];
];

(* Starting list of Mathematica programs *)
proglistfile = ToFileName[dirhtml, "proglist.htm"];
oproglist = OpenWrite[proglistfile, PageWidth -> Infinity, FormatType -> OutputForm];
plist = "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n
<HTML>\n
<HEAD>\n
<TITLE>Programs to display results of summation of Moller-Plesset perturbation series as web-pages</TITLE>\n
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n
<META name=\"description\" content=\"Texts of programs for Mathematica software used to calculate and display coefficients of Moller-Plesset perturbation theory, partial sums, Pade approximants, singularities etc.\">\n
<META name=\"keywords\" content=\"quantum mechanics, Moller Plesset perturbation theory, summation, Pade approximants\">\n
</HEAD>\n
<BODY BACKGROUND=\"../../../iconz/bg-calc.gif\">\n
<H1><I>Mathematica</I> programs to display results of summation of Moller-Plesset perturbation series as web-pages</H1>\n
\n
<H2>Main program</H2>\n
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 BGCOLOR=\"#FEF8CB\"><TR>\n
<TD><PRE>(* Display results for each example of series in HTML - format *)\n
Clear[&quot;@&quot;];\n
itest = 0; (* 1 for testing *)\n
newabc = True;  (* re - calculate parameters a, b, c *)\n
newfigure = True;  (* re - create figure files *)\n
dirhtml = &quot;C:\\html\\files\\umassd\\mollerpl&quot;;\n
dirser = &quot;C:\\sergeev\\umassd\\dgoodson\\projects\\qsum\\series&quot;;\n
dirhome = &quot;C:\\sergeev\\umassd\\math\\internet&quot;;\n
If[FileType[dirhtml] =!= Directory,\n
    Print[&quot;Creating HTML-directory &quot;, dirhtml]; CreateDirectory[dirhtml]];\n
Get[&quot;\\sergeev\\umassd\\math\\series\\read.m&quot;];\n
SetDirectory[dirhome];\n
\n
&lt;&lt; indhead.m;\n
Do[\n
    &lt;&lt; indline.m;\n
    &lt;&lt; head.m;\n
    &lt;&lt; ctable.m;\n
    &lt;&lt; cplot.m;\n
    &lt;&lt; cplots.m;\n
    &lt;&lt; errors.m;\n
    &lt;&lt; sings3.m;\n
    &lt;&lt; foot.m,\n
    {nser, mser}];\n
&lt;&lt; indfoot.m;</PRE></TD></TR></TABLE>\n
\n
<H2>Sub-programs</H2>\n
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=5 BGCOLOR=\"C0C0C0\">\n
<TR ALIGN=\"CENTER\" VALIGN=\"MIDDLE\" BGCOLOR=\"#FFFFFF\">";
Write[oproglist,plist];

plt0 = ListPlot[{{0, 0}}, PlotStyle -> {PointSize[0]}, 
      DisplayFunction -> Identity];

names = Select[names, exact[#] != 0 &];
mser = Length[names];

mrul = mser; (* to shrink ruler, decrease to ~20 *)
names1 = names;
ruler = "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5>";
While[(m = Length[names1]) != 0,
    ruler = ruler <> "<TR>";
    Do[
      c = If[nrul <= m,
          name = names1[[nrul]];
          namel = StringReplace[ToLowerCase[name], "+" -> "-"];
          "<FONT SIZE=\"-2\"><A HREF=\"../" <> namel <> "/index.htm\">" <> name <> "</A></FONT>",
          "&nbsp;"];
      ruler = ruler <> "<TD>" <> c <> "</TD>"
      , {nrul, mrul}];
    ruler = ruler <> "</TR>";
    names1 = Drop[names1, Min[m, mrul]]];
ruler = ruler <> "</TABLE>";

indfile = ToFileName[dirhtml, "index.htm"];
indf = 
  OpenWrite[indfile, PageWidth -> Infinity, 
    FormatType -> OutputForm];

of = indf;
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" // p;
"<HTML><HEAD>" // p;
"<TITLE>Examples of Moller-Plesset perturbation theory for different molecules</TITLE>" // p;
"<META name=\"description\" content=\"Details of computations for each example of MP perturbation series\">" // p;
"<META name=\"keywords\" content=\"quantum mechanics, Moller Plesset perturbation theory, summation, Pade approximants\">" // p;
"</HEAD><BODY BGCOLOR=\"#C0C0C0\">" // p;
"<H1>Examples of Moller-Plesset perturbation theory</H1>" // p;
"<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=5>" // p;
"<TR><TH ALIGN=\"CENTER\" VALIGN=\"MIDDLE\" BGCOLOR=\"#FFFFFF\" COLSPAN=4>List of examples. " <>
      "To view details for each example, follow a link to its name</TH></TR>" // p;
"<TR ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" BGCOLOR=\"#FEF8CB\"><TH WIDTH=\"13%\">Name</TH>" <>
      "<TH WIDTH=\"13%\">System</TH><TH WIDTH=\"8%\">Class</TH><TH>Moller-Plesset perturbation series</TH></TR>" // p;

printprogr["indhead"];

All Mathematica programs used to study M. - P. series Blank Work in UMassD BlankWaste icon Unpublished reports

Designed by A. Sergeev.