RE: showing your work in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg69836] RE: [mg69821] showing your work in mathematica
- From: "David Park" <djmp at earthlink.net>
- Date: Mon, 25 Sep 2006 03:52:50 -0400 (EDT)
Christopher, It is possible, and very desirable, to show your work in Mathematica. But Trace is probably not the best method for doing so. (Trace is sometimes useful for debugging.) The best way to show your work, or to present material in a didactic fashion is to: 1) Use the notebook Section and Subsection organization 2) When you want more detail than the regular Mathematica Simplify, or you need special rules, then define the transformation rules and give them names (and maybe even parameters). If you have derived an equation in one part of your notebook you can change it into a rule to use in further derivations. 3) Use Text cells to explain what you are doing. Explaining and doing is better than just doing. 4) You can usually do a number of derivation steps in one cell. Within one cell you can safely use the '%' and '%%' reference system. You can keep modifying and reevaluating such cells until you are happy with the result. 5) Within a single cell you can intersperse Print statements to annotate the steps. The Print statement allows you to mix text and expressions (such as the transformation rule used) so you can make fairly elaborate annotation. In a good notebook, if you should evaluate and then close all the Input cells (Alt-CRC) then the notebook should read like a research paper or textbook. You won't usually really want to close all the Input cells but I'm just suggesting that the text and output should be able to stand on their own. Here is a small example. It comes from answering the question posted today by Guillermo Sanchez. "I have a pair of elements list. The second elements of the list should be summed when the first element of the pairs are equals." testlist = {{a1, b1}, {a2, b3}, {a2, b4}, {a3, b5}, {a3, b6}, {a2, b2}}; Print["The starting list"] testlist Print["Sort the list"] Sort[testlist] Print["Split the list on equality in the first element"] Split[%%, First[#1] === First[#2] &] Print["Sum the second elements in each group using the following function: ", \ {Part[#, 1, 1], Last@Total[#]} &] {Part[#, 1, 1], Last@Total[#]} & /@ %% David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Christopher Arthur [mailto:caa0012 at unt.edu] To: mathgroup at smc.vnet.net Hi, Has anyone ever tried using a form of Trace[] around a call to Simplify[]? It would be neat if we could set it up in such a way so that we get a list of all the transformations that lead to the final solution.