# Vector Algebra

Elementary Vector Algebra and programming

Author: Dara O Shayda

# What is Vector Algebra?

# What is a Vector?

Any set of objects with addition, subtraction and multiplication is an algebra. Any such object requiring a **fixed number of symbols** to describe itself is called a vector. These are informal definitions. A collection of such vectors with operations such as **+** or **-** is called a Vector Algebra.

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)

[![point_at_birds.jpeg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-02/scaled-1680-/point-at-birds.jpeg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-02/point-at-birds.jpeg)

**Here**: is the start point or the **pivot**.

**There**: is the finish point or the **endpoint**.

Select any two symbols and you can create a tuple namely the **left CurlyBracket** '**{**' and the **right Curly Bracket** '**}**' for example:

```diff
{a,b} or {c,d}
```

Now let's **Add** these two vectors:

---

```diff
{a,b} + {c,d} = {a + c,b + d};
```

<div class="code-toolbar" id="bkmrk--3"><div class="toolbar"><div class="toolbar-item">  
</div></div></div>**Operator**: any symbol in mathematics, that indicates an **operation** to be performed e.g. +

'**+**' : **Addition Operator** of the form ◧ op ◨

◧ + ◨

◧: **Left Operand** of an Operator

◨: **Right Operand** of an Operator

'**=**': Identity Operator of the form ◧ op ◨

'**,**' : **Comma** or **Separator** **Operator** of the form ◧ op ◨

'**{ }**': **Brackets** or **Grouping** or **Bracket Operator**, grouping the enclosed circle between the right and left parenthesis

# What is Algebra?

<p class="callout info">**What**: Concept of Algebra  
**Why**: What is an algebra why you need algebra  
**Time To Complete**: 1 hour</p>

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)

#### Nature of Algebra 

Algebra is a set of finitely many symbols with functions and operators acting on these symbols in such a fashion that all these functions and operators can be implemented in an electromechanical device or a computer or computer program.

A human being or a machine, by applying mechanically oriented operations could simply operate on the symbols of an algebra without any requirements to understand what the symbols or the operations are supposed to mean!

The latter is called **Abstraction**.

**Example**: The *Comma operator*

a , b

separates the ‘a’ from ‘b’ so it is not confused with ‘ab’ or in general separates the Right Hand Side (rhs) from Left Hand Side (lhs).

**Example**: The *Function* Sin

Sin(a)

computes the well known trigonometric function Sinus.

##### Words

A Word in an algebra is a sequence of concatenated symbols and functions and operators.

**Example**:

c = a + b

symbols c, =, a, +, and b are concatenated or sequenced into a string of letters or a word as the final ensemble.

##### Valid Words

Not all sequences of symbols in an algebra are Valid, indeed there is another ‘mechanical’ process of an algebra which qualifies a word either being Valid or Invalid.

**Example**:

a = b + 1 a valid word in algebra of arithmetic

1 +++, b an invalid word in algebra of arithmetic

#### Repeatability 

The first motivation and the last goal of an algebra is one and only one namely **Repeatability**:

<p class="callout success">If a set of symbols and operations manipulated by a person living in the 17th century was again manipulated by a person today, both efforts yield the same results!</p>

This is due to the fact that Algebra at its core construction is like unto an electromechanical entity that requires no intelligence to operate! Even a machine can carry out the same operations!

<p class="callout danger">Students need to be aware that being good at algebra or making proficient use of algebraic systems does not require any intelligence, rather requires skills and in particular skills in programming. A person being good at algebra is decided by their skills to manipulate symbols and with no reference to his/her level of intelligence.</p>

# Symbolic Computing

<p class="callout info">**What**: Concept of Symbolic Computing  
**Why**: Computing with symbols and non-numerals  
**Time To Complete**: 1 hour</p>

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)

#### Why?

As discussed in previous class notes, the nature of algebra is conducive to expand our abilities to understand and compute geometries.

Symbolic Computing, in part, is the very software engine that functions the said algebra’s symbols and expressions.

Therefore, naturally Symbolic computing goes hand in glove with algebra.

#### What? 

See simple example of use of Free Form language’s symbolic computing capabilities. Notice no numbers, all in symbols.

```diff
var1 = a + b;
var2 = a - b;

res = var1 * var2;

show res;

res2 = expand[var1 * var2];

show res2;

save as symbolics;


```

Output:

```diff
{
res  =  (a - b)*(a + b)
,
res2  =  a^2 - b^2
}
```

# Vector Arithmetic

# + and - operators

<p class="callout info">**What**: Addition and Subtraction of Vectors   
**Why**: Detailed computations   
**Time To Complete**: 2 hours </p>

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)  


#### +

```diff
//+ addition ;

v1 = {a,2,c}+{1,b,3};

show v1;

save as addition;
```

Output:

```diff
"v1" → {1 + a, 2 + b, 3 + c}
```

'**//**' : **Comment Operator** instructing the Grammarian to ignore its sentence

'**v1**' : identifier for a variable or **variable name**

'**=**': **Assignment Operator** copying the <span style="background-color: rgb(251, 238, 184);">Right Hand Side </span>to <span style="background-color: rgb(251, 238, 184);">Left Hand Side</span>

'**{ }**' : curly brackets, <span style="background-color: rgb(251, 238, 184);">enclosing</span> the list of elements in between

'**a,2,c**' : **Elements** of the vector enclosed in '{ }' brackets

'**;**' : **Delimiter** called semicolon indicating the end of a Free Form sentence, <span style="background-color: rgb(251, 238, 184);">separating</span> sentences

'**show**': textually displays the followed variables

