Can someone explain the simplification of this boolean algebra equation? - boolean

I think I missed reading a theorem or postulate or something..
The equation is: wy + wxz + xyz
According to my professor, the simplification is (which she didn't explain how):
wy + xz(w'y + wy')
= wy + xz (w XOR y)
Where did that (w'y + wy') came from??
I tried to calculate it but so far I only got: (w+x)(w+y)(w+z)(x+y)(y+z)

In a Boolean expression + is XOR and * is AND. This is the same as identifying true with 1 and false with 0, with the only special convention that 1 + 1 = 0 (or 2 = 0 if you wish.)
With these definitions both + and * are commutative, i.e., a + b = b + a and a * b = b * a. In addition, the distributive law is also valid a * (b + c) = a * b + a * c. Note also that the * operator is usually implicit in the sense that we write ab instead of a * b.
Applying these properties to the expression wy + wxz + xyz, there are some few obvious transformations you can do:
wy + wxz + yxz (commute x with y)
wy + (w + y)xz (prev plus distribute xz)
wy + xz(w + y) (prev plus commute (w + y) with xz
Note that the last one is wy + xz(w XOR y) because + is nothing but XOR.
ADDENDUM
Regarding the expression of your professor, let's recall that a' = 1 - a by definition. So
w'y + wy' = (1 - w)y + w(1 - y) - def
= y - wy + w - wy - distribute
= y + w - simplify (a + a = 0 always)
= w + y - commute
which shows that s/he was right.

Related

How to make the response of the solve function symbolic?

I am solving a fourth order equation in matlab using the solve function.My script looks like this:
syms m M I L Bp Bc g x
m = 0.127
M = 1.206
I = 0.001
L = 0.178
Bc = 5.4
Bp = 0.002
g = 9.8
eqn = ((m + M)*(I + m*L^2) - m^2*L^2)*x^4 + ((m + M)*Bp + (I + m*L^2)*Bc)*x^3 + ((m + M)*m*g*L + Bc*Bp)*x^2 + m*g*L*Bc*x == 0
S = solve(eqn, x)
In the answer, I should get 4 roots, but instead I get such strange expressions:
S =
0
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 1)
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 2)
root(z^3 + (34351166180215288*z^2)/7131724328013535 + (352922208800606144*z)/7131724328013535 + 1379250971773894912/7131724328013535, z, 3)
The first root, which is 0, is displayed clearly. Is it possible to make the other three roots appear as numbers as well? I looked for something about this in the documentation for the solve function, but did not find it.

Express an expression in terms of other expressions in MATLAB

Is there any way to express an expression in terms of other expressions in MATLAB?
For example, the following expressions have been written as sum (X + Y) and product (XY)
1/X + 1/Y = (X + Y)/XY
1/X^2 + 1/Y^2 + 2/(XY) = (X + Y)^2/(XY)
2*X/Y + 2*Y/X = 2*((X + Y)^2 - 2*X*Y)/(XY)
I know about the rewrite() function but I couldn't find how it can be used to do what I want?
There are a few different functions you can try to change the format of your symbolic expression:
collect: collects coefficients (can specify an expression to collect powers of):
>> collect(1/X + 1/Y)
ans =
(X + Y)/(Y*X)
simplify: perform algebraic simplification:
>> simplify(1/X^2 + 1/Y^2 + 2/(X*Y))
ans =
(X + Y)^2/(X^2*Y^2)
numden: convert to a rational form, with a numerator and denominator:
>> [n, d] = numden(2*X/Y + 2*Y/X)
n =
2*X^2 + 2*Y^2
d =
X*Y
>> n/d
ans =
(2*X^2 + 2*Y^2)/(X*Y)

Simplifying following Boolean Expression and verify using Karnaugh Map

