What does True mean in this Wolfram output?

Viewed 529

Here's a simple WolframCloud computation:

enter image description here

The answer is 1 when 0 < x < 1 is True and 0 when 0 < x < 1 is False, so why in the world does the output associate True with 0?

(In WolframAlpha, executing Limit[Boole[0<x<1] (1 + 1/a) ,a->Infinity] displays the correct answer, i.e., Boole[0<x<1], but the strange result is still found when you click "Open code".)

EDIT: An alternative form that gives the same result is

f[x_,a_]:=Boole[0<x<1] (1 + 1/a)
Limit[f[x,a],a->Infinity]

The output should be Boole[0<x<1], but instead is the strangeness involving True.

3 Answers

Seems that where is a bug in WolframAlpha sandbox - it probably can't deduce that your analyzed Boole[0 < x < 1] expression is independent of limit calculation and thus computes incorrectly. To get correct results - put Boole function in front of limit:

Boole[0 < x < 1] Limit[(1 + a^(-1)), a -> Infinity]

BTW, WolframAlpha online calculation shows answer correctly

Your expression makes little sense. It is not an equation and x is undefined. what are you trying to calculate?

Boole[expr]  (* yields 1 if expr is True and 0 if it is False. *)
Limit[expr,x->Subscript[x, 0]]  (* finds the limiting value of expr when x approaches Subscript[x, 0]. *)

Thus, Boole[0<x<1] will always yield 1 or 0 and is independent of a. However, Limit[1+1/a, a-> Infinity] is independent of x and will always yield 1.

Simplifying this expression you get n * 1 where n belong to [0,1], and is fully dependant on x.

My guess is that your input confuses the Mathematica, hence the weird output. btw. on Mathematica desktop the output is

Boole[0 < x < 1]

Showing that the value of the expression fully depends on the x as I described above..

Although at first it seems quite strange (or, indeed, a bug), in Wolfram language this is a standard usage of True in the output of piecewise functions, where it has the meaning of "otherwise" (when all the other listed conditions, which are to be evaluated in order, are False).

In other words, such an output expression is to be understood as a list of {value, condition} pairs, which evaluates to the first listed value whose condition is True, as in the following examples:

enter image description here

Related