function ExplainElementaryOperations
%% Linear Combinations of Lines Preserve Intersection

%% Generate two pseudo random lines
	N = randi([-10,10],[2,3]);
	M = N;

%% Given a linear system of two lines produce the parametric equations
	[x,y1,y2] = LinesFromMatrix(N);

%% Find where the lines intersect
	R = rref(N);
	p = R(1,3);
	q = R(2,3);

%% Plot a random line from the list, and the point (p,q)
	close all
	hold on;
	axis([-10,10,-10,10])
	plot(x,y1,'r+');
	plot(x,y2,'b+');
	plot(p,q,'k*','MarkerSize',12);

%% Now plot the lines that result forming linear combinations of lines
	K = .005;
	for i = 0:K:.3
		pause(.1);
		N(1,:) = (1-i) * N(1,:) + i * N(2,:);
		N(2,:) = (1-i) * N(2,:) + i * N(1,:);
		[x,y1,y2] = LinesFromMatrix(N);

		axis([-10,10,-10,10])
		plot(x,y1,'r-');
		plot(x,y2,'b-');
		plot(p,q,'ko','MarkerSize',15);
	end
	
	for i = 0:K:.3 
		pause(.1);
		N(1,:) = (1-i) * N(1,:) + i * M(1,:);
		N(2,:) = (1-i) * N(2,:) + i * M(2,:);
		[x,y1,y2] = LinesFromMatrix(N);

		axis([-10,10,-10,10])
		plot(x,y1,'b-');
		plot(x,y2,'r-');
		plot(p,q,'ko','MarkerSize',15);
	end

	for i = 0:K:1
		pause(.1);
		N(1,:) = (1-i) * M(1,:) - i * M(2,:);
		N(2,:) = (1-i) * M(2,:) - i * M(1,:);
		[x,y1,y2] = LinesFromMatrix(N);

		axis([-10,10,-10,10])
		plot(x,y1,'r-');
		plot(x,y2,'b-');
		plot(p,q,'ko','MarkerSize',15);
	end

%% A function which returns parametric equations corresponding to a 2-D system of two equations
function [x,y1,y2] =  LinesFromMatrix(M)

	a = M(1,1);
	b = M(1,2);
	c = M(1,3);


	d = M(2,1);
	e = M(2,2);
	f = M(2,3);

	x = -10:10;
	y1 = -a/b .* x + c/b;
	y2 = -d/e .* x + f/e;
	 
