# How to get different items in a list to interact to get a result?

I have two lists, for example (the real lists are much longer):

list1 = {1, 2, 3, 4, 5, 6, 7};
list2 = {9, 10, 11, 12, 13, 14, 15};


I want to create a single list by adding together different elements from different places in each list. For example,

list3 = (list1i+1 + list1i-1) * (list2i+1 + list2i-1)

where $i$ is the location of the number in the list, e.g. in list2, 12 would be $i=4$. I realize the first and last entries in list3 would either be wrong or non-existent. For example, the 2nd item in list3 would be $(3+1)(11+9)$ and the 3rd item would be $(4+2)(12+10)$.

I hope that makes sense and I appreciate any help.

• What do you expect for the first element in list3? Oct 30, 2013 at 16:28

This will do it:

(list1[[3 ;;]] + list1[[;; -3]]) (list2[[3 ;;]] + list2[[;; -3]])


{80, 132, 192, 260, 336}

The smallest value of i has to be 2, and therefore list1[3;;]] represents all values the list of i+1 can assume. Similarly for i-1. The syntax is explained in the documentation for Part.

• list1[[;; Length[list1] - 2]] can be written as list1[[;; -3]] Oct 30, 2013 at 16:20
• @SimonWoods Ty. Oct 30, 2013 at 16:21

Or this:

Times @@ (ListCorrelate[{1, 0, 1}, #, {2, -2}, 0] & /@ {list1, list2})

(* {20, 80, 132, 192, 260, 336, 84} *)


Another way of doing it

list3 = (RotateLeft[list1]+RotateRight[list1])*(RotateLeft[list2]+RotateRight[list2])