'**save as**': instructs the Grammarian to save the Free Form script and all its interim computations in cloud objects

#### -

```diff
//- subtraction ;

v1 = {a,2,c}-{1,b,3};

show v1;

save as subtraction;
```

Output:

```
"v1" → {-1 + a, 2 - b, -3 + c}
```

#### Properties

##### 0-vector

```diff
//+ 0 ;

v1 =  {a,b,c}  + {0, 0, 0};

show v1;

save as subtraction;
```

Output:

```
"v1" → {a, b, c}
```

```diff
//- 0 ;

v1 =  {a,b,c}  - {0, 0, 0};

show v1;

save as subtraction;
```

Output:

```
"v1" → {a, b, c}
```

**<span style="color: rgb(230, 126, 35);">© 2012-Present CCN Studios</span>**

**<span style="color: rgb(230, 126, 35);">Creative Commons Attribution-NonCommercial-ShareAlike 4.0</span>**

# *: Scale Factor

<p class="callout info">**What**: Scale a vector  
**Why**: Computations to alter the length and direction of a vector  
**Time To Complete**: 1-3 hours</p>

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)

<span style="white-space: pre-wrap;">Multiply a vector by a numeral from the </span>**left**.

```
v  =  5.4 * {x,y};

show  v;

save as scale;
```

<span style="white-space: pre-wrap;">Multiply a vector by a numeral from the </span>**right**.

```
v  =   {x,y}*5.4;

show  v;

save as scale;
```

Output

```
"v" → {5.4*x, 5.4*y}
```

**u**<span style="white-space: pre-wrap;"> ought to be a variable/symbol or a numeral. </span>**u**<span style="white-space: pre-wrap;"> cannot be another vector.</span>

```
v  =  u * {a, b, c, d, e, f};

show  v;

save as scale;
```

Output

```
"v" → {a*u, b*u, c*u, d*u, e*u, f*u}
```

# Scale Factor < 0

<p class="callout info">**What**: Negative scale factor  
**Why**: How to reverse a vector to point in the opposite direction  
**Time To Complete**: 1-3 hours</p>

#### [![cc.png](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/cc.png)

```
v1  = {1,1};
v2 = -1*v1;

//list of pivots;
pivots = {{0,0}, {0,0}};

//list of vectors;
vectors = {v1,v2};

vectorplot pivots vectors;

save as scale;
```

Output

[![negative_scale.jpg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/negative-scale.jpg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/negative-scale.jpg)

# Lines

Definitions, constructions and utilities of lines.

# Spray a Line!!!

<p class="callout info"><span style="white-space: pre-wrap;"><b>What</b>: Sprinkle points along a 2D line and play  
<b>Why</b>: The equations and inequlities dealing with lines suddenly make better sense 
<b>How</b>: Get your eyes trained on reading math and code, by simply copy-paste one or few lines of the ff scripts below into new ff programs and use show or different plots to study the internal structures of the program.
<b>Time To Complete</b>: 6 hours </span></p>

<!--
comment
-->
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.en" target="_blank">
<img src="https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png" alt="Alt Text" width="20%" height="20%">

</a>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">**pts2** is your friend the Line! In 2D, any equation of the form <span style="background-color: rgb(251, 238, 184);">a&#42;x+b&#42;y + c = 0 </span> has solutions namely the x and y coordinates that satisfy the identity, namely lhs = rhs, line up along a fixed line specified by the three constants a, b and c. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">Pay attention to the function-call <span style="background-color: rgb(251, 238, 184);">color [{red, black,green}];</span> that sets a list of colors for three plots of points form pts1, pts2 and pts3. As you can see the black color corresponds to the second plot which is obtained from the pts2. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">The single line of function-call below: </span> 

<code><span style="color:purple" >pts2 = instance[linear == 0 and -5<x<5 and -5<y<5 , 50];</span></code>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">linear == 0</span> sets up an equation for 3&#42;x+2&#42;y-3 to be always 0. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">50</span> is the number of requested randomly generated solutions to the Line Equation 3&#42;x+2&#42;y-3 = 0. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">-5<x<5 and -5<y<5</span> indicates a rectangular region of the 2D plane to solve the Line Equation 3&#42;x+2&#42;y-3 = 0 for. </span> 

<p class="callout success">
<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">As you will learn in future we can alter that rectagular shape for much more intricate and exciting ones. </span></p>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">and</span> indicates both inequalities -5<x<5 and -5<y<5 to hold or be satisfied by the choice of x and y. </span>

```
//do not use the reserved word line, alter e.g. linear;

linear = 3*x+2*y-3;

//points residing on one side of the line;
pts1 = instance [linear < 0 and -5<x<5 and -5<y<5 , 50];

//points residing on the line;
pts2 = instance [linear == 0 and -5<x<5 and -5<y<5 , 50];

//points residing on the other side of the line;
pts3 = instance [linear > 0 and -5<x<5 and -5<y<5 , 50];

//make a list of colors corresponding to the points in each region;
color[{red, black,green}];

//show all points;
pointplot pts1 also pts2 also pts3;

save as line;
```

**Output**

[![line_less_equal_greater.jpg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/line-less-equal-greater.jpg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/line-less-equal-greater.jpg)

<p class="callout success"><span style="white-space: pre-wrap;"> Run the Free Form code again and you should each time get a different distribution of the scattered points.</p>

**Output**

[![line_less_equal_greater2.jpg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/line-less-equal-greater2.jpg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/line-less-equal-greater2.jpg)

# Implicit Line Equation

<span style="white-space: pre-wrap;">line </span>