Skip to content

Commit

Permalink
update solution 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsaki committed Feb 13, 2023
1 parent 68f1892 commit e269b99
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
Binary file modified answers/zk_solution_1.pdf
Binary file not shown.
79 changes: 76 additions & 3 deletions answers/zk_solution_1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,76 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6d10f0baf016782cb934c3f7f8580a7fcb8c956536d004393ef2d66e73d618f4
size 2016
# Zero Knowledge Bootcam
from scipy.optimize import fsolve
import numpy as np
import matplotlib.pyplot as plt


def question_one():
"""
1. Working with the following set of integers s = {0,1,2,3,4,5,6}
What is
a) 4 + 4
b) 3 x 5
c) what is the inverse of 3?
"""
# opereations are caried out by modulo 7
s = {0, 1, 2, 3, 4, 5, 6}
p = 7

a = (4+4) % p
b = (3*5) % p
c = pow(3, -1, p) # pyhton internal inverse modular function pow()

# For c we can use Fermat's little theorem where a^-1 = a^(p-2) mod p
c = (3**(p-2))%p

print(f"Question 1: a={a} b={b} c={c}")


def question_two():
"""
2. For S = {0,1,2,3,4,5,6}
Can we consider 'S' and the operation '+' to be a group?
"""
notes = """
Simply put a group is a set of elements set(a, b, c, ...) plus a binary operation
To be concidered a group the combination needs to have the following Properties:
1. Closure:
For all a,b in set S, the result of a + b is also in S
2. Associativity:
For all a,b and c in set S, (a+b)+c = a+(b+c)
3. Identity element
There exists an element e in set S such that, every element a in set S, the equation e + a = a + e = a holds.
Such an element is unique and thus on speaks of the identity element.
4. Inverse element
For each a in set S, there exists an element b in set S, commonly denoted -a (if operations is +) or a**-1 if operator is *, such that a + b = b + a = e, where e is the identity element.
"""

def questions_three():
"""
What is -13 mod 5?
"""
res = -13 % 5
print(f"Question 3: {res}")


def question_four():
"""
Polynomials
For the polynomials x**3 - x**2 + 4x - 12
Find a the positive root?
what is the degree of this polymial?
"""
# def f(x): return x**2 - x + 4
# res = fsolve(f,2)

# print(f"Question 4: {res}")


def main():
question_one()
question_two()
questions_three()
question_four()


main()
6 changes: 3 additions & 3 deletions answers/zk_solution_1.tex
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ \section*{Question 2}
\end{itemize}

\section*{Question 3}
$-13 \mod 5 \equiv 2 \mod 5$. Answer is 2.
$-13 \mod 5 \equiv (-13 + 15 )\mod 5 \equiv 2 \mod 5$. Answer is 2.

\section*{Question 4}

We can simplify our function $f(x) = x^{3}-x^{2}+4x-12$ to factors $f(x)= (x-2)\cdot (x^{2}+x+6)$
The degree of our polynomial is $3$. We can simplify our function $f(x) = x^{3}-x^{2}+4x-12$ to factors $f(x)= (x-2)\cdot (x^{2}+x+6)$. Using factorization method for $(x-2)=0$ our answer is 2.

Using Polynomial Remainder Theorem $\frac{P(x)}{x-a}\xrightarrow{} r=P(a)$ where $P(x) = x^{3}-x^{2}+4x-12$. If we divided $P(x)$ with a first degree polynomial $(x-a)$, and we don't get a remainder $r=0$, this verifies $(x-a)$ is a valid factor of our polynomial $P(x)$. We can solve this with our factor $(x-2)$ for $P(a)$. When $x=2$, $P(2)=2^{3}-2^{2}+4\cdot2-12=0$. Solving for $x$ using $(x-2)=0$ or $(x^{2}+x+6)=0$. Answer is $2$. The degree of this polynomial is $3$.
Using Polynomial Remainder Theorem formula $\frac{P(x)}{x-a}\xrightarrow{} r=P(a)$ where $P(x) = x^{3}-x^{2}+4x-12$. If we divided $P(x)$ with a first degree polynomial $(x-a)$, and we don't get a remainder $r=0$, this verifies $(x-a)$ is a valid factor of our polynomial $P(x)$. We can solve this with our factor $(x-2)$ for $P(a)$. When $x=2$, $P(2)=2^{3}-2^{2}+4\cdot2-12=0$. Solving for $x$ using $(x-2)=0$ give us $2$. While solving for $x$ using $(x^{2}+x+6)=0$ gives us complex numbers.

See: \href{https://www.khanacademy.org/math/algebra2/x2ec2f6f830c9fb89:poly-div/x2ec2f6f830c9fb89:remainder-theorem/v/polynomial-remainder-theorem-to-test-factor}{Remainder theorem: checking factors}

Expand Down

0 comments on commit e269b99

Please sign in to comment.