Why XY + XZ + YZ can be simplified into XY + Z(X¬Y + ¬XY) in boolean algebra? - boolean

I not understand why the first boolean expression on the question can be simplified into the last. Please help me.

XY + Z(X ⊕ Y)
= XY + Z(X¬Y + ¬XY) // Expand XOR operation
= XY + X¬YZ + ¬XYZ // Distribute AND over OR
= XYZ + XY¬Z + X¬YZ + ¬XYZ // Expand XY
= (XYZ + XY¬Z) + (XYZ + X¬YZ) + (XYZ + ¬XYZ) // Copy XYZ and add parens
= XY + XZ + YZ // Remove trivial X+¬X = 1's
Reassembly is the reverse of disassembly.

Related

Any one can solve this: Simplify the boolean expression Z=A+A'B + A'B'C+ A'B'C'D

Any one can solve this:
Simplify the boolean expression
Z=A+A'B + A'B'C+ A'B'C'D
What will be the final answer of this question.
Z = A + A'B + A'B'C + A'B'C'D <br>
Z = A + A'(B + B'C + B'C'D) (distributivity)
Z = A + A'(B + B'(C + C'D)) (distributivity)
Z = A + A'(B + B'(C(D+1) + C'D)) (null law)
Z = A + A'(B + B'(CD + C + C'D)) (distributivity)
Z = A + A'(B + B'(C + D(C + C'))) (distributivity)
Z = A + A'(B + B'(C + D)) (inverse law)
Z = A + A'(B + C + D) (same 4 steps applied above)
Z = A + B + C + D (same as above)
So, whole expression actually can be solved with this rule:
A + A'B = A + B (absorption law)

Simplify the Boolean Expressions (x+y).(x+z)

Simplify the Boolean expression " (x+y).(x+z) " .
I think answer is " x+y.z " But i don't know how t get that.
You should use the De Morgan Law (A+B)=(A'.B'). It works this way:
(X+Y)=X'.Y' and (X+Z)=X'.Z'
By commutativity: (X+Y).(X+Z)=(X'.Y').(X'.Z')=X'.Y'.X'.Z'=X'.X'.Y'.Z'
By idempotence: X'.X'=X'
Then: X'.X'.Y'.Z'=X'.Y'.Z'=X'.(Y'.Z')
Calling: Y'.Z'=W
Then: X'.(Y'.Z')=X'.W'
By De Morgan: X'.W'=(X+W) (I)
Negating the affirmation: W'=Y'.Z' then W=(Y'.Z')'=Y'+Z'=Y.Z (II)
By (I) and (II): (X+Y).(X+Z)=X+(Y.Z)=X+Y.Z
(x+y)(x+z)
= xx + xz + yx + yz
= x + xz + yx + yz (since xx = x eg 0.0 = 0 , 1.1 = 1)
= x(1 + z + y) + yz
= x(1 + y) +yz (since 1 + z = 1 e.g 1+0 = 1 or 1+1 = 1)
= x(1) + yz (since 1 +y =1 as explained above)
= x + yz
(x+y)(x+z) -Distribute-> xx+xy+xz+yz -x.x=x-> x+xy+xz+yz -> x+x(y+z)+yz -x=x.1-> x.1+x(y+z)+yz -> x(1+(y+z))+yz -1+(y+z)=1-> x+yz
Here is a much simpler solution by using idempotent(xx = x) and absorption(x+xy = x) laws.
(x+y)(x+z) = xx+xz+xy+yz = x+yz

Boolean expression F = x'y + xyz':

Using DeMorgan's theorem show that:
a. (A + B)'(A' +B)' = 0
b. A + A'B + A'B' = 1
Boolean expression F = x'y + xyz':
Derive an algebraic expression for the complement F'
Show that F·F' = 0
Show that F + F' = 1
Please Help me
Assuming you know how DeMorgan's law works and you understand the basics of AND, OR, NOT operations:
1.a) (A + B)'(A' + B)' = A'B'(A')'B' = A'B'AB' = A'AB'B' = A'AB' = 0 B' = 0.
I used two facts here that hold for any boolean variable A:
AA' = 0 (when A = 0, A' = 1 and when A = 1, A' = 0 so (AA') has to be 0)
0A = 0 (0 AND anything has to be 0)
1.b) A + A'B + A'B' = A + A'(B + B') = A + A' = 1.
I used the following two facts that hold for any boolean variables A, B and C:
AB + AC = A(B + C) - just like you would do with numeric variables and multiplication and addition. Only here we work with boolean variables and AND (multiplication) and OR (addition) operations.
A + A' = 0 (when A = 0, A' = 0 and when A = 1, A' = 0 so (A + A') has to be 1)
2.a) Let's first derive the complement of F:
F' = (x'y + xyz')' = (x'y)'(xyz')' = (x + y')((xy)' + z) = (x + y')(x' + y' + z) = xx' + xy' + xz + x'y' + y'y' + y'z = 0 + xy' + xz + x'y' + y' + y'z = xy' + xz + y'(x + 1) + y'z = xy' + xz + y' + y'z = xy' + xz + y'(z + 1) = xy' + y' + xz = y'(x + 1) = xz + y'.
There is only one additional fact that I used here, that for any boolean variables A and B following holds:
A + AB = A(B + 1) = A - logically, variable A completely determines the output of such an expression and part AB cannot change the output of entire expression (you can check this one with truth tables if it's not clear, but boolean algebra should be enough to understand). And of course, for any boolean variable A + 1 = A.
2.b) FF' = (x'y + xyz')(xz + y') = x'yxz + x'yy' + xyz'xz + xyz'y'.
x'yxz = (xx')yz = 0xz = 0
xyy'= x0 = 0
xyz'xz = xxy(zz') = xy0 = 0
xyz'y' = xz'(yy') = xz'0 = 0
Therefore, FF' = 0.
2.c) F + F' = x'y + xyz' + xz + y'
This one is not so obvious. Let's start with two middle components and see what we can work out:
xyz' + xz = x(yz' + z) = x(yz' + z(y + y')) = x(yz' + yz + y'z) = x(y(z + z') + y'z) = x(y + y'z) = xy + xy'z.
I used the fact that we can write any boolean variable A in the following way:
A = A(B + B') = AB + AB' as (B + B') evaluates to 1 for any boolean variable B, so initial expression is not changed by AND-ing it together with such an expression.
Plugging this back in F + F' expression yields:
x'y + xy + xy'z + y' = y(x + x') + y'(xz + 1) = y + y' = 1.

Simplifying Boolean Expression x'yz + xy'z + xyz' + xyz

Hi I'v solved this halfway, please help me for the rest.
so far I've got..
x'yz + xy'z + xyz' + xyz
z(x'y + xy') + xy(z'+z)
z(x'y + xy') + xy
i don't understand how to solve the z(x'y + xy') part of this expression.. please somebody help..
x'y + xy' is XOR. So you can simplify to z(x+y) + xy because z(x'y + xy') + xy is z when x != y and xy when x == y.
The (x+y) after z is necessary to disallow influence of z when x == y == 0.

Solving equation slow

I have an equation (5th order Polynomial) and I have to solve it every time for different variables A,B and Coeff as written down. And the coefficient are quite alot (100000) I had no other way than using the for loop to do it but it is incredibely slow. Could anyone please give me a suggestion to make it faster or if there is another way to solve the equation faster.
This is my code:
tCounter = zeros(length(A),1);
NaNIndices = find(isnan(IntersectionPointsLayer(:,1))==1);
tCounter(NaNIndices) = NaN;
NotNaNIndices = find(isnan(IntersectionPointsLayer(:,1))==0);
for i = NotNaNIndices
syms t
Equation = -(Coeff(21).*((B(i,2) + t*A(i,2)).^5) + (Coeff(20).*((B(i,2) + t*A(i,2)).^4)).*(B(i,1) + t*A(i,1)) + Coeff(19).*((B(i,2) + t*A(i,2)).^4) + (Coeff(18).*((B(i,2) + t*A(i,2)).^3)).*((B(i,1) + t*A(i,1)).^2) + (Coeff(17).*((B(i,2) + t*A(i,2)).^3)).*(B(i,1) + t*A(i,1)) + Coeff(16).*((B(i,2) + t*A(i,2)).^3) + (Coeff(15).*((B(i,2) + t*A(i,2)).^2)).*((B(i,1) + t*A(i,1)).^3) + (Coeff(14).*((B(i,2) + t*A(i,2)).^2)).*((B(i,1) + t*A(i,1)).^2) + (Coeff(13).*((B(i,2) + t*A(i,2)).^2)).*(B(i,1) + t*A(i,1)) + Coeff(12).*((B(i,2) + t*A(i,2)).^2) + (Coeff(11).*((B(i,2) + t*A(i,2)))).*((B(i,1) + t*A(i,1)).^4) + (Coeff(10).*(B(i,2) + t*A(i,2))).*((B(i,1) + t*A(i,1)).^3) + (Coeff(9).*(B(i,2) + t*A(i,2))).*((B(i,1) + t*A(i,1)).^2) + (Coeff(8).*(B(i,2) + t*A(i,2))).*((B(i,1) + t*A(i,1))) + (Coeff(7).*(B(i,2) + t*A(i,2))) + Coeff(6).*((B(i,1) + t*A(i,1)).^5) + Coeff(5).*((B(i,1) + t*A(i,1)).^4) + Coeff(4).*((B(i,1) + t*A(i,1)).^3) + Coeff(3).*((B(i,1) + t*A(i,1)).^2) + Coeff(2).*(B(i,1) + t*A(i,1)) + Coeff(1)) + Thickness - (B(i,3) + t*A(i,3));
t = solve(Equation,t);
t = double (t);
t(imag(t) ~= 0) = [];
t(t<0) = [];
t = min(t);
tCounter(i) = t;
end
Many thanks in advance
Symbolic math is slow, I would suggest using the roots function instead (you are converting the result to double precision anyway).
To use that you need to compute the coefficients for the polynomial with respect to variable t (which requires some rearrangements for your formula), but this will be significantly faster.
I found the answer.
I had to solve the equation generally outside the loop and then use the loop to get for each instance.
It is still slow but not like before