Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Output of left-hand side of expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35537] RE: [mg35509] Output of left-hand side of expression
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 18 Jul 2002 03:06:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I do not know your larger objective so I can only give some general advice.
First, in general it is better to use small letter variables in Mathematica,
as Mathematica sometimes reserves capital letter symbols.

Second, if you want to use a symbol as a symbol in further expressions then
don't set it to something else. In Mathematica = is the Set statement. It
sets the lhs symbol to be the rhs. After that, anytime you enter the lhs
symbol, Mathematica will immediately replace it by the rhs. In consequence,
the lhs symbol will nevermore appear in one of your output cells. (Unless
you put it in a Hold or HoldForm.)

Perhaps what you want is ==, which in Mathematica is a logical expression
giving True or False. But if you write

m = c + 1;
m == c + 1  you get
True

And if you wanted to solve the equation for c...

Solve[m == c + 1, c]
{{}}

you obtain no solution because the equation is automatically True.

Often it is better to resist using the Set (=) statement. If you want to
continue using a symbol and using or manipulating expressions that contain
the symbol, then use rules rather than the set statement.

Clear[m]

mRule = m -> c + 1;

Now you can write the equation for m and substitute the value with the rule.

m == c + 1
% /. mRule
m == 1 + c
True

You retain both sides of the equation in the first step. You could now also
solve for c.

Solve[m == c + 1, c]
{{c -> -1 + m}}

So the general idea is: if you want to keep using a symbol, don't Set it to
some other expression, rather use rules to affect the subsequent
substitution.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: news.eircom.net [mailto:J_M_1967 at hotmail.com]

Hello
This is really simple but I cannot find in manuals. (Honestly!)

Q. How do I display the left-hand side of an expression

currently I do

In[148]:=
M=C+1
Out[148]=
1+C

but I want

Out[xxx]=
M=1+C

I need this so that I can copy/paste the entire expression into a doc. so
that it is complete - not just the right hand side or result.

Is there some magic command that can do this? or system default?

Thankyou.







  • Prev by Date: Re: Expanding expressions with Dot, Times and Plus
  • Next by Date: Re: Problems with simulating society ch4 section 4.3
  • Previous by thread: Re: Output of left-hand side of expression
  • Next by thread: Re: Output of left-hand side of expression