Items tagged with boolean

In Kitonums'answer of

I read a code of remove(t->t=".", b);
t->t="." is a Boolean-valued procedure.

But, then, why does (t->t=".")(9); not return false like (t->t^2)(3); returns 9?
How can I have maple return false?

Thanks in advance.

Lets say we have to vectors u := Vector(3,[0,a_2,a_3]) and v :=Vector(3,[a_1,a_2,a_3]), in which a_1, a_2 and a_3 are arbitrary constants. It is clear that if we set a_1=0 we could see that u is contained in the vector space of v. Is there a function in Maple like isSubspace(u,v) which returns a boolean true or false?

An alternative interpretation could be that the image of u is a subset of the image of v.

Thank you alot for reading my question. 


I know how to use Maple for an optimization problem contaning continous variables but I couldn't find anything in help of Maple related to use boolean variables in optimization. So assume I want to minimize a function that one of its variables only can take 0 and 1 as its value. Anyone knows how to introduce those to the Maple? For example you can look at this link that Matlab can do many of these kind of optimizations.

Hi everyone,

Can anybody help me to write a programme in maple? I want to do a loop that iterate from an integer from 0 to N where I want to write a prodedure, say, MEC(N). Then I want to organise the output into a list of three lists  [[min points],[escape],[capture]], which, if correct, should include all integers from 0 to N exactly once.

> MEC := proc (N)
local IsEmpty, Escape, escape, capture, minpoints, Capture, z, MinPts, ic;
IsEmpty := array(0 .. 2*N);
Escape := array(0 .. 2*N);
Capture := array(0 .. 2*N);
MinPts := array(0 .. N);
IsEmpty := true;
Escape := true;
Capture := true;
MinPts := true;

for ic from 0 to N do
if IsEmpty then
z := ic;
MinPts[ic] := true;
z := ic;
while z <= 2*N and F(z) <= 2*N do
z := F(z);
IsEmpty[z] := true;
Escape[z] := true
end do;

z := ic;
while z <= 2*N and Finv(z) <= 2*N do
z := Finv(z);
IsEmpty[z] := true;
Capture[z] := true end do fi;
end do;
return [MinPts(z), Escape(z), Capture(z)]
end proc;

There are two operations involved in the program which is the function F and F inverse called Finv. 
i need to produce the output which contain the list of integers exactly once.

I could not figure out which logical expression that I do wrong.

Thank you for your help!

Hi all,

I have some "boolean variable" constraint equation like this:


where a1,a2,...,an and b1, b2, ..., bn are 1 or -1

These equations will be used in LPSolve or the other command to find a group of parameters which can fit them.

Now I used for-loop to deal with this kind of question, for example:

But there are more than 10 boolean variables in my case and It's very inefficient. On the other hand, using for-loop to determine the equation we solve in the command will lead to great confusion.

I think there should be some ways able to solve this kind of "boolean variables" question in Maple, such as, through assume command to define the type of "boolean variable".

But I have no idea how to do it.


I am quite new on Maple and Maplesim. A co-worker and I are evaluating a demo version (Maple 18 with Maplesim 7) for a possible purchase in 2015. For the project my collegue and I are working on, we need to detect when a signal becomes zero in order to switch between two options. We were trying to do this using the "Change" or "Boolean Change" components (the difference between those two is not really clear to us). Correct me if I am wrong, but those components should detect when a boolean signal has a change in value (both rising or decreasing) and in that case the output should become TRUE, while otherwise is FALSE.

The problem is that the component work if a "Terminate" is connected, but the output is always FALSE in any other case.

At the bottom we are attaching a file with two very easy examples.

In the first one the input of the "Boolean Change" component is a "Boolean Pulse". We compared also the output of the "Change", "Rising Edge", and "Edge with Initial Value" components. We were expecting istantaneous pulse with frequency equal to that of the boolean pulse, or its half for the Edge block. On the contrary the output of all the components stays zero (thus FALSE) for the whole simulation.

The second example use the output of a "Greater Threshold" component to enter the "Boolean Change", whose output is used to trigger a "Switch", whose output is in turn used as an input for the "Greater Threshold" component. The expected result is to have the "Switch" output to alternate the two inputs, instead it keeps the second one (thus the input for the switch is always FALSE).
The feature we need is more similar to this second output, but we don't understand what we are doing wrong or if there is another way to do it.
Thank you in advance


Maple has a powerful package for manipulation with logical expressions (Logic package). But it lacks for transfomation a boolean expression to algebraic normal form (ANF). In fact, this transfomation is very simple and implements by applying simple rules

to disjunctive normal form.

I suppose that this can be reached by introducing some custom operators and transfomations, if it is possible in Maple.




so we have to Write a maple function with -> that takes an integer N and a boolean function

F: {(i,j) l 0<= i,j<= N} -> {true,false} 

and returns a list containing all [i,j] such that F(i,j). A procedure that does this
would be

proc(N,F) local i, j, RV;
for i from 1 to N do for j from 1 to N do
if F(i,j) then RV:=RV,[i,j] ; end if ;
end do ; end do ;
return RV ;
end proc ;

The problem is to do this inline, i.e. you have to write
(i,j)-> ...


please help...



Another (hopefully) simple question that I can't work out the answer for. How can I write an if loop for which n things must be true? I need to have:

if thing[1]=true and thing[2]=true and thing[3]=true and ... and thing[n]= true then


n will change for different inputs, so I can't write out explicitly.

Hope that makes sense! Thanks.

What's wrong with my loop? It works fine if no_legs is set to 3, but when it is set to 2 or 4 it doesn't work (as in the picture). The code is to list combinations, as in I'm really stuck. Thank you for any help!




for a from 3 to 30 do

   for b from 23 to 30 do

       for k from b to 30 do

         for d from 4 to 30 do

            for e from 10 to 30 do

  big:=max(sqrt(a^2+b^2), sqrt(k^2+d^2), b+k,e,d+e-a):

  small:=min(sqrt(a^2+b^2), sqrt(k^2+d^2), b+k,e,d+e-a):

Hi all,

I want to compare two signals where intersections between the two signals represent the instant of command (like boolean pulse) of a thyristor. The two signals are volatges and command of thyristor is boolean. A conversion of voltage to boolean signal should also done, I think ?

Thanks in advance

See image below.

I am looking for an implementation of the Mathematica equivalent of RegionPlot whose description should be like:

RegionPlot(pred,x=x_min..x_max, y=y_min..y_max) makes a plot showing the region in which pred is True.

For example, I would like to execute:

> RegionPlot(f(x,y) > 0 and g(x,y), x=x_min..x_max, y=y_min..y_max)

where g(x,y) outputs True/False.

One idea I had was to use:

> densityplot(`if`(pred,1,0...

In Maple boolean evaluation returns the values 'true' or 'false'.

Is there any canonical way of getting evalb to produce values in {0,1}? This is of some use when testing conjectures on  hudge lists of items...

Of course: you can always define a script like

if evalb(PP)='true' then eps:=1:
else eps:=0:

but I think there should be...

I am trying to construct a 7x7 matrix T such that T[i,j]=k, when multiply(monoid[i],monoid[j])=monoid[k]

I've defined monoid to be a boolean matrix such that there is at least one 1 in each row and column.

I am just not sure how to get my input to return the matrix. I keep getting a 7x7 zero matrix.

This is what I have:

T[i,j]:= Matrix(7);for i to 7  

do for j from 1 by 1 to 7    

do T[i,j]:=(multiply(monoid[i...

1 2 Page 1 of 2