Created
October 25, 2024 15:37
-
-
Save ncalm/91c9d2f2c12f1ba5a8b685b8f5726f41 to your computer and use it in GitHub Desktop.
This Excel LAMBDA function computes the finite difference of a vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
FINITE_DIFF function | |
array is a vector (one column or one row) | |
1) Check if array is a vector. If not, return #VALUE! | |
2) Multiply array by similarly sized array of {1, -1, ..., -1}. | |
3) REDUCE SUM over (2) | |
*/ | |
FINITE_DIFF = LAMBDA(array, | |
IF( | |
AND(ROWS(array)>1,COLUMNS(array)>1), #VALUE!, | |
REDUCE(,array * EXPAND(1, ROWS(array), COLUMNS(array), -1), SUM) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment