waltermilner

Untitled

Apr 2nd, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. public class Test {
  2.  
  3.   static double integral()
  4.   {
  5.     final double topLimit=Math.PI/4;
  6.     final double bottomLimit=0;
  7.     final int steps=10000;
  8.     final double h=(topLimit-bottomLimit)/steps;
  9.     final double h2 = h/2;
  10.     double sum=0;
  11.     for (double x=bottomLimit; x<topLimit; x+=h)
  12.     {
  13.       double xx=x+h2; // midpoint
  14.       double y=(xx*xx)/(Math.sin(xx)*Math.sin(xx));
  15.       sum+=y*h;
  16.     }
  17.     return sum;
  18.    
  19.   }
  20.  
  21. public static void main(String[] args) {
  22. System.out.println(integral());
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment