Boolean algebra simplification exercise - boolean-algebra

So I have been given the following expression, but I cannot seem to solve it, can anyone do this and show the steps please?
Prove XY'Z + XYZ' + XYZ = XY + XZ

XY'Z + XYZ' + XYZ = XY + XZ
Notice X and Z are common factors between XY'Z and XYZ.
XZ(Y' + Y) + XYZ' =
Y' + Y is equal to 1 (if Y=0 then Y'=1 and so 0 + 1 = 1, that is 0 or 1 = 1. Similarly, if Y=1 then Y'=0 and so 1 + 0 = 1). Therefore, what you get is:
XZ·1 + XYZ' =
XZ·1 = XZ since A·1 = A (if A=0 then 0·1 is 0 and if A=1 then 1·1 = 1). Now the function is simplified to:
XZ + XYZ' =
Notice once again X is a common factor between XZ and XYZ'.
X(Z + YZ') =
Notice this time that Z + YZ' is a special case of the distributive law, which is A + A'B = A + B. This is because if we apply the general distributive law A + BC = (A + B)·(A + C) then we get A + A'B = (A + A')·(A + B) = 1·(A + B) = A + B. Following this reasoning we get to simplify the function even further:
X(Z + Y) =
All that's left is for us to use the distributive law and we finally arrive to the final result:
XY + XZ
Please note that nothing is written between variables, an AND operator (or "·" symbol) is assumed. It's just a way to save space.

Related

Multiplication over GF(256) in SAGE

I am trying to reproduce the multiplication over GF(256) of this question. Specifically, I am trying d4*02 in sage. According to the authors, this multiplication is 𝟷𝟶𝟷𝟷𝟶𝟶𝟷𝟷. In Sage I tried
k.<a> = FiniteField(256, impl='givaro', repr='int')
print(k((a**2+a**4+a**6+a**7)*(a))) # a**2+a**4+a**6+a**7 is d4 and a is 2
181
But 181 is not equal to 𝟷𝟶𝟷𝟷𝟶𝟶𝟷𝟷. What I am doing wrong? Could you help me, please?
You need to give your finite field constructor the correct modulus for Rijndael.
# Rijndael finite field
k.<a> = GF(2^8, modulus=x^8+x^4+x^3+x+1)
r = (a^7 + a^6 + a^4 + a^2) * a
v = r.integer_representation()
print(r, v, hex(v))
Output
a^7 + a^5 + a^4 + a + 1 179 0xb3
It's usually more convenient to specify field elements using integers. Eg,
# Rijndael finite field
k.<a> = GF(2^8, modulus=x^8+x^4+x^3+x+1)
kint = k._cache.fetch_int
p, q = [kint(u) for u in (0xd4, 0x02)]
r = p * q
v = r.integer_representation()
print(r, v, hex(v))
Alternatively, you can use a list and a dict to convert integers to and from field elements. The following code does the second multiplication from the linked question.
# Rijndael finite field
k.<a> = GF(2^8, modulus=x^8+x^4+x^3+x+1)
i2f = sorted(k)
f2i = {v: i for i, v in enumerate(i2f)}
p, q = [i2f[u] for u in (0xbf, 0x03)]
print(p)
print(q)
r = p * q
v = f2i[r]
print(r, v, hex(v))
Output
a^7 + a^5 + a^4 + a^3 + a^2 + a + 1
a + 1
a^7 + a^6 + a^4 + a^3 + a 218 0xda

Defining a particular polynomial ring in some CAS (Computer Algebra System)

I'm interested in defining the following polynomial quotient ring in some CAS (Singular, GAP, Sage, etc.):
R = GF(256)[x] / (x^4 + 1)
Specifically, R is the set of all polynomials of degree at most 3, whose coefficients belong to GF(256). Two examples include:
p(x) = {03}x^3 + {01}x^2 + {01}x + {02}
q(x) = {0B}x^3 + {0D}x^2 + {09}x + {0E}
Addition and multiplication are defined as the per ring laws. Here, I mention them for emphasis:
Addition: The corresponding coefficients are XOR-ed (the addition law in GF(256)):
p(x) + q(x) = {08}x^3 + {0C}x^2 + {08}x + {0C}
Multiplication: The polynomials are multiplicated (coefficients are added and multiplicated in GF(256)). The result is computed modulo x^4 + 1:
p(x) * q(x) = ({03}*{0B}x^6 + ... + {02}*{0E}) mod (x^4 + 1)
= ({03}*{0B}x^6 + ... + {02}*{0E}) mod (x^4 + 1)
= ({1D}x^6 + {1C}x^5 + {1D}x^4 + {00}x^3 + {1D}x^2 + {1C}x + {1C}) mod (x^4 + 1)
= {01}
Please tell me how to define R = GF(256)[x] / (x^4 + 1) in a CAS of your choice, and show how to implement the above addition and multiplication between p(x) and q(x).

Solve Linear System Over Finite Field with Module

Is there in sage, any instruction to solve a linear system equations
module p(x) (polynomial over finite field), where the system coefficients are polynomials over finite field in any indeterminate?. I know that for integers exists something like, example
sage: I6 = IntegerModRing(6)
sage: M = random_matrix(I6, 4, 4)
sage: v = random_vector(I6, 4)
sage: M \ v
(4, 0, 2, 1)
Here my code
F.<a> = GF(2^4)
PR = PolynomialRing(F,'X')
X = PR.gen()
a11 = (a^2)*(X^3)+(a^11)*(X^2)+1
a12 = (a)*(X^4)+(a^13)*(X^3)+X+1
a13 = X^2+(a^13)*(X^3)+a*(X^2)+1
a21 = X^3
a22 = X+a
a23 = X^2+X^3+a*X
a31 = (a^12)*X+a*(X^2)
a32 = (a^8)*(X^2)+X^2+X^3
a33 = a*X + (a^2)*(X^3)
M = matrix([[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]])
v = vector([(a^6)*(X^14)+X^13+X,a*(X^2)+(X^3)*(a^11)+X^2+X+a^12,(a^8)*(X^7)+a*(X^2)+(a^12)* (X^13)+X^3+X^2+X+1])
p = (a^2 + a)*X^3 + (a + 1)*X^2 + (a^2 + 1)*X + 1 # is than 6 in the firs code
I'm trying
matrix(PolynomialModRing(p),M)\vector(PolynomialModRing(p),v)
but PolynomialModRing not exist ...
EDIT
another person talk me that I will make
R.<Xbar> = PR.quotient(PR.ideal(p))
# change your formulas to Xbar instead of X
A \ b
# ==> (a^3 + a, a^2, (a^3 + a^2)*Xbar^2 + (a + 1)*Xbar + a^3 + a)
this work fine but Now I'm trying to apply the Chinese Theorem Remainder after the code, then .... I defined
q = X^18 + a*X^15 + a*X^12 + X^11 + (a + 1)*X^2 + a
r = a^3*X^3 + (a^3 + a^2 + a)*X^2 + (a^2 + 1)*X + a^3 + a^2 + a
#p,q and r are relatively prime
and I'm trying ...
crt([(A\b)[0],(A\b)[1],(A\b)[2]],[p,q,r])
but I get
File "element.pyx", line 344, in sage.structure.element.Element.getattr (sage/structure/element.c:3871)
File "misc.pyx", line 251, in sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1606)
AttributeError: 'PolynomialQuotientRing_field_with_category.element_class' object has no attribute 'quo_rem'
I'm thinking that problem is the change Xbar to X
Here my complete example to integers
from numpy import arange, eye, linalg
#2x-3y+2z=21
#x+4y-z=1
#-x+2y+z=17
A = matrix([[2,-3,2],[1,4,-1],[-1,2,1]])
b=vector([21,1,17])
p=[17,11,13]
d=det(A)
dlist=[0,0,0]
ylist=matrix(IntegerModRing(p[i]),[[2,-3,2],[1,4,-1], [-1,2,1]])\vector(IntegerModRing(p[i]),[21,1,17])
p1=[int(ylist[0]),int(ylist[1]),int(ylist[2])]
CRT(p1,p)
Maybe... this is what you want? Continuing your example:
G = F.extension(p) # This is what you want for "PolynomialModRing(p)
matrix(G,M)\vector(G,v)
which outputs
(a^3 + a, a^2, (a^3 + a^2)*X^2 + (a + 1)*X + a^3 + a)
In your question you ask "where the system coefficients are polynomials over finite field in any indeterminate" so what I'm doing above is NOT what you have actually asked, which would be a weird question to ask given your example. So, I'm going to just try to read your mind... :-)

Solutions for y for a rotated ellipse

I wish to plot an ellipse by scanline finding the values for y for each value of x.
For a plain ellipse the formula is trivial to find: y = Sqrt[b^2 - (b^2 x^2)/a^2]
But when the axes of the ellipse are rotated I've never been able to figure out how to compute y (and possibly the extents of x)
In parametric form
x[t]= a Cos[t] Cos[psi] - b Sin[t] Sin[psi]
y[t]= b Cos[psi] Sin[t] + a Cos[t] Sin[psi]
Where psi is the rotation angle, and a and b the semi-axes.
The parameter t goes from 0 to 2 Pi.
Or if you prefer in Cartesian non-parametric form:
(a x^2+b y^2) Cos[psi]^2 + (b x^2 +a y^2) Sin[psi]^2 + (a-b) x y Sin[2 psi]==1
Which yields to the two possible solutions for y[x], equivalent to the two solutions for the square root in the non-rotated case:
y -> (-(Sqrt[2]*Sqrt[a + b - 2*a*b*x^2 + (-a + b)*Cos[2*psi]]) +
(-a + b)*x*Sin[2*psi]) / (2*(b*Cos[psi]^2 + a*Sin[psi]^2))
y -> (Sqrt[2]*Sqrt[a + b - 2*a*b*x^2 + (-a + b)*Cos[2*psi]] +
(-a + b)*x*Sin[2*psi])/ (2*(b*Cos[psi]^2 + a*Sin[psi]^2))
Well, you asked for it :)
Those functions give:
And the limits for x are:
LimitX= +/- Sqrt[a + b + (-a + b)*Cos[2*psi]]/(Sqrt[2]*Sqrt[a]*Sqrt[b])

how can i calculate the polynomial that has the following asymptotes

how can i calculate the polynomial that has the tangent lines (1) y = x where x = 1, and (2) y = 1 where x = 365
I realize this may not be the proper forum but I figured somebody here could answer this in jiffy.
Also, I am not looking for an algorithm to answer this. I'd just like like to see the process.
Thanks.
I guess I should have mentioned that i'm writing an algorithm for scaling the y-axis of flotr graph
The specification of the curve can be expressed as four constraints:
y(1) = 1, y'(1) = 1 => tangent is (y=x) when x=1
y(365) = 1, y'(365) = 0 => tangent is (y=1) when x=365
We therefore need a family of curves with at least four degrees of freedom to match these constraints; the simplest type of polynomial is a cubic,
y = a*x^3 + b*x^2 + c*x + d
y' = 3*a*x^2 + 2*b*x + c
and the constraints give the following equations for the parameters:
a + b + c + d = 1
3*a + 2*b + c = 1
48627125*a + 133225*b + 365*c + d = 1
399675*a + 730*b + c = 0
I'm too old and too lazy to solve these myself, so I googled a linear equation solver to give the answer:
a = 1/132496, b = -731/132496, c = 133955/132496, d = -729/132496
I will post this type of question in mathoverflow.net next time. thanks
my solution in javascript was to adapt the equation of a circle:
var radius = Math.pow((2*Math.pow(365, 2)), 1/2);
var t = 365; //offset
this.tMax = (Math.pow(Math.pow(r, 2) - Math.pow(x, 2), 1/2) - t) * (t / (r - t)) + 1;
the above equation has the above specified asymptotes. it is part of a step polynomial for scaling an axis for a flotr graph.
well, you are missing data (you need another point to determine the polynomial)
a*(x-1)^2+b*(x-1)+c=y-1
a*(x-365)^2+b*(x-365)+c=y-1
you can solve the exact answer for b
but A depends on C (or vv)
and your question is off topic anyways, and you need to revise your algebra

Resources