Advertisement
Guest User

qqqqq

a guest
Oct 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. int main (){
  6. int a=2, b=4, n=20;
  7. double x=5.5, d=a, c[n], h, p=1, l1, l2=0, f[n];
  8. h=0.1;
  9. cin >> x;
  10. cout << "x" << "\t" << "y(x)"<<endl;
  11. for(int i=0; i<=n; i++){
  12. c[i]=d;
  13. f[i]=5*log10(d);
  14. d+=h;
  15. cout << fixed << setprecision(1) << c[i] << "\t" << fixed << setprecision(5) << f[i] << endl;
  16. }
  17. for(int j=0; j<=n; j++){
  18. for (int k=0; k<=n; k++){
  19. if (k!=j){
  20. p*=(x-c[k])/(c[j]-c[k]);
  21. }
  22. }
  23. l2+=f[j]*p;
  24. p=1;
  25. }
  26. l1=5*log10(x);
  27. if (x=2) {
  28. cout << "y(" << x << ")" <<endl;
  29. cout << fixed << setprecision(18) << l1 << "- Исходная функция" << endl << l1 << " -Лагранж ";
  30. }
  31. else
  32. {
  33. cout << "y(" << x << ")" <<endl;
  34. cout << fixed << setprecision(18) << l1 << "- Исходная функция" << endl << l2 << " -Лагранж ";
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement