Re: Math Formulas

*To*: mathgroup at smc.vnet.net*Subject*: [mg92716] Re: Math Formulas*From*: John <jwa0 at lehigh.edu>*Date*: Sat, 11 Oct 2008 06:44:42 -0400 (EDT)*References*: <gckn71$noe$1@smc.vnet.net> <gcn4hp$7as$1@smc.vnet.net>

On Oct 10, 4:42 am, Bob F <deepyog... at gmail.com> wrote: > On Oct 9, 4:42 am, John <j... at lehigh.edu> wrote: > > > > > Mathematica 6, WindowsXP > > > NotebookPut[ > > Notebook[{Cell["October 7, 2008", "Text", TextAlignment -> 1, > > FontSize -> 24, Bold, > > CellMargins -> {{Inherited, Inherited}, {50, Inherited}}], > > Cell["Probability Of Acceptance", "Section", "Text", > > CellFrame -> False, > > CellMargins -> {{Inherited, Inherited}, {4, 3}}], > > Cell["Use the formula,", "Text", TextJustification -> 1, > > Hyphenation -> True, FontSize -> 16, Bold, CellFrame -> False, > > CellMargins -> {{Inherited, Inherited}, {10, Inherited}}], > > Cell[BoxData[ > > RowBox[{ RowBox[{"(", GridBox[{{"c"}, {"i"}}], ")"}], > > SuperscriptBox["p", "i"], > > SuperscriptBox["(1-p)", "c-i"]}] ] , "Tex= t"= > , > > FontSize -> 16, Bold, TextJustification -> 1, Hyphenation -> Tr= ue= > , > > CellMargins -> {{Inherited + 35, Inherited}, {10, Inherited}= }]= > , > > Cell["to compute the probability that acceptance sampling deems = a = > \ > > lot to be acceptable. Values of n, c amd p are specified by the \ > > user.", "Text", FontSize -> 16, Bold, TextJustification -> 1, > > Hyphenation -> True, CellFrame -> False, > > CellMargins -> {{Inherited, Inherited}, {10, Inherited}}]}]] > > > The cell that prints the formula was suggested to me by Bob. It > > prints the formula correctly. > > My attempts to insert a summation sign in front of the formula failed. > > The command > > > Sum[f,{i,0,c}] > > > didn't do the job. Maybe I didn't put it in the right place. > > > Latex formulas are elegant (suitable for framing). Can Mathematica > > match the elegance of Latex? If so I want to know how to do it. > > > John > > John, > > One way is to do: > > NotebookPut[ > Notebook[{Cell["October 7, 2008", "Text", TextAlignment -> 1, > FontSize -> 24, Bold, > CellMargins -> {{Inherited, Inherited}, {50, Inherited}}], > Cell["Probability Of Acceptance", "Section", "Text", > CellFrame -> False, > CellMargins -> {{Inherited, Inherited}, {4, 3}}], > Cell["Use the formula,", "Text", TextJustification -> 1, > Hyphenation -> True, FontSize -> 16, Bold, CellFrame -> False, > CellMargins -> {{Inherited, Inherited}, {10, Inherited}}], > Cell[BoxData[ > RowBox[{RowBox[{UnderoverscriptBox["\[Sum]", > RowBox[{"i", "=", "0"}], "c"], "(", GridBox[{{"c"},= {"i"}}], > ")"}], SuperscriptBox["p", "i"], > SuperscriptBox["(1-p)", "c-i"]}]], "Text", FontSize -> 16, > Bold, TextJustification -> 1, Hyphenation -> True, > CellMargins -> {{Inherited + 35, Inherited}, {10, Inherited}}], > Cell["to compute the probability that acceptance sampling deems a > lot to be acceptable. Values of n, c amd p are specified = by > the > user.", "Text", FontSize -> 16, Bold, TextJustification -= > 1, > Hyphenation -> True, CellFrame -> False, > CellMargins -> {{Inherited, Inherited}, {10, Inherited}}]}]] > > But this is so much work, there must be a better way. And there is. > Use Mathematica as it was designed to create a technical document and > try the following: (don't forget that you need to highlight the > desired text or cell and then apply the indicated command - I have > specified the Mac menu commands and shortcuts, so if you have a > Windows or Linux or other version of Mathematica substitute the > correct menu command or shortcut, although the menu commands are > usually the same) > > 1. File/New Notebook (or Command-n keyboard shortcut) > 2. Type in "October 7, 2008" and set it to be a "Text" style cell > (Format/Style/Text or Command-7 shortcut), with a font size of your > choice (Format/Size/Larger or shortcut Command-= on a Mac) and right > justified (Format/Text Alignment/Align Right), and make it bold > (Format/Face/Bold or Command-b shortcut) > 3. Create the next cell with "Probability Of Acceptance" as a > "Section" cell (Format/Style/Section or shortcut Command-4) and change > the text size and boldness as in step 2 > 4. Create the next cell with "Use the formula," as a "Text" cell with > size and boldness as desired > 5. Create the next cell with the formula as a "Text" cell, then use > the"BasicMathInput" palette to enter the Sum, the binomial > coeffecient, and the exponential elements of the formula, and then set > the size and boldness as desired > 6. Create the next cell with the "to compute the ..." phrase as a Text > cell with size and boldness as desired > 7. You can indent the formula by using the Ruler - first highlight the > formula cell (click on the cell bracket is one way), then just drag > the margin indicators right underneath the ruler (they look like bold > right angle symbols) to adjust the left margin to the desired amount. > You can turn on the "Ruler" from the "Window" menu command, and you > might also turn on the "Toolbar" as well. The Toolbar shows what style > the current cell is (Section, Text, Input, Output, etc) and shows text > justification and font shortcuts too, as well as a Print and Help > icons. I prefer to have both (Ruler and Toolbar) visible at all times, > but that is entirely up to you as to what you prefer. > > You are done - and not one BoxData, or Grid or anything. So you need > to explore how to create cells of different types (Section, > subsection, text, input, etc) and how to modify their visual > attributes, rather than create them with the low-level Mathematica > commands like LaTeX does. This is so much easier IMO, but if you > really want to you can look at the underlying code by doing a "Cell/ > Show Expression" menu command to see all the low-level commands that > form the document you see. By the way, if you want several cells to > have the same attributes, highlight several of them at once by > clicking on the first cell bracket while holding the "Shift" key, and > then click on the last cell bracket, then do the size, style, etc > commands to all of them at once. If some of the cells are not adjacent > to each other (for example the 1st, 3rd and 5th cells you want to all > change to bold), then use the Command key instead of the Shift key and > click on only the desired cells before doing the desired change. > > I would post the resulting notebook, but don't know how to get complex > equations like this example to reproduce correctly -- can someone > suggest how to do this? I will e-mail John the resulting notebook > separately so he can see exactly what the notebook looks like when > created this way. > > You can also start to explore the use of cell groups where you might > have some Input cell with a long program to create a plot, but you > dont really want to show the code in a presentation - in that case put > the code and the plot in a cell group, then double-click on one or the > other to hide the other cells in the group, e.g. double-click on the > cell bracket of the plot and the input cell with the code is hidden, > or double click on the input cell with the code and the plot is > hidden. But notice that an Input cell with a program is always a > member of the cell group that also contains it's output cell, so the > step to make them part of a group may already be done. To get back the > hidden cells, just double-click on the outermost cell bracket on the > right of the notebook window. To group several cells together, just > click on their cell brackets and then do a "Cell/Grouping/Group Cells" > menu command. You can put as few as 2 or as many as desired in a > group. You can ungroup them later as well with the "Cell/Grouping/ > Ungroup cells" menu command. > > You can also turn on or off the cell brackets so they are invisible or > visible as you wish. One way to do this is with the Option Inspector, > but be careful setting things with the Option Inspector as it can do > things that are not easy to undo. > > Doing things this way, avoids having to deal with the low-level code > that John's example has. It is hard at first to remember where all the > commands are and what the shortcuts are, but as with anything else, > the more you use it the more you will remember. > > Hope this helps explain things a bit. But explore using Mathematica on > your own and look at as many different ways of using as possible to > see how versatile and powerful it is. > > Also, I think there is a mistake as the phrase "Values of n, c and p" > should be "Values of c, i, and p" (there is no "n" in this equation). > > -Bob Freeman Bob, There is a mistake in my formula. The upper number in the combinatorial formula should be n and the exponent of (1-p) should be n-i. I am still working on the alternate method that you described in your message. Thank you for your helpful advice. John