Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Collecting Positive and Negative Terms

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112330] Re: Collecting Positive and Negative Terms
  • From: "E. Martin-Serrano" <eMartinSerrano at telefonica.net>
  • Date: Thu, 9 Sep 2010 04:24:46 -0400 (EDT)

This example illustrates the need of keeping constantly in mind that
Mathematica actually works with expressions under FullForm.

In[1]:== myExpression == a+b-c;

In[2]:== FullForm[myExpression]

Out[2]:== Plus[a,b,Times[-1,c]]

In[3]:== DeleteCases[myExpression,Times[-1,___]]

Out[3]:== a+b

Of course, Times[-1,c] (in Out[2]) matches Times[-1,___] in (In[3])

Most times things get much more subtle and troublesome than this one if you
try to understand an expression like this directly from its plain InputForm.

So =BFwhat about a built-in button to pop-up a panel showing InputForm
expressions converted to FullForm without the need of writing the 'In[2]'
request explicitly as to see its inner structure?

E. Martin-Serrano


-----Original Message-----
From: Michael Knudsen [mailto:micknudsen at gmail.com]
Sent: Wednesday, September 08, 2010 7:00 AM
To: mathgroup at smc.vnet.net
Subject: [mg112330] [mg112301] Re: Collecting Positive and Negative Terms

On Aug 14, 12:32 pm, Bob Hanlon <hanl... at cox.net> wrote:

> myExpression == a + b - c;
>
> DeleteCases[myExpression, Times[-1, ___]]
>
> a+b

Thanks! That was just what I needed!

--
Michael Knudsen


  • Prev by Date: Re: Matrix with number of rows / columns not fixed
  • Next by Date: Re: Sorting a list of names
  • Previous by thread: Re: Collecting Positive and Negative Terms
  • Next by thread: Re: Collecting Positive and Negative Terms