# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/ai-ds/linear-methods/real-axis-transformation
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/ai-ds/linear-methods/real-axis-transformation/en.mdx

Learn quadratic forms, symmetric matrices, coordinate transformations from eigenvalues, and conic sections such as ellipses and hyperbolas.

---

## Quadratic Forms with Symmetric Matrices

When you encounter a general quadratic equation, the best way to understand it is by looking at its structure in matrix form. Imagine you have a symmetric matrix $$A$$ with elements:

Visible text: When you encounter a general quadratic equation, the best way to understand it is by looking at its structure in matrix form. Imagine you have a symmetric matrix with elements:

Component: MathContainer
Children:

```math
A = \begin{pmatrix} a & b/2 \\ b/2 & c \end{pmatrix}
```

This matrix has eigenvalues $$\lambda_1, \lambda_2 \in \mathbb{R}$$ and corresponding orthonormal eigenvectors $$v_1, v_2 \in \mathbb{R}^2$$. Something interesting happens when we use coordinate transformation through the matrix $$S = (v_1 \quad v_2) \in \mathbb{R}^{2 \times 2}$$.

Visible text: This matrix has eigenvalues and corresponding orthonormal eigenvectors . Something interesting happens when we use coordinate transformation through the matrix .

For coordinate transformation, we use $$\begin{pmatrix} \delta \\ \epsilon \end{pmatrix} = S^T \begin{pmatrix} d \\ e \end{pmatrix}$$. In the new coordinates $$\xi = S^T x$$, the equation becomes:

Visible text: For coordinate transformation, we use . In the new coordinates , the equation becomes:

Component: MathContainer
Children:

```math
\lambda_1 \xi_1^2 + \lambda_2 \xi_2^2 + \delta \xi_1 + \epsilon \xi_2 + f = 0
```

## Completing the Square Process

For both variables with $$\lambda_1, \lambda_2 \neq 0$$, the completing the square process is performed separately:

Visible text: For both variables with , the completing the square process is performed separately:

Component: MathContainer
Children:

```math
\begin{aligned} 0 &= \lambda_1 \left( \xi_1^2 + 2 \frac{\delta}{2\lambda_1} \xi_1 + \frac{\delta^2}{4\lambda_1^2} \right) - \frac{\delta^2}{4\lambda_1} \\ &\quad + \lambda_2 \left( \xi_2^2 + 2 \frac{\epsilon}{2\lambda_2} \xi_2 + \frac{\epsilon^2}{4\lambda_2^2} \right) - \frac{\epsilon^2}{4\lambda_2} + f \end{aligned}
```

The result of this process gives a simpler form:

Component: MathContainer
Children:

```math
\begin{aligned} &= \lambda_1 \left( \xi_1 + \frac{\delta}{2\lambda_1} \right)^2 + \lambda_2 \left( \xi_2 + \frac{\epsilon}{2\lambda_2} \right)^2 \\ &\quad + \left( f - \frac{\delta^2}{4\lambda_1} - \frac{\epsilon^2}{4\lambda_2} \right) \end{aligned}
```

By determining the center point $$(m_1, m_2) = \left( -\frac{\delta}{2\lambda_1}, -\frac{\epsilon}{2\lambda_2} \right)$$ and the constant $$\gamma = \frac{\delta^2}{4\lambda_1} + \frac{\epsilon^2}{4\lambda_2} - f$$, we obtain:

Visible text: By determining the center point and the constant , we obtain:

Component: MathContainer
Children:

```math
\lambda_1 (\xi_1 - m_1)^2 + \lambda_2 (\xi_2 - m_2)^2 - \gamma = 0
```

For $$\gamma > 0$$, various curve forms can emerge depending on the signs of the eigenvalues.

Visible text: For , various curve forms can emerge depending on the signs of the eigenvalues.

## Curve Classification

### Both Eigenvalues Positive

If $$\lambda_1 > 0$$ and $$\lambda_2 > 0$$, then the conic section formed is an **ellipse**:

Visible text: If and , then the conic section formed is an **ellipse**:

Component: MathContainer
Children:

```math
\frac{(\xi_1 - m_1)^2}{r_1^2} + \frac{(\xi_2 - m_2)^2}{r_2^2} = 1
```

With semi-axis lengths $$r_1 = \sqrt{\frac{\gamma}{\lambda_1}}$$ in the direction of $$v_1$$ and $$r_2 = \sqrt{\frac{\gamma}{\lambda_2}}$$ in the direction of $$v_2$$.

Visible text: With semi-axis lengths in the direction of and in the direction of .

Component: LineEquation
Props:
- title: Ellipse Visualization in Coordinates $$\xi_1, \xi_2$$
  Visible text: Ellipse Visualization in Coordinates
- description: Ellipse curve with both positive eigenvalues and principal axes aligned with eigenvector directions.
- data: [
{
points: Array.from({ length: 100 }, (_, i) => {
const t = (i / 99) * 2 * Math.PI;
const lambda1 = 2; // λ₁ > 0
const lambda2 = 1; // λ₂ > 0
const gamma = 16; // γ > 0
const m1 = 0; // δ/(2λ₁) = 0
const m2 = 0; // ε/(2λ₂) = 0
const r1 = Math.sqrt(gamma / lambda1);
const r2 = Math.sqrt(gamma / lambda2);
const x = Math.cos(t) * r1 + m1;
const y = Math.sin(t) * r2 + m2;
return { x, y, z: 0 };
}),
color: getColor("CYAN"),
smooth: true,
showPoints: false
},
{
points: [
{ x: -4, y: 0, z: 0 },
{ x: 4, y: 0, z: 0 }
],
color: getColor("EMERALD"),
smooth: false,
showPoints: false,
labels: [
{
text: "ξ₁",
at: 1,
offset: [0.3, -0.3, 0]
}
]
},
{
points: [
{ x: 0, y: -3, z: 0 },
{ x: 0, y: 3, z: 0 }
],
color: getColor("EMERALD"),
smooth: false,
showPoints: false,
labels: [
{
text: "ξ₂",
at: 1,
offset: [0.3, 0.3, 0]
}
]
},
{
points: [
{ x: 0, y: 0, z: 0 }
],
color: getColor("ROSE"),
smooth: false,
showPoints: true,
labels: [
{
text: "Center (m₁, m₂)",
at: 0,
offset: [0.4, 0.4, 0]
}
]
}
]
- cameraPosition: [0, 0, 12]
- showZAxis: false

### Eigenvalues with Opposite Signs

When $$\lambda_1 > 0$$ and $$\lambda_2 < 0$$, the conic section formed is a **hyperbola**:

Visible text: When and , the conic section formed is a **hyperbola**:

Component: MathContainer
Children:

```math
\frac{(\xi_1 - m_1)^2}{r_1^2} - \frac{(\xi_2 - m_2)^2}{r_2^2} = 1
```

With semi-axis lengths $$r_1 = \sqrt{\frac{\gamma}{\lambda_1}}$$ in the direction of $$v_1$$ and $$r_2 = \sqrt{\frac{\gamma}{-\lambda_2}}$$ in the direction of $$v_2$$.

Visible text: With semi-axis lengths in the direction of and in the direction of .

Component: LineEquation
Props:
- title: Hyperbola Visualization in Coordinates $$\xi_1, \xi_2$$
  Visible text: Hyperbola Visualization in Coordinates
- description: Hyperbola curve with principal axes aligned with eigenvector directions and center transformation.
- data: [
{
points: Array.from({ length: 60 }, (_, i) => {
const t = (i / 29 - 1) * 2.5;
const lambda1 = 2; // λ₁ > 0
const lambda2 = -1; // λ₂ < 0
const gamma = 3; // γ > 0
const r1 = Math.sqrt(gamma / lambda1);
const r2 = Math.sqrt(gamma / (-lambda2));
const x = Math.cosh(t) * r1;
const y = Math.sinh(t) * r2;
return { x, y, z: 0 };
}),
color: getColor("ORANGE"),
smooth: true,
showPoints: false
},
{
points: Array.from({ length: 60 }, (_, i) => {
const t = (i / 29 - 1) * 2.5;
const lambda1 = 2;
const lambda2 = -1;
const gamma = 3;
const r1 = Math.sqrt(gamma / lambda1);
const r2 = Math.sqrt(gamma / (-lambda2));
const x = -Math.cosh(t) * r1;
const y = Math.sinh(t) * r2;
return { x, y, z: 0 };
}),
color: getColor("ORANGE"),
smooth: true,
showPoints: false
},
{
points: Array.from({ length: 2 }, (_, i) => {
const lambda1 = 2;
const lambda2 = -1;
const gamma = 3;
const r1 = Math.sqrt(gamma / lambda1);
const r2 = Math.sqrt(gamma / (-lambda2));
const slope = r2 / r1; // slope asimptot
const x = (i - 0.5) * 6; // dari -3 ke 3
const y = slope * x;
return { x, y, z: 0 };
}),
color: getColor("SKY"),
smooth: false,
showPoints: false,
labels: [
{
text: "r₁",
at: 1,
offset: [0.5, -0.5, 0]
}
]
},
{
points ... [truncated; 1997 chars]
- cameraPosition: [0, 0, 12]
- showZAxis: false

### One Eigenvalue Zero

A special condition occurs when $$\lambda_1 \neq 0$$ and $$\lambda_2 = 0$$. Completing the square gives:

Visible text: A special condition occurs when and . Completing the square gives:

Component: MathContainer
Children:

```math
0 = \lambda_1 \left( \xi_1^2 + 2 \frac{\delta}{2\lambda_1} \xi_1 + \frac{\delta^2}{4\lambda_1^2} \right) - \frac{\delta^2}{4\lambda_1} + \epsilon \xi_2 + f
```

```math
= \lambda_1 \left( \xi_1 + \frac{\delta}{2\lambda_1} \right)^2 + \epsilon \xi_2 + \left( f - \frac{\delta^2}{4\lambda_1} \right)
```

```math
= \lambda_1 (\xi_1 - m_1)^2 + \epsilon \xi_2 - \gamma
```

The conic section formed is a **parabola**:

Component: MathContainer
Children:

```math
\xi_2 = -\frac{\lambda_1}{\epsilon} (\xi_1 - m_1)^2 + \frac{\gamma}{\epsilon}
```

Component: LineEquation
Props:
- title: Parabola Visualization in Coordinates $$\xi_1, \xi_2$$
  Visible text: Parabola Visualization in Coordinates
- description: Parabola curve with one zero eigenvalue and coordinate axis transformation aligned with eigenvectors.
- data: [
{
points: Array.from({ length: 50 }, (_, i) => {
const t = (i / 49 - 0.5) * 6;
const lambda1 = 1; // λ₁ ≠ 0
const epsilon = -2; // ε ≠ 0
const gamma = 2; // γ
const m1 = 0; // δ/(2λ₁) = 0
const x = t;
const y = -(lambda1 / epsilon) * Math.pow(x - m1, 2) + (gamma / epsilon);
return { x, y, z: 0 };
}),
color: getColor("PURPLE"),
smooth: true,
showPoints: false
},
{
points: [
{ x: -3.5, y: 0, z: 0 },
{ x: 3.5, y: 0, z: 0 }
],
color: getColor("CYAN"),
smooth: false,
showPoints: false,
labels: [
{
text: "ξ₁",
at: 1,
offset: [0.3, -0.3, 0]
}
]
},
{
points: [
{ x: 0, y: -0.5, z: 0 },
{ x: 0, y: 4, z: 0 }
],
color: getColor("CYAN"),
smooth: false,
showPoints: false,
labels: [
{
text: "ξ₂",
at: 1,
offset: [0.3, 0.3, 0]
}
]
}
]
- cameraPosition: [0, 0, 12]
- showZAxis: false

## Two-Dimensional Example

Conic sections in $$\mathbb{R}^2$$ satisfy the general quadratic equation:

Visible text: Conic sections in satisfy the general quadratic equation:

Component: MathContainer
Children:

```math
ax_1^2 + bx_1x_2 + cx_2^2 + dx_1 + ex_2 + f = 0
```

Which can be written in matrix form as:

Component: MathContainer
Children:

```math
\begin{pmatrix} x_1 \\ x_2 \end{pmatrix}^T \begin{pmatrix} a & b/2 \\ b/2 & c \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} + \begin{pmatrix} d \\ e \end{pmatrix}^T \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} + f = 0
```

## Quadratic Surfaces and Transformation

For a symmetric matrix $$A \in \mathbb{R}^{n \times n}$$, vector $$b \in \mathbb{R}^n$$, and scalar $$c \in \mathbb{R}$$, the **quadratic surface** $$Q$$ is defined as the solution set of the general quadratic equation:

Visible text: For a symmetric matrix , vector , and scalar , the **quadratic surface** is defined as the solution set of the general quadratic equation:

Component: MathContainer
Children:

```math
x^T A x + b^T x + c = 0
```

Which can be written in explicit form:

Component: MathContainer
Children:

```math
Q = \left\{ x \in \mathbb{R}^n : x^T A x + b^T x + c = 0 \right\}
```

```math
= \left\{ x \in \mathbb{R}^n : \sum_{j=1}^n \sum_{k=1}^n x_j a_{jk} x_k + \sum_{j=1}^n b_j x_j + c = 0 \right\}
```

If $$A \in \mathbb{R}^{n \times n}$$ is symmetric and $$v_1, \ldots, v_n \in \mathbb{R}^n$$ is an orthonormal basis of eigenvectors with $$A \cdot v_i = \lambda_i \cdot v_i$$, then the orthonormal matrix $$S = (v_1 \quad \ldots \quad v_n)$$ enables diagonalization $$A \cdot S = S \cdot \Lambda$$ or $$\Lambda = S^{-1} \cdot A \cdot S = S^T \cdot A \cdot S$$.

Visible text: If is symmetric and is an orthonormal basis of eigenvectors with , then the orthonormal matrix enables diagonalization or .

In the new coordinate basis $$\xi = S^T x$$ and $$\mu = S^T b$$, the quadratic surface has diagonal form:

Visible text: In the new coordinate basis and , the quadratic surface has diagonal form:

Component: MathContainer
Children:

```math
Q = \left\{ \xi \in \mathbb{R}^n : \xi^T S^T A S \xi + b^T S \xi + c = 0 \right\}
```

```math
= \left\{ \xi \in \mathbb{R}^n : \xi^T \Lambda \xi + \mu^T \xi + c = 0 \right\}
```

```math
= \left\{ \xi \in \mathbb{R}^n : \sum_{j=1}^n \lambda_j \xi_j^2 + \sum_{j=1}^n \mu_j \xi_j + c = 0 \right\}
```

```math
= \left\{ \xi \in \mathbb{R}^n : \sum_{j=1}^n (\lambda_j \xi_j^2 + \mu_j \xi_j) = -c \right\}
```

In the orthonormal basis of eigenvectors, the quadratic form has a diagonal structure. This transformation is called **principal axis transformation** because the new coordinate axes are aligned with the directions of the matrix eigenvectors.