Project 3 Boolean Computation

Union and Intersection of Sets

 

Following through with the instructions from part one of the project, we first plot a region using the RegionPlot
command, and make the region opaque as we are later going to lay another region over it(Fig 1).  After that step is completed we want to plot another region in a different color that is extended over the same range as the first one. We have to make sure this new region is opaque as well.  Once this step is completed we can overlay the two together to form one region of two regions being overlapped using the show function. (Fig 2).



Figure 1

 

Figure 2

 

 

 

Next we are going to determine the area of each region by using the BOOLE value.

The Mathematica function Boole applied to a region takes the value 1 on that region, and takes the value 0 outside the region. As a result, integrating Boole[R] for a region R gives the area of R:

NIntegrate[Boole[1/4 <= x^2 + (2 y)^2 <= 1], {x, -1, 1}, {y, -1, 1}]

1.1781 (= area of A)

Similarly, the area of B is calculated as

NIntegrate[Boole[y > x], {x, -1, 1}, {y, -1, 1}]

2 (= area of B)

So with this in mind we want to calculate the areas of A\cup B and A\cap B.  I gave a visual representation in figures 3 and 4 as well as a numerical value following it.

 

Figure 3

 

 

Figure 4

 

So the area of A\cup B is 2.59  and the area of A\cap B is .59 .

 

Once these values were found we were asked to look at other similar examples where we could compare outcomes and for this situation I stuck to simple graphical presentations because they are easier to follow and comprehend.

 

 

 

 

 

 

Number 1.b)

 

 

 

In order to complete this program I first started by generating random numbers using the RandomInteger function in mathematica. I produced 10 different random integers from 1-30 in order to obtain a few different comparable sets of values. my findings are shown below.

 

 

So to prove the distributive property is correct I first made a three different sets of random numbers and then plugging these sets of values into the distributive property equation. The equation claims that if A is distributed through (B∪CC). If that’s true DD and EE should be the same, and since they are the distributive property does work.

 

Absorptive

 

 

 

The Absorptive Laws says that the intersection of a set to the union  and another set
should be the orignal set. The above test shows that sets A and FF are equal and that the
absorptive law does work.

 

Part 2.

 

In this part we start off looking at the difference between propositions and predicates. To me a predicate is just a statement, it cannot be proven to be either correct or incorrect . For example if we had a function like x>2   we cannot determine this statement to be true or false because we have  no idea what the value of x is or could be. A proposition on the other hand can be
evaluated or proven  to be true or false. On the other hand you can always modify the expression in order to make it a true or false. Using the resolve function in mathematica I show how this is true.

Resolve[ForAll[x,x>2]]

False

Resolve[Exists[x,x>2]]

True

 

Part 2 B.)

 

Background: For propositions the truth table for implication is false when, and only
when is true and is false. When are predicates with unbound variables, the situation is
more delicate.
For example, let where are variables ranging over
the set .
The implication is neither true nor false. There are specific values of for which
is true, and other values for which it is false.

RegionPlot command will make things alot easier.

 

p=x^2+y^2<1;

RegionPlot[p,{x,-1,1},{y,-1,1}]

 

p=x+y>0;

RegionPlot[p,{x,-1,1},{y,-1,1}]

 

 

Now by plotting the result of p implies q, we get a very good visual representation of what is happening.
As stated, the only place our output is false (or zero, unshaded, etc) is the area where p is TRUE, but q is
FALSE. This can also be seen by plotting the result of NOT p OR q. These two commands are boolean
equivalents!

 

RegionPlot[Implies[p, q], {x, -1, 1}, {y, -1, 1}]

 

RegionPlot[! p || q, {x, -1, 1}, {y, -1, 1}]

 

We can use a 3d plot to illustrate our point even better the true part of the function will be shaded while the false part or 0 will unshaded. 

 

 

 

Leave a comment