Perkalian Titik (DOT PRODUCT)#

a. Materi perkalian titik vektor (dot product)#

Definisi#

Perkalian titik (dot product) adalah operasi aljabar antara dua vektor dengan panjang yang sama, menghasilkan sebuah skalar.

Misal dua vektor:

\[\begin{split} \mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \end{bmatrix}, \quad \mathbf{w} = \begin{bmatrix} w_1 \\ w_2 \end{bmatrix}\end{split}\]

Maka dot product:

\[\mathbf{v} \cdot \mathbf{w} = v_1w_1 + v_2w_2\]

Contoh#

\[\begin{split} \begin{bmatrix} 2 \\ -3 \end{bmatrix} \cdot \begin{bmatrix} 4 \\ 1 \end{bmatrix} = 2 \cdot 4 + (-3) \cdot 1 = 8 - 3 = 5 \end{split}\]

Latihan#

  1. Hitung:

\[\begin{split} \begin{bmatrix} 3 \\ 4 \end{bmatrix} \cdot \begin{bmatrix} 2 \\ -2 \end{bmatrix} \end{split}\]
  1. Panjang vektor \(\mathbf{v} = \begin{bmatrix} 3 \\ 4 \end{bmatrix}\):

\[ |\mathbf{v}| = \sqrt{3^2 + 4^2} = 5 \]
  1. Hitung:

\[ \mathbf{v} \cdot \mathbf{v} = 3 \cdot 3 + 4 \cdot 4 = 25 \]

dan bandingkan dengan \(|\mathbf{v}|^2\)

  1. Rotasi vektor \(\mathbf{v}\) sebesar \(90^\circ\) CCW:

\[\begin{split} \text{Matriks rotasi:} \quad \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \end{split}\]

Hasil rotasi:

\[\begin{split}\mathbf{w} = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 3 \\ 4 \end{bmatrix} \begin{bmatrix} -4 \\ 3 \end{bmatrix} \end{split}\]
\[\mathbf{v} \cdot \mathbf{w} = 3 \cdot (-4) + 4 \cdot 3 = -12 + 12 = 0 \]

Geometri Perkalian Titik#

Untuk vektor berdimensi \(n\):

\[ \mathbf{v} \cdot \mathbf{w} = \sum_{i=1}^{n} v_i w_i \]

Juga dapat ditulis sebagai:

\[ \mathbf{v} \cdot \mathbf{w} = |\mathbf{v}| |\mathbf{w}| \cos(\theta) \]

Sifat-Sifat Dot Product#

  1. Komutatif:

\[ \mathbf{v} \cdot \mathbf{w} = \mathbf{w} \cdot \mathbf{v} \]
  1. Distributif:

\[ \mathbf{v} \cdot (\mathbf{w} + \mathbf{u}) = \mathbf{v} \cdot \mathbf{w} + \mathbf{v} \cdot \mathbf{u} \]
  1. Skalar:

\[ r(\mathbf{v} \cdot \mathbf{w}) = (r\mathbf{v}) \cdot \mathbf{w} \]
  1. Positif semidefinit:

\[ \mathbf{v} \cdot \mathbf{v} \geq 0 \]

b. Buat program untuk menghitung dot product vektor (perkalian titik dari dua vector)#

# implementasi porgram untuk menghitung dot product vektor
def dot_product(vec1, vec2):
    if len(vec1) != len(vec2):
        raise ValueError("Vektor harus memiliki panjang yang sama.")
    
    hasil = 0
    for i in range(len(vec1)):
        hasil += vec1[i] * vec2[i]
    return hasil

# Contoh penggunaan:
vektor_A = [3, 4]
vektor_B = [6, 7]

print("Vektor A:", vektor_A)
print("Vektor B:", vektor_B)

hasil_dot = dot_product(vektor_A, vektor_B)
print("Dot Product A · B =", hasil_dot)
Vektor A: [3, 4]
Vektor B: [6, 7]
Dot Product A · B = 46

a. Materi vektor satuan#

Vektor Satuan di \(\mathbb{R}^n\)#

Vektor satuan (unit vector) adalah vektor dengan panjang satu.

Jelas bahwa vektor \(\mathbf{x}\) adalah vektor satuan jika dan hanya jika:

\[ \|\mathbf{x}\|^2 = \mathbf{x} \cdot \mathbf{x} = 1 \]

Membentuk Vektor Satuan#

Misalkan \(\mathbf{x}\) adalah vektor tak nol di \(\mathbb{R}^n\). Maka:

\[ \hat{\mathbf{x}} = \frac{\mathbf{x}}{\|\mathbf{x}\|} \]

adalah vektor satuan.


Bukti:#

\[ \frac{\mathbf{x}}{\|\mathbf{x}\|} \cdot \frac{\mathbf{x}}{\|\mathbf{x}\|} = \frac{\mathbf{x} \cdot \mathbf{x}}{\|\mathbf{x}\|^2} = \frac{\|\mathbf{x}\|^2}{\|\mathbf{x}\|^2} = 1 \]

Contoh:#

Misalkan \(\mathbf{x} = \begin{bmatrix} 3 \\ 4 \end{bmatrix}\)

  • Panjang vektor:

\[ \|\mathbf{x}\| = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5 \]
  • Vektor satuan:

\[\begin{split} \mathbf{u} = \frac{\mathbf{x}}{\|\mathbf{x}\|} = \frac{1}{5} \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} \frac{3}{5} \\ \frac{4}{5} \end{bmatrix} \end{split}\]
  • Verifikasi:

\[ \|\mathbf{u}\| = \sqrt{ \left(\frac{3}{5}\right)^2 + \left(\frac{4}{5}\right)^2 } = \sqrt{ \frac{9}{25} + \frac{16}{25} } = \sqrt{ \frac{25}{25} } = \sqrt{1} = 1 \]

b. buat program untuk mengkonversi vektor menjadi vektor satuan (vektor memiliki panjang vektor 1)#

# Implementasi kode program untuk mengkoversi vektor menjadi vektor satuan
import numpy as np

def normalisasi_vektor(vektor):
    panjang = np.linalg.norm(vektor)
    if panjang == 0:
        raise ValueError("Vektor nol tidak dapat dinormalisasi.")
    vektor_satuan = vektor / panjang
    return vektor_satuan

# Contoh penggunaan
vektor = np.array([3, 4])
vektor_satuan = normalisasi_vektor(vektor)

print("Vektor awal:", vektor)
print("Vektor satuan:", vektor_satuan)
print("Panjang vektor satuan:", np.linalg.norm(vektor_satuan))
Vektor awal: [3 4]
Vektor satuan: [0.6 0.8]
Panjang vektor satuan: 1.0