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.