Beispiel #1
0
from math import sqrt as rt


class Matrix(Element):
    def isApproxEq(self, b, approximation):
        for r in range(len(self.value)):
            for c in range(len(self.value[r])):
                if abs(b.value[r][c] - self.value[r][c]) > approximation:
                    return False
        return True


def operation(a, b):
    return Matrix("NONAME", np.matmul(a.value, b.value))


elements = [
    Matrix("P", np.array([[1, 0], [0, 1]])),
    Matrix("Q", 0.5 * np.array([[-1, -rt(3)], [rt(3), -1]])),
    Matrix("R", 0.5 * np.array([[-1, rt(3)], [-rt(3), -1]])),
    Matrix("S", np.array([[1, 0], [0, -1]])),
    Matrix("T", 0.5 * np.array([[-1, rt(3)], [rt(3), 1]])),
    Matrix("U", 0.5 * np.array([[-1, -rt(3)], [-rt(3), 1]]))
]

table = formCayleyTable(elements, operation, 0.0001)

mygroup4 = Group.fromCayleyTable(elements, table)

print("\n\nGroup 4")
print(mygroup4)
Beispiel #2
0
def root(a, b, c):
    r1 = (-b + rt((b**2) - (4 * a * c))) / 2 * a
    r2 = (-b - rt((b**2) - (4 * a * c))) / 2 * a

    return "{r1} and {r2}".format(r1=r1, r2=r2)
Beispiel #3
0
 def ozanam(nu):
     a = 4 * nu + 8
     b = (nu + 1) * a + 4 * nu + 7
     c = int(rt(a**2 + b**2))
     return [a, b, c]
Beispiel #4
0
 def stifel(nu):
     a = (2 * nu + 3)
     b = (nu + 1) * a + (nu + 1)
     c = int(rt(a**2 + b**2))
     return [a, b, c]
Beispiel #5
0
    },
    'joey': {
        'home': '9991616'
    },
    'ross': {
        'work': '2221717'
    },
}

#import a library
import math
print(math.sqrt(5))
from math import sqrt, acos
print(sqrt(5))
from math import sqrt as rt
print(rt(5))
print(5**0.5)

from pprint import pprint as pp

pp(contacts)
pp(contacts['phoebe'])
print(contacts['phoebe']['email'])
phoebe = contacts['phoebe']
phoebes_email = phoebe['email']
print(phoebes_email)

print(contacts['phoebe']['pets'][2])


def show_contacts():