Skip to article frontmatterSkip to article content
import numpy as np
import matplotlib.pyplot as plt
fig, axis = plt.subplots(2, 2)
fig.tight_layout()
titles = ['$Constant$', '$Linear$', '$Power 2$', '$Power 3$']
xs = np.linspace(-10, 10, 100)
for power, (ax, title) in enumerate(zip(axis.flat, titles), 1):
    coeffs = np.random.uniform(-5, 5, power)
    poly = np.poly1d(coeffs)
    ax.plot(xs, poly(xs))
    ax.set_title(title)
<Figure size 640x480 with 4 Axes>
plt.Figure((2, 1.5))
xs = np.linspace(-10, 10, 100)
coeffs = np.array([2, 3, 4])
ys = np.dot(coeffs, [xs**2, xs**1, xs**0])
plt.plot(xs, ys)
<Figure size 640x480 with 1 Axes>
jedinice_vektor = np.arange(5)
print(jedinice_vektor)
print('Umnožak', np.dot(jedinice_vektor, jedinice_vektor))
[0 1 2 3 4]
Umnožak 30
vektor_red = np.arange(5).reshape(1, 5)
print(vektor_red)
[[0 1 2 3 4]]
vektor_stupac = np.arange(0, 50, 10).reshape(5, 1)
print(vektor_stupac)
[[ 0]
 [10]
 [20]
 [30]
 [40]]
print(np.dot(vektor_stupac, vektor_red))
[[  0   0   0   0   0]
 [  0  10  20  30  40]
 [  0  20  40  60  80]
 [  0  30  60  90 120]
 [  0  40  80 120 160]]
vektor_red = np.arange(5).reshape(5, 1)
vektor_stupac = np.arange(5).reshape(1, 5)
print(vektor_red)
print(vektor_stupac)
[[0]
 [1]
 [2]
 [3]
 [4]]
[[0 1 2 3 4]]
print(np.dot(vektor_stupac, vektor_red))
[[30]]
print(np.dot(vektor_red, vektor_stupac))
[[ 0  0  0  0  0]
 [ 0  1  2  3  4]
 [ 0  2  4  6  8]
 [ 0  3  6  9 12]
 [ 0  4  8 12 16]]