2
$\begingroup$

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]]}]};
$\endgroup$
2
  • $\begingroup$ Are you looking for Map? Table could also work. $\endgroup$
    – MarcoB
    Mar 12 at 17:37
  • $\begingroup$ Make your code more elegant, readable, and efficient: a = Range[5]; b = {0,2,4}. $\endgroup$ Mar 12 at 17:45

2 Answers 2

2
$\begingroup$
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}

$\endgroup$
1
  • $\begingroup$ Thanks! That's what I wanted $\endgroup$
    – blahblah
    Mar 12 at 17:52
1
$\begingroup$

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}
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.