daily pastebin goal
3%
SHARE
TWEET

Lul

a guest Dec 16th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double sum(int k, double x);
  8.  
  9. int main()
  10. {
  11.     int k = 1;
  12.     for(double i = -0.5 ; i <-0.1 ; i+=0.1){
  13.         k = 1;
  14.         while(abs(sum(k, i)-sum(k+1, i))<0.001)
  15.             k++;
  16.         cout<<i<<" "<<k<<" "<<sum(k, i)<<endl;
  17.     }
  18.     for(double i = 0.1 ; i <=0.5 ; i+=0.1){
  19.         k = 1;
  20.         while(abs(sum(k, i)-sum(k+1, i))<0.001)
  21.             k++;
  22.         cout<<i<<" "<<k<<" "<<sum(k, i)<<endl;
  23.     }
  24.  
  25.     return 0;
  26. }
  27.  
  28.  
  29. double sum(int k, double x){
  30.     double totalSum = 0;
  31.     double a, b;
  32.     for(double i = 1 ; i<=k ; i++){
  33.         a = pow(-1, i+1)/i;
  34.         b = (pow(-1, i)*6)/(pow(i,3)*pow(M_PI,2));
  35.         totalSum += (a+b)*sin(i*M_PI*x);
  36.     }
  37.     return totalSum;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand