please help me with simplifying this one. I am a bit new to these..
(A'BC') + (A'B'C) + (A'BC) + (AB'C)
the book i use shows and answer, which is,
Answer = A'B + B'C
I tried simplifying, but I get stucked with two eXors, my simplification so far goes like this...
(A'BC') + (A'B'C) + (A'BC) + (AB'C)
A (BC' + B'C) + C (A'B + AB')
This doesn't seem to be a write way, Please someone help me simplify this, and please show step by step, as I am sort of new..
Also I don't get how to simplify eXor further..
You have the Rule X' + X = True. SO
(A'BC') + (A'B'C) + (A'BC) + (AB'C) =
(A'BC') + (A'BC) + (A'B'C) + (AB'C) = // just permuting the terms
A'B(C' + C) + (A' + A)B'C = // factoring
A'B + B'C
I'll assume that multiplcation is AND, addition is OR and prime is negation.
Here's what I'd do:
(A'BC') + (A'B'C) + (A'BC) + (AB'C)
A'B(C'+C) + B'C(A'+A)
(C'+C) = 1 and (A'+A) = 1
A'B + B'C
Q.E.D.
for simplifying boolean expressions use karnaugh maps. i think it is very much useful if we less number of variables. but if we have more variables then we can follow methods because this method is not that preferable.
(A'BC') + (A'B'C) + (A'BC) + (AB'C)
answer just arrange the terms like this
step 1:A'BC'+A'BC+AB'C+A'B'C
now get common terms out
step 2 : A'B(C'+C)+B'C(A+A')
step 3 : A'B.1+B'C.1
step 4 : A'B+B'C
Related
I'm trying to find a fit with a custom equation, but I keep getting errors and don't know why. The custom equation is really big. I'm using what I found here.
This is the code (sorry about the length of the custom equation):
myfittype = fittype('a + (b*2*y) + (c*2*x+dsqrt(6)(2*xy)) + (esqrt(3)*(2*x^2+2*y^2-1)) + (fsqrt(6)(x^2-y^2)) + (gsqrt(8)(3*x^2*y-y^3)) + (hsqrt(8)(3*x^2*y+3*y^3-2*y)) + (ipsqrt(8)(x^3+3*x*y^2-2*x)) + (jpsqrt(8)(x^3-3*xy^2)) + (ksqrt(10)*(4*x^3*y-4*xy^3)+lsqrt(10)*(8*x^3*y+8*x*y^3-6*xy)) + (msqrt(5)*(6*x^4+12*x^2*y^2+6*y^4-6*x^2-6*y^2+1)) + (nsqrt(10)(4*x^4+4*x^2*y^2-3*x^2-4*x^2*y^2-4*y^4+3*y^2)) + (osqrt(10)(x^4-6*x^2*y^2+y^4)) + (psqrt(12)(5*x^4*y-10*x^2*y^3+y^5)) + (qsqrt(12)(15*x^4*y-12*x^2*y-5*y^5+4*y^3+10*x^2*y^3)) + (rsqrt(12)(10*x^4*y+20*x^2*y^3+10*y^5-12*x^2*y-12*y^3+3*y)) + (ssqrt(12)(10*x^5+20*x^3*y^2+10*x*y^4-12*x^3-12*x*y^2+3*x)) + (tsqrt(12)(5*x^5-10*x^3*y^2-4*x^3-15*x*y^4+12*xy^2)) + (usqrt(12)*(x^5-10*x^3*y^2+5*x*y^4))',... 'independent',{'x'},'dependent',{'y'},...
'coefficients',{'a','b','c','d','e','f','g','h','ip','jp','k','l','m','n','o','p','q','r','s','t','u'})
Here is the code formatted with line breaks (...) so that you can read it:
myfittype = fittype('a + (b*2*y) + (c*2*x+d*sqrt(6)*(2*x*y)) + ...
(e*sqrt(3)*(2*x^2+2*y^2-1)) + (f*sqrt(6)*(x^2-y^2)) + ...
(g*sqrt(8)*(3*x^2*y-y^3)) + (h*sqrt(8)*(3*x^2*y+3*y^3-2*y)) + ...
(ip*sqrt(8)*(x^3+3*x*y^2-2*x)) + (jp*sqrt(8)*(x^3-3*x*y^2)) + ...
(k*sqrt(10)*(4*x^3*y-4*x*y^3)+l*sqrt(10)*(8*x^3*y+8*x*y^3-6*x*y)) + ...
(m*sqrt(5)*(6*x^4+12*x^2*y^2+6*y^4-6*x^2-6*y^2+1)) + ...
(n*sqrt(10)*(4*x^4+4*x^2*y^2-3*x^2-4*x^2*y^2-4*y^4+3*y^2)) + ...
(o*sqrt(10)*(x^4-6*x^2*y^2+y^4)) + (p*sqrt(12)*(5*x^4*y-10*x^2*y^3+y^5)) + ...
(q*sqrt(12)*(15*x^4*y-12*x^2*y-5*y^5+4*y^3+10*x^2*y^3)) + ...
(r*sqrt(12)*(10*x^4*y+20*x^2*y^3+10*y^5-12*x^2*y-12*y^3+3*y)) + ...
(s*sqrt(12)*(10*x^5+20*x^3*y^2+10*x*y^4-12*x^3-12*x*y^2+3*x)) + ...
(t*sqrt(12)*(5*x^5-10*x^3*y^2-4*x^3-15*x*y^4+12*x*y^2)) + ...
(u*sqrt(12)*(x^5-10*x^3*y^2+5*x*y^4))', ...
'independent',{'x'},'dependent',{'y'}, ...
'coefficients', ...
{'a','b','c','d','e','f','g','h','ip','jp','k','l','m','n','o','p','q','r','s','t','u'})
The error says this expression is not a valid matlab expression
Hope you can help me, thanks.
I run your code :
The problem of your code is that
Coefficient d does not appear in the equation expression.
Could someone suggest the right way to eliminate constants from the code in production mode? I've already tested babel-plugin-constant-folding and babel-plugin-dead-code-elimination but they both work only with babel 5, not with babel 6.
Example:
const K=1;
const B=K + 13;
console.log("b=" + B);
I expect to get:
console.log("k=" + 1 + ", b=" + 14)
or, better (honestly, I don't need this level of optimization, replacing all ID with their values without string concat is completely enough for me):
console.log("k=1, b=13")
but get only:
var K = 1,
B = K + 13;
console.log("k=" + K + ", b=" + B);
Could someone suggest me the right sequence of babel plugins?
I have already asked the same question in the Matlab user community.
I have the following symbolic expression:
(3*s11)/2 + (3*s12)/2 + (3*s13)/2 + (3*s14)/2 + (3*s15)/2 + (s11*s12)/2 + (s11*s13)/2 + (s11*s14)/2 + (s12*s13)/2 + (s11*s15)/2 + (s12*s14)/2 + (s12*s15)/2 + (s13*s14)/2 + (s13*s15)/2 + (s14*s15)/2 + s11^2/4 + s12^2/4 + s13^2/4 + s14^2/4 + s15^2/4 + 9/4
It is stored as a symbolic expression variable. I would like to enforce the rule sij^2 = 1 i.e. the variables can be either -1 or +1. If I enforce the rule in the expression mentioned above, the expression will be as follows.
(3*s11)/2 + (3*s12)/2 + (3*s13)/2 + (3*s14)/2 + (3*s15)/2 + (s11*s12)/2 + (s11*s13)/2 + (s11*s14)/2 + (s12*s13)/2 + (s11*s15)/2 + (s12*s14)/2 + (s12*s15)/2 + (s13*s14)/2 + (s13*s15)/2 + (s14*s15)/2 + 1/4 + 1/4 + 1/4 + 1/4 + 1/4 + 9/4
How can I do this in Matlab?
Set assumptions e.g. assume(s14^2==1), then use simplify.
I would like help simplifying this boolean algebra expression:
B*C + ~A*~B + ~A*~C => A*B*C + ~A
I need to know the steps of how to simplify it to the ABC + ~A
'*' indicates "AND"
'+' indicates "OR"
"~A" indicates "A NOT"
Any help would be appreciated!
Thank you!
For a better view, i'll skip * for conjunction, and use ' for negation.
First you shall expand the 2 term disjunctions: Expand B*C , A'*B' and A'*C'
1) (A + A')BC + A'B'(C + C') + A'(B + B')C'
now distribute the parentheses.
2) ABC + A'BC + A'B'C + A'B'C' + A'BC' + A'B'C'
the fourth term and the last term are the same, A'B'C', so ignore one of them since p + p = p or you can expand the situation for your needs (might be needed for some situations) as in p+p+p+p+....+p = p
3) So now, lets try to search for common terms. See the 2nd term and 5th term, A'BC and A'BC'. Take common parenthesis, A'B(C+C') => A'B.
Do the same for 3rd term and the 4th term, A'B'C and A'B'C'. A'B'(C+C') => A'B' since X+X' = 1.
now we have:
ABC + A'B + A'B'
4) take common parenthesis again, 2nd and 3rd term: A'(B+B')
There you have ABC + A'
BC + A'B' + A'C' => ABC + A'
I have a matrix with a bunch of unknown constants such as the one below:
a*b -c -d 0
-c e -a -b-d
-d -a d -e
0 -b-d -e a
As you may realize it is symmetric about the diagonal and therefore, the diagonal values are all positive. All constants are greater than 0.
I would like to solve this for the eigenvalues in matlab. How would I go about doing this? I do not know the values a,b,c,d, and e. I would like to do something like this:
d = eig(#getMatrix)
but the eig function does not accept function handles.
No problem in MATLAB.
>> syms a b c d e
>> M = [a*b -c -d 0
-c e -a -b-d
-d -a d -e
0 -b-d -e a];
>> eig(M)
ans =
a/4 + d/4 + e/4 + (a*b)/4 - ((51*a*d^3)/16 - (117*a^4*b)/16 + (27*a^3*d)/16 + (27*a*e^3)/16 + (57*b*d^3)/2 + (27*a^3*e)/16 + (27*d*e^3)/16 + (51*d^3*e)/16 + 6*((4*(2*b*d - (a*e)/4 - (a*d)/4 - (d*e)/4 - (a^2*b)/4 + (11*a^2)/8 + b^2 + c^2 + (19*d^2)/8 + (11*e^2)/8 + (3*a^2*b^2)/8 - (a*b*d)/4 - (a*b*e)/4)*((17*a*d^3)/64 - (39*a^4*b)/64 + (9*a^3*d)/64 + (9*a*e^3)/64 + (19*b*d^3)/8 + (9*a^3*e)/64 + (9*d*e^3)/64 + (17*d^3*e)/64 + (45*a^4)/256 + (285*d^4)/256 + (45*e^4)/256 - (a^2*b^2)/16 + (a^2*b^3)/8 + (3*a^2*b^4)/16 + (31*a^4*b^2)/128 + (a^4*b^3)/64 - (3*a^4*b^4)/256 + (3*a^2*c^2)/16 + (15*a^2*d^2)/128 - (9*a^2*e^2)/128 + (19*b^2*d^2)/16 - (b^2*e^2)/16 + (3*c^2*d^2)/16 + (15*c^2*e^2)/16 +
...
(a*b*c^2*e)/8 + (3*a*b*d*e^2)/64 + (11*a*b*d^2*e)/64 + (a*b^2*d*e)/4 - (33*a^2*b*d*e)/32 - (5*a^2*b^2*d*e)/64 + (a*b*d*e)/4 + (a*c*d*e)/2 - 2*b*c*d*e) - 256*((17*a*d^3)/64 - (39*a^4*b)/64 + (9*a^3*d)/64 + (9*a*e^3)/64 + (19*b*d^3)/8 + (9*a^3*e)/64 + (9*d*e^3)/64 + (17*d^3*e)/64 + (45*a^4)/256 + (285*d^4)/256 + (45*e^4)/256 - (a^2*b^2)/16 + (a^2*b^3)/8 + (3*a^2*b^4)/16 + (31*a^4*b^2)/128 + (a^4*b^3)/64 - (3*a^4*b^4)/256 + (3*a^2*c^2)/16 + (15*a^2*d^2)/128 - (9*a^2*e^2)/128 + (19*b^2*d^2)/16 - (b^2*e^2)/16 + (3*c^2*d^2)/16 + (15*c^2*e^2)/16 + (15*d^2*e^2)/1...
Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display.
I deleted a lot there. Admittedly, its rather messy and lengthy, but can you really expect better?
Edit: I should comment that such a long extended formula may be dangerous in terms of computational accuracy. I've seen people blindly use such a mess of an expression, evaluating it in Fortran or MATLAB. They think that because it is "symbolic" that it is also exact. This is a total fallacy when numerical computations are done.
There may well be immense subtractive cancellation in those terms, with huge positive and negative terms almost canceling each other out, leaving a tiny result that is essentially worthless because of the limited dynamic range of floating point computations. BEWARE. At the very least, compare single and double precision computations done with the same expression. If they differ by any significant amount, try an extended precision version to verify there is not a problem for the doubles. If you have not tested such an expression and verified it extensively, don't trust it.