Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. double a,b,c,eps,c1, e, x, m, M,x1;
  4. int i,n,k;
  5. bool u;
  6. double f (double x)
  7. {
  8. return pow(x,4)-2*pow(x,2)-3;
  9. }
  10.  
  11. double f1(double x){
  12. return 4*pow(x,3)-4*x;
  13. }
  14.  
  15.  
  16. void tang(double a, double b, double eps, double m1, double m2) {
  17. int k5=0;double x,x1,c=0;
  18. c = (a * f(b) - b * f(a))/(f(b)-f(a));
  19. if (f(a)*f(c)>0) { x = b;
  20. } else { x = a;
  21. }
  22. do {
  23. x1=x;
  24. x = x1 - f(x1)/f1(x1);
  25. k5++;
  26.  
  27.  
  28. }while(((m1*pow((x-x1),2))/(2*m2))>=eps);
  29. cout << " c : " << fixed << setprecision(15) << x << " f(c) : " << fixed << setprecision(15) << f(x) << " n : " << k5 << endl;
  30.  
  31.  
  32. }
  33.  
  34. int main(){
  35. a=-2; b=-1;
  36. cout<<"a : "<<a<<" "<<" b : "<<b<<endl;
  37. m=pow(10,-15);
  38.  
  39. eps=pow(10,-15);
  40.  
  41. cout<<"tangenta aposteriori"<<endl;
  42. tang(a,b,eps,44,m);
  43. int a=1,b=2;
  44. cout<<"a : "<< a<<" "<<" b : "<<b<<endl;
  45. cout<<"tangenta aposteriori"<<endl;
  46. //tang(1.5,b,eps,44,7.5);
  47. m=pow(10,-15);
  48. tang(a,b,eps,44,m);
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement