I'm learning Linear algebra/Transformations.
- I understand that in Linear algebra, Integration IS a Linear Transform.
- I CAN prove it algebrically
- BUT I'm CANNOT visualise that Graphically when using Integration as the Linear transform
- Properties of a Linear transform
per Relationship between properties of linear transformations algebraically and visually
a. Lines remain lines without getting curved
b. Origin remains fixed in place
c. Grid lines remain parallel and evenly spaced
I define the transform $\phi$ as the$\int f(x)$ where $f(x)=x$ $$\phi:V \rightarrow W$$ $$f \rightarrow \phi(f) = \int f(x) dx$$ integrating it $$ f'x =\int f(x) = \frac{x^2}{2} $$
But $f'x$ is a Curve; because the Grid lines are NOT evenly spaced i.e Contradicting #2.c above
In the below visualisation
- graphs are $f(x)$ and $f'(x)$ respectively.
visualisation here - https://file.io/ozR9YCYKQB6z . Python code to generate visualisation below.
Question:
- Since Integration is a Linear mapping: $f'(x)$ should be a straight line? equal grid spacing too?
- Appreciate any guidance on where I'm going wrong please.
Thanks in advance!
Python code to generate visualisation
import math
import numpy as np
import matplotlib.pyplot as plt
def plot_grid(
xmin: float,
xmax: float,
ymin: float,
ymax: float,
n_lines: int,
line_points: int,
map_func,
):
"""
Plot a transformation of a regular grid.
:param xmin: Minimum x value
:param xmax: Maximum x value
:param ymin: Minimum y value
:param ymax: Maximum y value
:param n_lines: Number of lines per axis
:param line_points: Number of points per line
:param map_func: Function to map the grid points to new coordinates
"""
# List for gathering the lines into.
lines = []
# Iterate over horizontal lines.
for y in np.linspace(ymin, ymax, n_lines):
lines.append([map_func(x, y) for x in np.linspace(xmin, xmax, line_points)])
# Iterate over vertical lines.
for x in np.linspace(xmin, xmax, n_lines):
lines.append([map_func(x, y) for y in np.linspace(ymin, ymax, line_points)])
# Iterate over y=x
lines.append([map_func(x, x) for x in np.linspace(xmin, xmax)])
color = "grey"
style = "dotted"
# Plot all the lines.
for i, line in enumerate(lines):
p = i / (len(lines) - 1) # Normalize to 0-1.
# Transpose the list of points for passing to plot.
xs, ys = zip(*line)
# Get the line color from the colormap.
if i == (len(lines)-1):
color = "black"
style = "solid"
plt.plot(xs, ys, color, linestyle=style)
Define some mapping functions.
def identity(x, y):
return x, y
def integration(x, y):
return (x, yy0.5)
Set up the plot surface...
plt.figure(figsize=(8, 8))
plt.tight_layout()
plt.subplot(2, 2, 1)
plt.title("V: f(x)")
plot_grid(0, 4, 0, 4, 5, 5, identity)
plt.subplot(2, 2, 2)
plt.title("W: f'(x)")
plot_grid(0, 4, 0, 4, 5, 5, integration)
plt.show()
```