## 1. Affine transformation

Where $(u,v)$ is the new coordinate and $(x,y)$ is the old coordinate.

The APL code mapping an image by this transformation is like:

` |`` affine←{`

|` ⍝ affine transformation`

|` ⎕IO←0 ⋄ s←⍴⍵`

|` g←¯1↓⍉⌊0.5+⍺+.×⍤2 1⊢1,⍨⍉s⊤⍳×/s`

5 |` m←∧⌿(s>⍤0 1⊢g)∧0<g`

|` s⍴(0,,⍵)[m×1+s⊥g]`

|` }`

## 2. Solve linear equations

For coefficient matrix $A$, variable matrix $X$ and constant matrix $B$, then

Then the APL code is just `(⌹A)+.×B`

, or even
simpler, `B⌹A`

. As the APL2 specification writes:

If

`Z←L⌹R`

is executable,`Z`

is determined to minimize the value of the least squares expression:`|`

`+/,(L-R+.×Z)*2`

In J the matrix division is `B %. A`

. Note that, if
possible, using exact number can produce more accurate result.

## 3. Norm in ${\u2102}^{n}$

The norm of inner product space, $\Vert \stackrel{\u203e}{a}\Vert =\sqrt{\u27e8\stackrel{\u203e}{a},\stackrel{\u203e}{a}\u27e9}$, is:

` |``2*∘÷⍨+.×⍨`

## 4. Use linear transformation to define polynomial functions

Due to the "superposition" principle, for ${\mathbb{P}}_{4}$ that basis $B=[1,x,{x}^{2},{x}^{3}]$, $L(p)={x}^{\prime}+{x}^{\prime \prime}$ find $M$ that $[L(p){]}_{B}=M{\left[p\right]}_{B}$.

Then M is just:

This may comes handy when some extent of symbolic computation is needed.

## 5. Determinant, Generalized

There is already a general determinant from APLcart.info. However, I am not able to explain the mathematics behind it. I could only tell it involves taking the matrix product of upper matrix and diagonal replaced by accumulative sum minus the total sum and itself, negate it, and repeat with the result. Sorry, so far I am only familiar with cofactor expansion method

Actually, Iversion had assigned a
special combinator for determinant: monadic `-.×`

. This
would not work in most of today's APL implementations, but there is
the similar operator in J. Since he has recorded the definition, we
are still able to figure out what it means.

Let's first review the cofactor expansion method with a 3 by 3 matrix:

Then, here is a play on trick of visualizing the method in
APL(`⎕IO←0`

and remember the evaluation order in
APL):

```
⎕←perm←3 6⍴0 0 1 1 2 2 1 2 2 0 0 1 2 1 0 2 1 0
0 0 1 1 2 2
1 2 2 0 0 1
2 1 0 2 1 0
(⊣,'-',⊢)/(⊣,'×',⊢)/1 0 1⍉(3 3⍴'abcdefghi')[perm;]
┌───────────────────────────────────┐
│a×e×i-a×h×f-d×h×c-d×b×i-g×b×f-g×e×c│
└───────────────────────────────────┘
```

Now, the only problem left is what is `perm`

? It is not the unique index value since any
permutation that can correctly arrange the parity should work.

According to Iverson, matrix determinant can be characterized as:

` |`` det ← {-/×/1 0 1⍉⍵[perm⍴⍵;]}`

|` mod ← {0=⊃⍴⍵:⍵ ⋄ ⍵[0;],[0]Z+⍵[(1↑⍴Z)⍴0;]≤Z←∇ 1 0↓⍵}`

|`perm ← {(mod Z)[;(⍳⍴P)+P-(⍴P←2|+⌿Z←rep ⍵)⍴0 1]}`

|` rep ← {(⊢⊤(⍳×/))⌽1+⍳1↑⍵}`

Replacing `-`

and `×`

by other functions
can give other interesting results, but that would not be covered
here. A similar implementation in Dyalog can be found at dfns.

## Bibliography

[Iverson] Two combinatoric operators

. . Proceedings of the eighth
international conference on APL. 22 September 1976. G Truman Hunter. 233–237. Association
for Computing Machinery. New York, NY, United
States. doi:10.1145/800114.803681.

[dfns] Alternant. . https://dfns.dyalog.com/n_alt.htm.