Items tagged with boolean

Feed

Hi everyone,

Instead of writing:

a[1] < b[1] or (a[1] = b[1] and a[2] < b[2]) or (a[1] = b[1] and a[2] = b[2] and a[3] < b[3]) or (a[1] = b[1] and a[2] = b[2] and a[3] = b[3] and a[4] < b[4]) or (a[1] = b[1] and a[2] = b[2] and a[3] = b[3] and a[4] = b[4] and a[5] < b[5])...

Is there a more convenient way to do so? Plus, what if a[1] = b[1] and a[2] = b[2] and ... and a[99] = b[99] and a[100] < b[100]? I do not imagine writhing everything.

Thanks for your help. 

If input a group of outputs which are binary numbers

can it simplify to give a logic that can output these outputs

In Kitonums'answer of

http://www.mapleprimes.com/questions/220229-How-Do-I-Solve-A-Differential-Equation-In-Maple

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:

a1*x1+a2*x2+...+an*xn>=b1*y1+b2*y2+...+bn*yn

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.

Hello,

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
Irene

test_change.msim

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.

 

Hi,

 

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
...;
fi; 

 

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 http://www.mapleprimes.com/questions/149475-How-Do-I-Create-Combinations-According. I'm really stuck. Thank you for any help!

Program:

restart;

printlevel:=3:

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):

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

###########################
evalbb:=proc(PP)
if evalb(PP)='true' then eps:=1:
else eps:=0:
fi:
eps;
end:
###########################

but I think there should be...

Augh, this is hurting my brain.  This homework assignment (still the same one as before) is my first experience with Maple.  I'm trying to learn the semantics of the language as I go, and that's been going well for the most part, but there's this one thing that has been bugging me to absolutely NO END:  Logical operators.

Here's what I understand after a lot of internet searching and Help browsing:
-There's two sets of very similar operators. ...

1 2 Page 1 of 2