Re: Using % in ; separated commands
- To: mathgroup at smc.vnet.net
- Subject: [mg35904] Re: Using % in ; separated commands
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 7 Aug 2002 05:59:22 -0400 (EDT)
- References: <ailj89$hq2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Kaustubh, % gives the output from the last input line evaluated. Several input lines can be in the same input cell, but to be recognised as separate they must be separated by a new line symbol - obtained by using the key Return ( a visual new line produced by automatic wrap around is not sufficient). Solve[Sin[a]==0.4717 * Sin[(Pi/3)-a],a]; Last[a /. %] is a single input line. More fully,it is a compound expression: CompoundExpression[ Solve[Sin[a]==0.4717 * Sin[(Pi/3)-a],a]; Last[a /. %]] This explains the behaviour that you see. The behaviour that you want may be obtained by using Solve[Sin[a]==0.4717 * Sin[(Pi/3)-a],a]; Last[a /. %] With Return at the end of the first line. or by putting the two lines in separate cells. -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Kaustubh Raghukumar" <kausmic at yahoo.com> wrote in message news:ailj89$hq2$1 at smc.vnet.net... > Hi, > I have been using Mathematica for basic stuff so far > and find myself lost on how to acheive the following: > > I need to extract the last numerical value of 'a' in > Solve ( without the 'a ->'), so I can use it > elsewhere, without having to type it in. Here is what > I wrote > > Solve[Sin[a]==0.4717 * Sin[(Pi/3)-a],a]; Last[a /. %] > > The problem is that the value in '%' is not the output > of Solve, but the whatever operation came before that! > Any help on how to extract the last numerical from > solve will be greatly appreciated. > > Thanks a lot, > Kaustubh > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Health - Feel better, live better > http://health.yahoo.com >