How do i simplify f = x'yz + xy'z + xyz'? - boolean-logic

I am working on simplifying the expression f = x'yz + xy'z + xyz' + xyz. Actually, it may not be this expression. The question is: simplify the boolean expression for a voting system, the system being: three people vote on multiple candidates, and two or more people should agree(true) on the candidate in order to pass. So I think the answer would be xy + yz + xz, but I can't figure out the process between. Can anyone explain?

From the idempotent/identity law, we have x + x = x, and so xyz + xyz = xyz. Applying this principle, we can rewrite your expression as:
f = x'yz + xy'z + xyz' + xyz
=> f = x'yz + xy'z + xyz' + xyz + xyz + xyz --OR with xyz twice without affecting the value
=> f = x'yz + xyz + xy'z + xyz + xyz' + xyz --Rearrange
=> f = yz (x + x') + xz (y + y') + xy(z' + z) --Group
=> f = yz + xz + xy --Since x+x' = 1
That said, as the diagram clearly shows, you can simply take AND together each pair of inputs, and OR them together to get the same result. By doing this, you ensure that:
If any 2 of the 3 inputs are true, your overall result is true
When all 3 are true, the result is still true
The advantage of expressing it in this way is that you can just focus on each pair of inputs at one time, without worrying about the impact of the third one.

A simple way without involved logical reasoning
Write a truth table. For three inputs, there are 2^3 = 8 rows.
Four rows correspond to the given terms in your sum-of-products expression.
Enter the eight values of your expression into a Karnaugh map:
Group adjacent 1-terms to blocks as shown.
A pair of cells can be merged into a bigger block, if they just differ in one input. This way, the blocks double their cell-count and reduce their input-count by one in every merge step.
Each of the resulting blocks corresponds to one implicant term in the minimized expression.
Drawing the map and finding the blocks can be done automatically using a nice online tool of Marburg University.

Related

Boolean Algebra with Max terms

I want to simplify the following expression:
F = (A+B+C)(A+B'+C)(A'+B+C)
I have simplified it accordingly.
F = (A+B+C)(A+B'+C)(A'+B+C)
F = (A+C)(A'+B+C)
F = AA' + AB + AC + A'C + BC + C
F = AB + C(A + A' + B + 1) = AB + C
However, the correct answer is (A+C)(B+C).
Where in my "current" proof am I going wrong? I have seen the solution, but I want to know why my current approach is wrong.
Nothing wrong - it's just two different ways of expressing the same thing.
If the goal is minimization I would argue that your solution is "better" since it only references each term once.
Wolfram Alpha is your friend in cases like this.

Maxima - Substitutions in Equations - let() and letsimp() without effect

My own equation is a bit longer, but the following example shows perfectly where I struggle at the moment.
So far I have been using the let() and letsimp() function
to substitute longer terms in an equation,
but in this example they have no effect:
(%i1) eq: ((2*u+a^2+d) * y+x)/2*a = x;
2
a ((2 u + d + a ) y + x)
(%o1) ------------------------ = x
2
(%i2) let(2*u+a^2+d, %beta);
2
(%o2) 2 u + d + a --> %beta
(%i3) letsimp(eq);
2
a ((2 u + d + a ) y + x)
(%o3) ------------------------ = x
2
What is the preferred way to replace 2*u+a^2+d with %beta in this sample equation?
And why has letsimp() no effect?
Thank you very much!
letsimp applies only to "*" expressions. You could try subst.

Mathcad 14: "pattern match exception" when solving equation with more unknowns

I'm trying to solve an equation with 5 unknowns in Mathcad 14. My equations look like this:
Given
0 = e
1 = d
0 = c
-1 = 81a + 27b + 9c + 3d + e
0 = 108a + 27b + 6c + d
Find(a,b,c,d,e)
Find(a,b,c,d,e) is marked as red and says "pattern match exception". What is the problem?
In mathcad you need to do something similar to:
c:=0
d:=1
e:=0
a:=1
b:=1
Given
81*a + 27*b + 9*c + 3*d + e = -1
108*a + 27*b + 6*c + d = 0
Find(a,b,c,d,e) = (0,0,0,0,-1)
Now, what I have done here is to define the variables BEFORE the Solve Block (Given...Find), you have to give initial values which you think are close to the solution you require in order for the iteration to succeed.
Tips: To get the equals sign in the Solve Block, use ctrl and '='. If your looking to solve for 5 unknowns then you need 5 equations, the original post looked like you knew 3 of the variables and were looking for a and b, in this case you would do the following:
c:=0
d:=1
e:=0
a:=1
b:=1
Given
81*a + 27*b + 9*c + 3*d + e = -1
108*a + 27*b + 6*c + d = 0
Find(a,b) = (0.111,-0.481)
This has held c, d and e to their original values and iterated to solve for a and b only.
Hope this helps.

f(n), understanding the equation

I've been tasked with writing MIPS instruction code for the following formula:
f(n) = 3 f(n-1) + 2 f(n-2)
f(0) = 1
f(1) = 1
I'm having issues understanding what the formula actually means.
From what I understand we are passing an int n to the doubly recursive program.
So for f(0) the for would the equation be:
f(n)=3*1(n-1) + 2*(n-2)
If n=10 the equation would be:
f(10)=3*1(10-1) + 2*(10-2)
I know I'm not getting this right at all because it wouldn't be recursive. Any light you could shed on what the equation actually means would be great. I should be able to write the MIPS code once I understand the equation.
I think it's a difference equation.
You're given two starting values:
f(0) = 1
f(1) = 1
f(n) = 3*f(n-1) + 2*f(n-2)
So now you can keep going like this:
f(2) = 3*f(1) + 2*f(0) = 3 + 2 = 5
f(3) = 3*f(2) + 2*f(1) = 15 + 2 = 17
So your recursive method would look like this (I'll write Java-like notation):
public int f(n) {
if (n == 0) {
return 1;
} else if (n == 1) {
return 1;
} else {
return 3*f(n-1) + 2*f(n-2); // see? the recursion happens here.
}
}
You have two base cases:
f(0) = 1
f(1) = 1
Anything else uses the recursive formula. For example, let's calculate f(4). It's not one of the base cases, so we must use the full equation. Plugging in n=4 we get:
f(4) = 3 f(4-1) + 2 f(4-2) = 3 f(3) + 2 f(2)
Hm, not done yet. To calculate f(4) we need to know what f(3) and f(2) are. Neither of those are base cases, so we've got to do some recursive calculations. All right...
f(3) = 3 f(3-1) + 2 f(3-2) = 3 f(2) + 2 f(1)
f(2) = 3 f(2-1) + 2 f(2-2) = 3 f(1) + 2 f(0)
There we go! We've reached bottom. f(2) is defined in terms of f(1) and f(0), and we know what those two values are. We were given those, so we don't need to do any more recursive calculations.
f(2) = 3 f(1) + 2 f(0) = 3×1 + 2×1 = 5
Now that we know what f(2) is, we can unwind our recursive chain and solve f(3).
f(3) = 3 f(2) + 2 f(1) = 3×5 + 2×1 = 17
And finally, we unwind one more time and solve f(4).
f(4) = 3 f(3) + 2 f(2) = 3×17 + 2×5 = 61
No, I think you're right and it is recursive. It seems to be a variation of the Fibonacci Sequence, a classic recursive problem
Remember, a recursive algorithm has 2 parts:
The base case
The recursive call
The base case specifies the point at which you cannot recurse anymore. For example, if you are sorting recursively, the base case is a list of length 1 (since a single item is trivially sorted).
So (assuming n is not negative), you have 2 base cases: n = 0 and n = 1. If your function receives an n value equal to 0 or 1, then it doesn't make sense to recurse anymore
With that in mind, your code should look something like this:
function f(int n):
#check for base case
#if not the base case, perform recursion
So let's use Fibonacci as an example.
In a Fibonacci sequence, each number is the sum of the 2 numbers before it. So, given the sequence 1, 2 the next number is obviously 1 + 2 = 3 and the number after that is 2 + 3 = 5, 3 + 5 = 8 and so on. Put generically, the nth Fibonacci number is the (n - 1)th Fibonacci Number plus the (n - 2)th Fibonacci Number, or f(n) = f(n - 1) + f(n - 2)
But where does the sequence start? This is were the base case comes in. Fibonacci defined his sequence as starting from 1, 1. This means that for our pruposes, f(0) = f(1) = 1. So...
function fibonacci(int n):
if n == 0 or n == 1:
#for any n less than 2
return 1
elif n >= 2:
#for any n 2 or greater
return fibonacci(n-1) + fibonacci(n-2)
else:
#this must n < 0
#throw some error
Note that one of the reasons Fibonacci is taught along with recursion is because it shows that sometimes recursion is a bad idea. I won't get into it here but for large n this recursive approach is very inefficient. The alternative is to have 2 global variables, n1 and n2 such that...
n1 = 1
n2 = 1
print n1
print n2
loop:
n = n1 + n2
n2 = n1
n1 = n
print n
will print the sequence.

Boolean Logic Design - Reduction

I have the following function to be reduced/simplified.
F(A,B,C,D) = BC + (A + C'D') where ' denotes the complement
Here's my solution:
= BC + (A + C'D')'
= BC + (A + (C+D)
= BC + (A + C + D)
= BC + C + A + D
= C(B + 1) + A + D
= C*1 + A + D
= C + A + D
Is this correct?
As in traditional algebra, if you do something to one side of the equation, you must do it to the other side, including complementing. Here we state the original equation:
F'(A,B,C,D) = BC + (A + (CD)')
Since we have F' instead of F, my intuition tells me to complement both sides, but first I distribute the complement in the term (CD)' to make life easier in the long run:
F' = BC + (A + (C'+ D'))
Now we can complement both sides of the equation:
1: F = '(BC)'(A + (C'+ D')) The OR becomes AND after distributing complement
Now let's distribute the complements inside just to see what we get:
2: F = (B'+ C')(A'(CD))
Now we can just distribute the right term (A'(CD)) over the two terms being OR'ed:
3: F = B' (A'(CD)) + C' (A'(CD))
We see that the right term goes away since we have a CC' and thus we are left with:
4: F = A'B'CD
Hopefully I didn't make a mistake. I know you've found the answer, but others reading this might have a similar question and so I did it out to save duplicate questions from being asked. Good Luck!