1. algebra problem

I'm having a problem understanding what must be an easy problem, but I can't see a way through it.

It relates to sequences in counting the number of corners, edges and middle panes in a square or rectangular of equal sized pieces. So with a 3x3 square, there are:
c e c............c - Corner panes
e m e........... e - Edge panes
c e c........... m - Middle panes

.......Corners...Edges...Middle
3x3.......4..........4.........1 - So it follows that:
3x4.......4..........6.........2 - If the width 'W' is variable, the sequence can be expressed as
3xW......4.......2w-2.....w-2

Doing the same for a 4 sides square:

.......Corners...Edges...Middle
4x4.......4..........8.........4 - So it follows that:
4x5.......4.........10........6 - If the width 'W' is variable, the sequence can be expressed as
4xW......4.........2w.....2w-4

My problem is how to express a formula when introducing a variable Height 'H' which would explain the sequence:

.......Corners...Edges...Middle
3xW.....4........2w-2.....w-2
4xW.....4.........2w......2w-4
5xW.....4........2w+2....3w-6
HxW....4..........??.........??

Any help would be appreciated. Thanks in advance.

2. Hello, Jazzy331!

A fascinating problem . . .

My problem is how to express a formula introducing $H$ which would explain the sequence:

. . $\begin{array}{|c|c|c|c|}\hline
H \times W& \text{Corners} & \text{Edges} & \text{Middle} \\ \hline
3\times W & 4 & 2(W-1) & 1(W-2) \\
4\times W & 4 & 2W & 2(W-2) \\
5\times W & 4 & 2(W+1) & 3(W-2) \\
\vdots & \vdots & \vdots & \vdots \\
H \times W & 4 & ?? & ?? \\ \hline \end{array}$

I think I found the H-formula for the Edges and Middles.

. . $\begin{array}{|c|c|c|c|}\hline
H \times W& \text{Edges} \\ \hline
{\color{red}3}\times W & 2(W{\color{red}-1}) \\
{\color{red}4}\times W & 2(W{\color{red}+0}) \\
{\color{red}5}\times W & 2(W{\color{red}+1}) \\
\vdots & \vdots \\
{\color{red}H} \times W & 2(W {\color{red}+ H-4)}\\ \hline \end{array}$

. . $\begin{array}{|c|c|c|c|} \hline
H \times W & \text{Middle} \\ \hline
{\color{red}3}\times W & {\color{red}1}(W-2) \\
{\color{red}4}\times W & {\color{red}2}(W-2) \\
{\color{red}5}\times W & {\color{red}3}(W-2) \\
\vdots & \vdots \\
{\color{red}H} \times W & {\color{red}(H-2)}(W-2) \\ \hline \end{array}$

3. Thanks Soroban - that's brilliant.

Is there a specific method of working to get me there?

I have followed the maths to test it and agree with the H-4 element on the Edges, but my problem with maths is always that I need to understand what I've done to get somewhere, otherwise it won't stick. Is it purely that the '1' in 5xW 2(w+1) resolves the h-4? If so, then I assume that the same would apply to the '3' in 5xW : 3(w-2) in the middles H-2 = 3.

But why does the expression of the formula work that way? Any thoughts?