Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FullForm puzzle.

2 views
Skip to first unread message

Jack L Goldberg 1

unread,
Jan 6, 2010, 5:59:14 AM1/6/10
to
I wonder why two apparently identical output forms have different FullForms.

(1) FullForm[ 2<= x< =3] returns LessEqual[2,x,3]

while

(2) Reduce[ 2<=x && x<=3 ] returns 2 <= x <= 3 whose FullForm is
Inequality[2,LessEqual,x,LessEqual,3].

Any thoughts?

Jack

Jack L Goldberg 1

unread,
Jan 7, 2010, 2:27:53 AM1/7/10
to
Fellow mathematistas:

I sent this post to the two responders but thought it might be of interest

I use a transformations in some of my code that takes a <= x <= b
and converts it into a function I have defined called "characteristic
function" - the name is obviously irrelevant. But to make this
transformation I need to know what the FullForm is. If it (the
FullForm) varies from one command to another, how can I count on my
transformation working. For example, suppose a line in my Module
looks like this:
(1) "something"/.LessEqual[2,x,3] -> characteristic[x,2,3]

But if "something" contains the FullForm "Inequality[ ... ]" the
transformation explicit in (1) will fail.

I ran into this and found a simple work-around. However, it took me a
couple of hours to pinpoint the problem since it was imbedded in a
relatively long code.

Jack


Bob Hanlon

unread,
Jan 7, 2010, 2:33:21 AM1/7/10
to

Because while they are functionally equivalent they are only apparently identical. The output (how it displays) is the formatting of the underlying FullForm (i.e., how it is represented inside Mathematica). Two different FullForm expressions can have the same output formatting.

They are equivalent:

Reduce[LessEqual[2, x, 3]] ===
Inequality[2, LessEqual, x, LessEqual, 3]

True


Bob Hanlon

---- Jack L Goldberg 1 <jack...@umich.edu> wrote:

=============

Norbert Marxer

unread,
Jan 8, 2010, 4:12:37 AM1/8/10
to

Hello

I would use LogicalExpand with your expressions. Then your three
expressions will all have the same FullForm.

(*This gives False*)
e1 = LessEqual[2, x, 3]; e2 = Inequality[2, LessEqual, x, LessEqual,
3]; e3 = 2 <= x && x <= 3;
SameQ[e1, e2, e3]

(*This gives True*)
e1L = LogicalExpand[e1]; e2L = LogicalExpand[e2]; e3L = LogicalExpand
[e3];
SameQ[e1L, e2L, e3L]
SameQ[e1L // FullForm, e2L // FullForm, e3L // FullForm]

I hope this helps.

Best Regards
Norbert Marxer


0 new messages