I'm having trouble simplifying these two boolean expressions algebraically and proving them with a Karnaugh Map. How can I do this?
These are my two expressions:
1) (X * Y) + (X' * Y * Z')+ (Y * Z)
2) (X * Y') + Z + (X' + Y)+ (Y * Z)
I've tried going through it using the boolean theorems and laws to reduce them but I always come up with different answers. My answers usually comes up as this.
1) (Y * Z') + (X' * Y)
2) (X' * Y') + (X * Y' * Z')
I don't know if my K-Map is wrong, but I do need someone to help me understand how to solve this problem and the steps or laws I need to get the answer, so that I can master it. It is practice for exam, and I suck at boolean algebra. I appreciate it.
Let's start with the first expression:
E = XY + X'YZ' + YZ
The three terms have Y, then we can factor it out
E = Y(X + X'Z' + Z)
Now let's concentrate in the expression in parenthesis S = X + X'Z' + Z:
S = X + X'Z' + Z
= X + (X + Z)' + Z (De Morgan)
= (X + Z) + (X + Z)' (regrouping)
so, despite the fact that this still looks complex it has the form
S = p + p'
for p = X + Z, right? But p + p' = 1 (or true) no matter the value of p. Thus the expression S is 1 and we get
E = Y(X + X'Z' + Z) = YS = Y1 = Y
In other words, the first expression reduces to Y.
Notice also that it is not that hard to see why S = 1 without rewriting it. There are three cases: (a) If X is true, then certainly the expression is true. (b) If Z is true, the result is true also. (c) If none of X and Z are true then both are false and X'Z' is true. So, in each of these 3 cases at least one of the terms is true, hence their sum.
Let's now consider the second expression
F = XY' + Z + (X' + Y) + YZ
The first thing to note is that XY' is the opposite of (X' + Y):
(X' + Y) = (XY')' (De Morgan)
So,
F = XY' + (XY')' + Z + YZ
Again, regardless of the fact that XY' + (XY')' looks complicated, it is an expression of the form p + p'. But p + p' = 1 (it is always true) and therefore
F = 1 + Z + YZ = 1
no matter the values of Y and Z. So, the second expression is nothing but 1 (aka true).

Rewrite a symbolic expression in terms of a specific subexpression

I need to rewrite a symbolic expression in terms of a specific subexpression.
Consider the following scenario:
expression f with 2 variables a, b
subexpression c = a / b
syms a b c
f = b / (a + b) % = 1 / (1 + a/b) = 1 / (1 + c) <- what I need
Is there a way to achieve this?
Edit:
The step from 1 / (1 + a/b) to 1 / (1 + c) can be achieved by calling
subs(1 / (1 + a/b),a/b,c)
So a better formulated question is:
Is there a way to tell MATLAB to 'simplify' b / (a + b) into 1 / (1 + a/b)?
Just calling simplify(b / (a + b) makes no difference.
Simplification to your desired form is not automatically guaranteed, and in my experience, isn't likely to be achieved directly through simplify-ing as I've noticed simplification rules prefer rational polynomial functions. However,
if you know the proper reducing ratio, you can substitute and simplify
>> syms a b c
>> f = b / (a + b);
>> simplify(subs(f,a,c*b))
ans =
1/(c + 1)
>> simplify(subs(f,b,a/c))
ans =
1/(c + 1)
And then re-substitute without simplification, if desired:
>> subs(simplify(subs(f,a,c*b)),c,a/b)
ans =
1/(a/b + 1)
>> subs(simplify(subs(f,b,a/c)),c,a/b)
ans =
1/(a/b + 1)

Solve finds wrong solution?

I have this equation in x and y:
(x + y)^(1/2) - 6*y*(x + y)^5 - (x + y)^6 + (x - 1)/(2*(x + y)^(1/2)) = 0.
Now I call the solver:
R_c = #(y)solve((x + y)^(1/2) - 6*y*(x + y)^5 - (x + y)^6 + (x - 1)/(2*(x + y)^(1/2)), x, 'Real', true);
which gives me the implicit solutions as a function of y. Now try
R_c(.3)
to find the explicit solution at y = 0.3. MATLAB's answer is:
ans =
0.42846617518653978966562924618638
0.15249587894102346284238111155954
0.12068186494007759990714181154349
However, the last entry in this array is NOT a solution. Test:
double(subs(subs((x + y)^(1/2) - 6*y*(x + y)^5 - (x + y)^6 + (x - 1)/(2*(x + y)^(1/2)), x, .12068186494007759990714181154349), y, .3))
yields
-0.0585.
This is not a rounding error. The other 2 solutions work perfectly and solve the equation correctly. I wonder where MATLAB the third value gets from. Can anyone help?