diff --git a/lab4.py b/lab4.py new file mode 100644 index 0000000..10587bc --- /dev/null +++ b/lab4.py @@ -0,0 +1,37 @@ +# https://www.youtube.com/playlist?list=PLFQBXZP95PWh1sDMZRHsu7P8maiUS0MTi +import numpy +import matplotlib.pyplot as plt + +# Our polynomials in factored form +p1 = numpy.poly1d([1, 3, 2]) +p2 = numpy.poly1d([1, 2, 4, 1]) + +p3 = numpy.polymul(p1, p2) +print(p3) + +pl = numpy.poly1d([1, 5, 13, -1]) + +print(pl) +print(numpy.roots(pl)) + +T = 1 +s = numpy.poly1d([1, 0]) +#?? + +# Vectors +v1 = numpy.array([1, 2, 3]) +v2 = numpy.array([4, 5, 6]) + +# Convolve v1 and v2 +v3 = numpy.convolve(v1, v2) + +# Valid convolution +v4 = numpy.convolve(v1, v2, 'valid') + +print(v3) +print(v4) + +# Roots +# r1 = numpy.roots(p1) + +# print(r1)