Re: Re: holding boxes verbatim
- To: mathgroup at smc.vnet.net
- Subject: [mg56486] Re: [mg56258] Re: holding boxes verbatim
- From: Chris Chiasson <chris.chiasson at gmail.com>
- Date: Tue, 26 Apr 2005 21:52:41 -0400 (EDT)
- References: <00aa01c544e3$6db4af30$6400a8c0@Main> <200504200931.FAA17986@smc.vnet.net>
- Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Dear Mathgroup gurus, Thank you for your replies to my questions in this thread so far. To follow up: The notation package is really independent of the question I was asking. I found the solution to the simple examples I gave above and to the problem I was trying to solve earlier. However, I have a new problem now... But first, the solutions I found are as follows (evaluate them for the two dimensional version): (*b*(a + s*m) -> b (a + m s) is fixed by using :*) RowBox[{"b", "*", RowBox[{"(", RowBox[{"a", "+", RowBox[{"s", "*", "m"}]}], ")"}]}] // DisplayForm (*(x)^(1/2) -> sqrt(x) is fiex by using :*) RowBox[{RowBox[{"(", "x", ")"}], "^", RowBox[{"(", RowBox[{ "1", "/", "2"}], ")"}]}] // DisplayForm (*(x/y)(h/g) is fixed by using :*) RowBox[{RowBox[{"(", RowBox[{"x", "/", "y"}], ")"}], RowBox[{ "(", RowBox[{"h", "/", "g"}], ")"}]}] // DisplayForm Now for the new problem: The expression I wanted to output was this (evaluate it for 2d): RowBox[{"CA", "==", RowBox[{RowBox[{"(", FractionBox[ RowBox[{"99", " ", "Kilo", " ", "Pascal"}], RowBox[{" P", "[", RowBox[{"a", ",", "db"}], "] "}]], ")"}], SuperscriptBox[RowBox[{"(", \ FractionBox[RowBox[{"T", "[", "db", "]"}], RowBox[{"298", " ", "Kelvin"}]], ")"}], RowBox[{"1", "/ ", "2"}]]}]}] // DisplayForm However, I noticed that the one way Notations I defined (using <==) are not applied. For instance T[db] (which is RowBox[{"T","[", "db", "]"}] in boxes) in the output of the last command would be T subscripted by db. Does anyone know how to cause the Notation package to "process" something that is already in box form? I imagine one solution would be to selectively evaluate the above expression with MakeExpression so that RowBox[{"T","[", "db", "]"}] turned into T[db], which could then be processed by the notation package. Another solution might be to define a procedure to call on output (isn't there a variable where one can set this?) which would replace RowBox[{"T","[", "db", "]"}] with RobBox[SubscriptBox["T","db"]]. I already have a bunch of notations set up that I would like to reuse, but I can redo it all if need be. What is the right way to go about "using Notation rules on boxes"? Thank you for your very valuable time, On 4/20/05, Chris Chiasson <chris.chiasson at gmail.com> wrote: > As a follow up to those who requested clairification: > > Consider the simple examples: > > HoldAllComplete[b*(a + s*m)] (*notice the order of the vairables > inside the inner Times is rearranged on output*) > HoldAllComplete[(x)^(1/2)] (*notice the reformatting of an expression > to the power 1/2 is reformatted to the square root of the expression*) > HoldAllComplete[(x/y)(h/g)] (*notice the elimination of the parenthesis*) > > The reason these things happen is that the boxes are parsed into > Mathematica input such as Times[b,Plus[a,Times[s,m]]]. > > I need a way to work directly with the boxes, but still at least do > some variable substitution. > > Thank you again for your time. > > On 4/19/05, Carl K. Woll <carlw at u.washington.edu> wrote: > > "Chris Chiasson" <chris.chiasson at gmail.com> wrote in message > > news:d42l18$3gf$1 at smc.vnet.net... > > > Dear Math Group gurus, > > > > > > Mathematica is annoying me. I would like some way to type in a two > > > dimensional box form (representing an arbitrary expression) and assign > > > it to a symbol. I would then like to be able to operate on the > > > expression by, for instance: > > > 1 printing it > > > 2 printing it with some variables' values substitued into it > > > 3 and finally evaluating it > > > > > > Hold and its variants do not do the job because they prevent > > > expression evaluation, but I need something that will keep its box > > > form exactly as I have typed it. > > > > > > Please, how does one do this? > > > > > > A method for doing this is very useful to me because my professors > > > like to see the variables substitued into the original (not > > > Mathematica reparsed original, but verbatim original) equations. > > > > > > Thank you for your very valuable time, > > > > An example of the desired behavior would be helpful. At any rate, have you > > tried using HoldForm? For example: > > > > expr = HoldForm[2^(x+1)]; > > expr > > expr /. x->2 > > ReleaseHold[ expr /. x->2 ] > > > > x + 1 > > 2 > > 2 + 1 > > 2 > > 8 > > > > I used InputForm instead of a 2D box form for expr for legibility, but using > > a 2D box form for expr won't cause any problems. > > > > If the above is not helpful, please give an example of the behavior you > > desire. > > > > Carl Woll > > > > > > -- > Chris Chiasson > Kettering University > Mechanical Engineering > Graduate Student > 1 810 265 3161 > > -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161
- References:
- Re: holding boxes verbatim
- From: Chris Chiasson <chris.chiasson@gmail.com>
- Re: holding boxes verbatim