Skip to main content
added 51 characters in body
Source Link
hana
  • 2.6k
  • 6
  • 19

(Please see the edit part for the real problem)

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

EDIT: Basically I have a list like this.

list = {ConditionalExpression[Plus[1, Times[-1, x]], 
   Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]], 
  ConditionalExpression[Plus[1, Times[-1, x]], LessEqual[1, x, 2]], 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]]}

enter image description here

I want to return the position of elements in the list that same as reffunc as follows:

reffunc = 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]];
Position[list, reffunc]

I expected the positions of the first and third are returned but only the third is returned.

enter image description here

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

EDIT: Basically I have a list like this.

list = {ConditionalExpression[Plus[1, Times[-1, x]], 
   Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]], 
  ConditionalExpression[Plus[1, Times[-1, x]], LessEqual[1, x, 2]], 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]]}

enter image description here

I want to return the position of elements in the list that same as reffunc as follows:

reffunc = 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]];
Position[list, reffunc]

I expected the positions of the first and third are returned but only the third is returned.

enter image description here

(Please see the edit part for the real problem)

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

EDIT: Basically I have a list like this.

list = {ConditionalExpression[Plus[1, Times[-1, x]], 
   Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]], 
  ConditionalExpression[Plus[1, Times[-1, x]], LessEqual[1, x, 2]], 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]]}

enter image description here

I want to return the position of elements in the list that same as reffunc as follows:

reffunc = 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]];
Position[list, reffunc]

I expected the positions of the first and third are returned but only the third is returned.

enter image description here

added 844 characters in body
Source Link
hana
  • 2.6k
  • 6
  • 19

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

EDIT: Basically I have a list like this.

list = {ConditionalExpression[Plus[1, Times[-1, x]], 
   Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]], 
  ConditionalExpression[Plus[1, Times[-1, x]], LessEqual[1, x, 2]], 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]]}

enter image description here

I want to return the position of elements in the list that same as reffunc as follows:

reffunc = 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]];
Position[list, reffunc]

I expected the positions of the first and third are returned but only the third is returned.

enter image description here

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.

EDIT: Basically I have a list like this.

list = {ConditionalExpression[Plus[1, Times[-1, x]], 
   Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]], 
  ConditionalExpression[Plus[1, Times[-1, x]], LessEqual[1, x, 2]], 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]]}

enter image description here

I want to return the position of elements in the list that same as reffunc as follows:

reffunc = 
  ConditionalExpression[Plus[1, Times[-1, x]], 
   LessEqual[0, x, Rational[1, 2]]];
Position[list, reffunc]

I expected the positions of the first and third are returned but only the third is returned.

enter image description here

Source Link
hana
  • 2.6k
  • 6
  • 19

How to make function return True if two functions and domains are same?

I have two expressions which are same but written in different ways.

expr1 = ConditionalExpression[Plus[1, Times[-1, x]], 
  Inequality[0, LessEqual, x, LessEqual, Rational[1, 2]]]

enter image description here

expr2 = ConditionalExpression[Plus[1, Times[-1, x]], 
  LessEqual[0, x, Rational[1, 2]]]

enter image description here

Now if I use Equal function:

expr1 == expr2

enter image description here

It returns True together with domains combining of the two functions. However, I want it to return True only (no domain) if the functions are same and domains are same as well. How can I do that?
SameQ doesn't work here as they are same mathematically but the underlying representations are different.