Skip to main content
added 541 characters in body
Source Link
Henrik Schumacher
  • 109.4k
  • 7
  • 186
  • 322

At 1).: Maybe, this would be referred to as "Boolean expression" in Mathematica speech.

At 2.:) SameQ is problematic as it does not respect the logical content:

hamlet = Or[be, Not[be]];
a = SameQ[hamlet, True]
b= Equivalent[hamlet, True]

False

be || ! be

So using these in later computions may lead to wrong results:

Simplify[a]
Simplify[b]

False

True

The TrueQ/Equal combo is similarly dangerous as TrueQ will return False whenever it gets a symbolic expression as arguments that does not evaluate immediately to True. Better not use it here.

Moreover, Equivalent may be able to perform some simplifications that Equal cannot perform because using Equivalent implies that its arguments are Boolean expressions.

3.) Some more simplifications are performed by TautologyQ:

TautologyQ[Equivalent[hamlet, True]]

True

4.) In life, there is usually never one best way to do anything. For example,SameQ is a very inexpensive test and if it evaluates to True, you are done. Equivalent and TautologyQ have to perform actual computations, taking a bit longer.

At 1.: Maybe, this would be referred to as "Boolean expression" in Mathematica speech.

At 2.: SameQ is problematic as it does not respect the logical content:

hamlet = Or[be, Not[be]];
a = SameQ[hamlet, True]
b= Equivalent[hamlet, True]

False

be || ! be

So using these in later computions may lead to wrong results:

Simplify[a]
Simplify[b]

False

True

1). Maybe, this would be referred to as "Boolean expression" in Mathematica speech.

2.) SameQ is problematic as it does not respect the logical content:

hamlet = Or[be, Not[be]];
a = SameQ[hamlet, True]
b= Equivalent[hamlet, True]

False

be || ! be

So using these in later computions may lead to wrong results:

Simplify[a]
Simplify[b]

False

True

The TrueQ/Equal combo is similarly dangerous as TrueQ will return False whenever it gets a symbolic expression as arguments that does not evaluate immediately to True. Better not use it here.

Moreover, Equivalent may be able to perform some simplifications that Equal cannot perform because using Equivalent implies that its arguments are Boolean expressions.

3.) Some more simplifications are performed by TautologyQ:

TautologyQ[Equivalent[hamlet, True]]

True

4.) In life, there is usually never one best way to do anything. For example,SameQ is a very inexpensive test and if it evaluates to True, you are done. Equivalent and TautologyQ have to perform actual computations, taking a bit longer.

Source Link
Henrik Schumacher
  • 109.4k
  • 7
  • 186
  • 322

At 1.: Maybe, this would be referred to as "Boolean expression" in Mathematica speech.

At 2.: SameQ is problematic as it does not respect the logical content:

hamlet = Or[be, Not[be]];
a = SameQ[hamlet, True]
b= Equivalent[hamlet, True]

False

be || ! be

So using these in later computions may lead to wrong results:

Simplify[a]
Simplify[b]

False

True