Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

LeafCount Question

  • To: mathgroup at
  • Subject: [mg25782] LeafCount Question
  • From: "Dana" <dana_news at>
  • Date: Wed, 25 Oct 2000 03:53:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hello.  Using Mathematica 4.0  When one solves equations, I get a little frustrated
when the answers come out as
-A +B, when the answer looks much better as...
B - A

I was hoping that the "LeafCount" would be smaller with my "preferred" way,
but for some reason, it does not look like there is a difference.

{LeafCount[-B + D], LeafCount[D - B]}

{5, 5}

Here is a simple Solve, and it is a little embarrassing to say the answer is
(-B + D)..Etc when  everyone else will have to change this  manually to (D -

Is there a way around this?  Again, I was hoping LeafCount would do the
trick, but it apparently does not.
Thank you in advance.  Dana.

FullSimplify[Solve[{Y == A*X + B, Y == C*X + D}, {X, Y}],
  ComplexityFunction -> LeafCount]

{{X -> (-B + D)/(A - C), Y -> (-(B*C) + A*D)/(A - C)}}

Since I am new to Mathematica, I noticed the following...
Internally, it looks like no difference.  It is just frustrating.

{FullForm[(-B + D)], FullForm[(D - B)]}

{Plus[Times[-1, B], D], Plus[Times[-1, B], D]}

  • Prev by Date: Vertical Tangents
  • Next by Date: Adding a new style environment
  • Previous by thread: Re: Vertical Tangents
  • Next by thread: RE: LeafCount Question