Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- static double integral()
- {
- final double topLimit=Math.PI/4;
- final double bottomLimit=0;
- final int steps=10000;
- final double h=(topLimit-bottomLimit)/steps;
- final double h2 = h/2;
- double sum=0;
- for (double x=bottomLimit; x<topLimit; x+=h)
- {
- double xx=x+h2; // midpoint
- double y=(xx*xx)/(Math.sin(xx)*Math.sin(xx));
- sum+=y*h;
- }
- return sum;
- }
- public static void main(String[] args) {
- System.out.println(integral());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment