Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: checking the sign of all terms in a long expression
Replies: 6   Last Post: Apr 13, 2014 5:25 AM

 Messages: [ Previous | Next ]
 Murray Eisenberg Posts: 2,105 Registered: 12/6/04
Re: checking the sign of all terms in a long expression
Posted: Apr 12, 2014 5:17 AM

Are the symbols a, b, etc., just symbolic, as you seem to indicate, or might they be actual numeric values, too?

If indeed the symbols a, b, etc. are just symbols and NOT numbers, then the following should help -- but note that Mathematica will automatically rearrange the terms of toCheck into its usual canonical form.

toCheck = a + a b + a b c + a c - b + bc + d - e f
(* a - b + a b + bc + a c + a b c + d - e f *)

Flatten@Position[List@@toCheck, Times[-1,__]]
(* {2, 8} *)

If you insist on identifying the "negative" terms by their positions in the original expression, before it is evaluated, then you may want to treat it as a string, and the treatment will be trickier.

On Apr 11, 2014, at 2:10 AM, dantimatter <google@dantimatter.com> wrote:

>
> hello all
> is there to check the signs of all terms in a symbolic expression, like
>
> toCheck = a + a b + a b c + a c - b + bc + d ....
>
> in this case, with the assumption that the a, b, c etc are all positive, only one term is negative (b by itself) and the rest are positive. I have expressions like this that have a hundred or more terms and i'm worried i might not be catching all those that are of a different sign.
>
> thanks
>

Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305

Date Subject Author
4/12/14 Bob Hanlon
4/12/14 dantimatter
4/12/14 Brambilla Roberto Luigi (RSE)
4/12/14 Murray Eisenberg
4/13/14 Bob Hanlon