# Do one calculation over the whole list [closed]

I am trying to calculate the numerical residue of the function, but I want to perform it at the whole list and as a return. For example, let's take

a = Table[q, {q, 1,5,1}];
b = Table[2 q, {q,0,2,1}];


Now, I want to get the residue list, where a is some parameter and bis the position. For the one value I could do

NResidue[a[[1]]/x, {x, b[[1]]}].


What I want is a list, that contains

Res = {NResidue[a[[1]]/x, {x, b[[1]]}], NResidue[a[[2]]/x, {x, b[[2]]}], ...,
NResidue[a[[5]]/x, {x, b[[5]]}]};

• Are you looking for Map? Table could also work. Mar 12 at 17:37
• Make your code more elegant, readable, and efficient: a = Range[5]; b = {0,2,4}. Mar 12 at 17:45

a = Table[q, {q, 1, 5, 1}];

b = Table[2 q, {q, 0, 2, 1}];

Table[Residue[a[[i]] / x, {x, b[[i]]}], {i, Length @ b}]


{1, 0, 0}

• Thanks! That's what I wanted Mar 12 at 17:52

For a result of Residue[a[[i]]/x, {x, b[[i]] and and b need to have the same length. Then the command ""MapThread" will do what you want. E.g.:

a = Table[q, {q, 1, 3}];
b = Table[2  q, {q, 0, 2}];
MapThread[Residue[#1/x, {x, #2}] &, {a, b}]

{1, 0, 0}