Advertisement
Guest User

Chebyshev

a guest
Mar 21st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cfloat>
  3. #include <vector>
  4. #include <math.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11. int main() {
  12.  
  13.     double a{-10.0}, b{10.0}, n{10.0};
  14.  
  15.     vector<double> nodeValue(n+1);
  16.     vector<double> functionValue(n+1);
  17.  
  18.     cout << "Nodal points: " << endl;
  19.     for(double i=0; i<=n; i++){
  20.         double nom = (2.0 * i + 1.0) * 3.14159;
  21.         double denom = 2.0 * n + 2.0;
  22.         nodeValue[i] = cos(nom/denom);
  23.         cout << nodeValue[i] << endl;
  24.     }
  25.  
  26.     cout << endl << "Values of the functional: " << endl;
  27.     for(double i=0; i<=n; i++){
  28.         functionValue[i] = nodeValue[i] / 2.0 * (b - a) + a + b;
  29.         cout << functionValue[i] << endl;
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement