# Plotting and Finding Area for Discrete Points

I want to plot a graph for following coordinates and then I want to find the area from x = 900 to 1600. What is the correct path to find the area of that limit?

x={800.,806.,812.,818.,824.,830.,836.,842.,848.,854.,860.,866.,872.,878.,884.,890.,896.,902.,908.,914.,920.,926.,932.,938.,944.,950.,956.,962.,968.,974.,980.,986.,992.,998.,1004.,1010.,1016.,1022.,1028.,1034.,1040.,1046.,1052.,1058.,1064.,1070.,1076.,1082.,1088.,1094.,1100.,1106.,1112.,1118.,1124.,1130.,1136.,1142.,1148.,1154.,1160.,1166.,1172.,1178.,1184.,1190.,1196.,1202.,1208.,1214.,1220.,1226.,1232.,1238.,1244.,1250.,1256.,1262.,1268.,1274.,1280.,1286.,1292.,1298.,1304.,1310.,1316.,1322.,1328.,1334.,1340.,1346.,1352.,1358.,1364.,1370.,1376.,1382.,1388.,1394.,1400.,1406.,1412.,1418.,1424.,1430.,1436.,1442.,1448.,1454.,1460.,1466.,1472.,1478.,1484.,1490.,1496.,1502.,1508.,1514.,1520.,1526.,1532.,1538.,1544.,1550.,1556.,1562.,1568.,1574.,1580.,1586.,1592.,1598.,1604.,1610.,1616.,1622.,1628.,1634.,1640.,1646.,1652.,1658.,1664.,1670.,1676.,1682.,1688.,1694.,1700.};
y={-0.00980972,0.00596186,0.00320024,0.017615,0.0547168,0.125684,0.276787,0.527948,0.829944,1.17031,1.4657,1.68395,1.81435,1.91029,1.97689,2.02305,2.03924,2.03904,2.03102,2.0087,1.9725,1.9331,1.86772,1.77735,1.66471,1.52289,1.38746,1.30563,1.27323,1.2572,1.24907,1.25349,1.22443,0.878296,0.358731,0.0529058,0.00220616,0.000495293,0.00128713,0.000158159,0.000778224,0.000460337,0.00133076,0.000300823,0.00029283,-0.0000828929,0.0000972822,0.000686283,-0.000742008,0.000194488,0.000921523,-0.00146594,0.000053367,-0.000239026,0.000202174,0.000706058,0.000469258,0.000197252,0.000162217,-0.000248154,0.000637709,-0.00052446,-0.000446398,0.000555572,0.00021992,-0.0000185739,0.000136337,-0.0000124176,0.000122421,0.000410419,0.00105847,0.00104981,0.00047304,0.00041979,0.000458166,0.000154253,0.000337662,-0.00120741,0.00028321,-0.000727188,-0.000417686,0.000135295,0.00041505,-0.000239,0.0000504985,0.000178334,-0.00015944,0.000463088,-0.000362963,0.000161397,-0.000708732,0.00045645,0.000822545,-0.000786351,0.00049991,-0.000679102,0.000462613,-0.000733844,0.000205055,0.0000957599,0.000869528,0.000882746,-0.000184393,0.000133353,0.000736523,-0.000376716,0.00154824,0.000168738,0.0000807096,-0.000216217,0.000653628,0.000489561,0.0000312046,0.00037852,0.00122543,-0.000124153,-0.000220213,0.000487884,0.0000324179,0.00129615,0.000500315,0.000398828,0.000655162,-0.00100403,0.000286067,0.000883019,0.000603403,-0.0000923475,0.000687423,-0.0000863789,-0.000432297,0.000339196,0.0000116848,0.00157237,0.000902373,0.0000770988,0.00146481,0.00044311,0.00146225,0.0010733,0.00345731,0.00212854,0.00117682,-0.00109278,0.000587325,0.00284339,0.00467152,0.00747574,0.0105482,0.0181444,0.0250546};
g = Thread[{x, y}];
graph1 = ListLinePlot[g, AxesLabel -> {Wavelength, Intensity}, AxesOrigin -> {200, -0.002}, PlotRange -> All]

• Have you seen Interpolation[]? – J. M. will be back soon Oct 12 '18 at 3:08
• f = Interpolation[Transpose[{x, y}]]; – Bob Hanlon Oct 12 '18 at 3:28
• Thank you. What does it mean? Could you give me a correct code for finding the area? – Tharaka Oct 12 '18 at 4:32
• You should be able to use Integrate[] on the result of Interpolation[]; have you seen the docs? – J. M. will be back soon Oct 12 '18 at 4:36
• I did not get it. It does not give the answer. Could you tell me the correct code? – Tharaka Oct 12 '18 at 4:47

## 1 Answer

From @J.M.issomewhatokay and @BobHanlon after

f = Interpolation[Transpose[{x, y}]];


use

NIntegrate[f[x], {x, 800, 1700}]


to get

258.438


Actually, in the spirit of how a definite integral is constructed, one can just approximate it by using

6 Total[y]

258.464


or

6 Total@MovingAverage[y, 2]
Differences[x].MovingAverage[y, 2]

258.419


where, 6 comes from the result of Differences[x].

• See here for other ways to implement the trapezoidal rule. – J. M. will be back soon Oct 12 '18 at 5:36
• @J.M.issomewhatokay. Thx a lot for the information. – Αλέξανδρος Ζεγγ Oct 12 '18 at 7:22
• Thank you very Much. – Tharaka Oct 12 '18 at 14:46