Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- // calculate product to 1000 terms
- static double product(double x) {
- double result = 1.0;
- double pi2 = Math.PI * Math.PI; // pi squared
- for (int n = 1; n < 1000; n++) {
- result *= (1 - x * x / (n * n * pi2));
- }
- return result;
- }
- public static void main(String[] args) {
- for (double x = 0.1; x<3; x+=0.1) // a range of x values, in radians
- {
- double lhs = Math.sin(x) / x;
- double rhs = product(x);
- System.out.printf("x = %8f, LHS = %8f, RHS = %8f \n",x,lhs,rhs);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment