Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- double sum(int k, double x);
- int main()
- {
- int k = 1;
- for(double i = -0.5 ; i <-0.1 ; i+=0.1){
- k = 1;
- while(abs(sum(k, i)-sum(k+1, i))<0.001)
- k++;
- cout<<i<<" "<<k<<" "<<sum(k, i)<<endl;
- }
- for(double i = 0.1 ; i <=0.5 ; i+=0.1){
- k = 1;
- while(abs(sum(k, i)-sum(k+1, i))<0.001)
- k++;
- cout<<i<<" "<<k<<" "<<sum(k, i)<<endl;
- }
- return 0;
- }
- double sum(int k, double x){
- double totalSum = 0;
- double a, b;
- for(double i = 1 ; i<=k ; i++){
- a = pow(-1, i+1)/i;
- b = (pow(-1, i)*6)/(pow(i,3)*pow(M_PI,2));
- totalSum += (a+b)*sin(i*M_PI*x);
- }
- return totalSum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement