I understand that
A+A`B=A+B
But what happens when
B
is replaced by
B`
on LHS?
The reason A + A'B is equivalent to A + B is because the A' is superfluous given the A + preceding it. If A' weren't already true then A would be so the A + would already make everything true. Anything could follow A' in the second part and the answer would be A + the rest. In your case, A + A'B' is equivalent to A + B'. We can verify with a truth table:
A B A' B' A'B' A + A'B' A + B'
T T F F F T T
T F F T F T T
F T T F F F F
F F T T T T T
Because A + A'B' and A + B' have the same values for all possible inputs, they are equivalent.
Related
This code make an operation on a and b and check if result is equal to c.
If yes, just print this row. My question is how to change this code to display
rows when result (a / b) = 0.
SELECT id, a, b, operation, c
FROM expressions
where
case
when operation LIKE '+' AND (a + b = c) then c
when operation LIKE '-' AND (a - b = c) then c
when operation like '/' AND (a / b = c) then c
when operation like '*' AND (a * b = c) then c
ELSE FALSE END;
Output:
id a b operation c
1 2 3 + 5
4 4 7 * 28
11 0 1 / 0
14 239 0 * 0
15 18 18 - 0
1, 2 rows are ok and printed. 3, 4, 5 rows should be printed but they are not!
When a / b = 0 then second condition in sql query is false - row is not printed, e.g. 0 / 1 = 0. It is 0 and should be printed. In contrart to 1 / 0 which shouldn`t be printed.
My solution is to cast (a / b = c) to unsigned but it is not working?
You shouldn't mix types like boolean and int because implicit conversion occurs.
Use explicit value instead of TRUE/FALSE (0 is treated as FALSE).
SELECT id, a, b, operation, c
FROM expressions
where
case
when operation LIKE '+' AND (a + b = c) then 1
when operation LIKE '-' AND (a - b = c) then 1
when operation like '/' AND (a / b = c) then 1
when operation like '*' AND (a * b = c) then 1
ELSE 0 END = 1;
alternatively:
SELECT id, a, b, operation, c
FROM expressions
where
case
when operation LIKE '+' AND (a + b = c) then TRUE
when operation LIKE '-' AND (a - b = c) then TRUE
when operation like '/' AND (a / b = c) then TRUE
when operation like '*' AND (a * b = c) then TRUE
ELSE FALSE END;
As already pointed out, the issue is that 0 is treated as false.
I would simplify the logic to:
SELECT id, a, b, operation, c
FROM expressions
WHERE (operation LIKE '+' AND (a + b = c) ) OR
(operation LIKE '-' AND (a - b = c) ) OR
(operation LIKE '/' AND (a / b = c) ) OR
(operation LIKE '*' AND (a * b = c) );
I don't think the CASE makes the code more understandable.
If you are concerned about divide-by-zero, then use nullif():
(operation LIKE '/' AND (a / nullif(b, 0) = c) ) OR
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.
F = ABC + AC + C'D'
is there a way to minimise this function even further because i want to make the circuit diagram with only 2 input nand gates
any suggestions ?
thanks
First, simplify:
F = ABC + AC + C'D'
F = AC(B + 1) + C'D'
F = AC + C'D'
Now, put in terms of ANDs and NOTs only:
F = (AC + C'D')'' [double negation]
F = ( (AC)'(C'D')' )' [DeMorgan's]
Then noting that:
NOT can be implemented via 2-input NAND by tying its inputs together.
AND can be implemented via 2-input NAND by combining NAND and NOT.
You should be able to implement F in this form directly using only 2-input NANDs.
This is the solution for the minimalization using a Karnaugh Table.
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.
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!