math - Java plot values in a virtual graph and find the integral area. -


quick question. got 10 000 lines information. have 2 values on each line. line in format : (time , water speed). want use numerical integration solve how water passed sensor, i'm confused how go solving in java.

i assume graph nice, don't need graphical, maybe array-list trick.

any tips, hint , tricks appreciated.

you can use trapezoidal rule this: sort intervals time, calculate sum follows:

// assume time expressed using class time[] time = ... // assume water speed double, expressed in volume per unit of time. // further assume time units match units in denominator of water speed, // e.g. if speed in galons per minute, time unit minutes; // if speed in galons per second, time unit seconds, , on double[] speed = ...  double sum = 0; (int = 0 ; < time.length-1 ; i++) {     double deltat = time[i+1].subtract(time[i]).totimeunits();     // formula trapezoidal rule on non-uniform grid     sum += (speed[i]+speed[i+1])*deltat; } double totalflow = sum / 2; 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -