I am working on a program that compares two curves (as a result of the output of a diode, therefore its voltage / current curve).
I want to calculate the area between these two curves (the BLUE curve is the first diode, and RED is the second).

There are 51 data points for each curve (they always have the same amount of data). What I'm doing at the moment is as follows:
public double CalculateArea(double[,] pin1, double[,] pin2)
{
double voltageArea = 0;
double currentArea = 0;
double max = 0;
double min = 0;
for (int i = 0; i < pin1.GetLength(0); i++)
{
max = Math.Max(Math.Abs(pin1[i, 0]), Math.Abs(pin2[i, 0]));
min = Math.Min(Math.Abs(pin1[i, 0]), Math.Abs(pin2[i, 0]));
voltageArea += max - min;
}
return voltageArea;
}
This code somehow works, bearing in mind that I am not doing anything with Current (vertical axis). If the result is close to 0, for example, 0.05, then the difference between the curves is imperceptible. But I'm sure this is not the right way, I don’t know at all what is the result of the method I wrote ... it seems the difference between the voltage points.
I really suggest if you can help me improve this method.