How to divide one list by another?

I have two lists which I generated from two plots.

list1 = Cases[
Cases[InputForm[plot1], Line[___],
Infinity], {_?NumericQ, _?NumericQ}, Infinity];

list2 = Cases[
Cases[InputForm[plot2], Line[___],
Infinity], {_?NumericQ, _?NumericQ}, Infinity];

Now I want to divide the list1 by list2 and then plot this resulting list3 vs. x. Can anyone please help me with this?

• Please format the post an place all code in a code block. Make sure that the code can be copied back into Mathematica intact. Click edit above, then if you need help click the ? button in the editing toolbar. Sep 5 '16 at 8:39
• If the lists are of equal length, then the division operator / works as expected. Sep 5 '16 at 8:43
• Just a comment: list division only makes sense if both lists are on the same x-grid. Sep 5 '16 at 10:57
• Yes, they are on the same grid. Sep 5 '16 at 11:48

The problem here is that list1 and list2 will not be on the same gridding (i.e. at the same x positions}. So the general approach is to convert the lists into interpolation functions and divide the two.

plot1 = Plot[Sin[x], {x, 0, 10}];
plot2 = Plot[x, {x, 0, 10}];
list1 = Cases[
Cases[InputForm[plot1], Line[_],
Infinity], {_?NumericQ, _?NumericQ}, Infinity];
list2 = Cases[
Cases[InputForm[plot2], Line[_],
Infinity], {_?NumericQ, _?NumericQ}, Infinity];

Unequal lengths:

Length[list1] == Length[list2]
<* Out[] = False *>

inter1 = Interpolation[list1];
inter2 = Interpolation[list2];
Plot[inter1[x]/inter2[x], {x, 0, 10}] • Thanks a lot Markus! Interpolation solved my problem! The problem was that the lists were not of same size and that's why simple divide function "/" was not working. Sep 5 '16 at 10:23