Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main (){
- int a=2, b=4, n=20;
- double x=5.5, d=a, c[n], h, p=1, l1, l2=0, f[n];
- h=0.1;
- cin >> x;
- cout << "x" << "\t" << "y(x)"<<endl;
- for(int i=0; i<=n; i++){
- c[i]=d;
- f[i]=5*log10(d);
- d+=h;
- cout << fixed << setprecision(1) << c[i] << "\t" << fixed << setprecision(5) << f[i] << endl;
- }
- for(int j=0; j<=n; j++){
- for (int k=0; k<=n; k++){
- if (k!=j){
- p*=(x-c[k])/(c[j]-c[k]);
- }
- }
- l2+=f[j]*p;
- p=1;
- }
- l1=5*log10(x);
- if (x=2) {
- cout << "y(" << x << ")" <<endl;
- cout << fixed << setprecision(18) << l1 << "- Исходная функция" << endl << l1 << " -Лагранж ";
- }
- else
- {
- cout << "y(" << x << ")" <<endl;
- cout << fixed << setprecision(18) << l1 << "- Исходная функция" << endl << l2 << " -Лагранж ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement