booleans and plot statements (6.3.01)

Bruce M Hartley

I have a problem with a procedure which I want to plot.

Consider the following.

gives 1.0 OK 
gives 0.0 OK. 
gives an error message 
Error, (in PrPDPD) cannot evaluate boolean.

Can anyone tell me what is going wrong and how I can use a procedure containing boolean statements inside a plot command?

This is Maple release 5.5

Carl DeVore (7.3.01)

plot('PrPDPD(x)', x= 0..1.0);

Note that it is impossible to determine the truth of the expression x < Pi/4 if \(x\) does not have a numerical value.

Thus, we need to delay the evaluation of the expression PrPDPD(x) until the numerical values are assigned. That’s what the quotes do.

Your expression PrPDPD(x) already has a well-defined name in Maple, indeed in math in general. It is Heaviside(Pi/4 - x).

— It is curious that if I put an equal sign instead of a less ...

Yes, that can be very annoying feature. I wish that Maple would fail with an error message for that one too. Perhaps there is a way to make it fail that I don’t know about. When it doesn’t fail, I think this behavior leads to erroneous computations.

Anyway, here’s why it happens: Consider the expression "x = 3", where \(x\) is an undefined variable. Is an undefined variable the same thing as a number? Of course not. So are they equal? No. Then they must be not equal.

Here’s another way of looking at it: I give you two sentences, A and B:

A: "The symbol x is the same thing as the number three." 
B: "The symbol x is less than the number three."

The first sentence makes sense, and is clearly false. The second sentence is nonsense.

Adri van der Meer (8.3.01)

If you call plot(something,options) then the first thing that happens is that Maple evaluates the arguments "something" and "options".

Thus PrPDPD(x) is evaluated before the variable \(x\) is assigned a (numerical) value, and Maple cannot dicide if x > critical_value.

Now you can do two things:

(1) prevent Maple to evaluate PrPDPD(x) before x has a numerical value. Possibilities:

(2) Alter the procedure so that it can handle the case that x doesn’t have a numerical value:

Now plot(PrPDPD(x),x=0..1.0); results in the disired plot.

Symancyk, Daniel (8.3.01)

There are several things you can do to get what you want.

You can use single quotes to delay the evaluation of the if in your procedure.

You can use the name of your function along with the domain without the variable.

You can avoid having to use the single quotes in another way if you use the piecewise command in your proc.

will work.