lrobbo314
Well-known Member
- Joined
- Jul 14, 2008
- Messages
- 3,957
- Office Version
- 365
- Platform
- Windows
CONVOLUTION returns the convolution of 2 sets of numbers. I was watching a 3Blue1Brown video where they explain the process and I thought it would be fun to come up with a lambda for it. The 2 sets of numbers should be vertical ranges with the same amount of cells in each range. In the example below, there is matrix multiplication being done to the 2 sets, and the result is the addition of the diagonals, which are color coded.
CONVOLUTION | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | 4 | 5 | 6 | Element | Math | Result | Set1 | Set2 | Convolution | |||||
2 | 1 | 4 | 5 | 6 | 1 | 1*4 | 4 | 1 | 4 | 4 | ||||
3 | 2 | 8 | 10 | 12 | 2 | 1*5+2*4 | 13 | 2 | 5 | 13 | ||||
4 | 3 | 12 | 15 | 18 | 3 | 1*6+2*5+3*4 | 28 | 3 | 6 | 28 | ||||
5 | 4 | 2*6+3*5 | 27 | 27 | ||||||||||
6 | 5 | 3*6 | 18 | 18 | ||||||||||
Sheet6 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
L2:L6 | L2 | =CONVOLUTION(J2:J4,K2:K4) |
Dynamic array formulas. |
Excel Formula:
=LAMBDA(set_1,set_2,
LET(
a,set_1,
b,set_2,
c,COUNTA(a),
MAP(
SEQUENCE(c*2-1,,-c+1),
LAMBDA(x,
LET(
sx,DROP(SEQUENCE(,c),,x),
cx,COUNTA(sx),
rx,INDEX(sx,SEQUENCE(,cx,cx,-1)),
SUM(INDEX(a,sx)*INDEX(b,rx))
)
)
)
)
)
Last edited:
Upvote
0