pysim/lab4.py
2024-05-20 22:19:59 +02:00

37 lines
602 B
Python

# 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)