# Numerics & List Manipulation:ListCorrelate: yield $\{-f1 + f2, \dots, -f2 + f4, \dots\}$ from $\{f1, f2, f3, f4, f5\}$

The command

 ListCorrelate[{-1, 1}, {f1, f2, f3, f4, f5}]


yields

{-f1 + f2, -f2 + f3, -f3 + f4, -f4 + f5}

is there any simple way to get

{-f1 + f2, -f1 + f3, -f2 + f4, -f3 + f5, -f4 + f5}

using ListCorrelate or similar command? I need it to approximate derivative in numerical integration. Also interested in itself as list-manipulating technique.

Thanks in advance for any help.

• Sorry, I cannot find a pattern in the desired output that you describe. Would you please add some detail? – Henrik Schumacher Dec 3 '18 at 21:43

ListCorrelate[{-1, 0, 1}, {f1, f2, f3, f4, f5}, {2, 2}, "Fixed"]


{-f1 + f2, -f1 + f3, -f2 + f4, -f3 + f5, -f4 + f5}

You can use ArrayPad to extend your list, and use the kernel {-1, 0, 1}:

list = {f1, f2, f3, f4, f5};

ListCorrelate[{-1, 0, 1}, ArrayPad[list, 1, "Fixed"]]


{-f1 + f2, -f1 + f3, -f2 + f4, -f3 + f5, -f4 + f5}

• What is the functionality of {2, 2}, "Fixed"] ? – user61386 Dec 4 '18 at 7:36
• Also: which is the right way of citing Mathematica output in a question? – user61386 Dec 4 '18 at 7:43