Advertisement
Guest User

WIELOPUNKTOWA

a guest
Dec 1st, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. //WIELOPUNKTOWA
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. double rownanie(double x);
  6. double pochodna(double x);
  7. double wzor(double x);
  8. int main()
  9. {
  10. cout<<"Wielopunktowa"<<endl;
  11. double x,e,h;
  12. int l=0;
  13. cout<<"Podaj x: ";cin>>x;cout<<endl;
  14. cout<<"Podaj e: ";cin>>e;cout<<endl;
  15. do
  16. {
  17. h=wzor(x);
  18. x=x+h;
  19. l++;
  20. }while(fabs(h)>=e);
  21. cout.precision(16);
  22. cout<<"Punkt: "<<x<<endl;
  23. cout<<"Ilosc krokow: "<<l<<endl;
  24. //cout<<"Blad: "<<fabs(x-)/fabs(x)<<endl;
  25. return 0;
  26. }
  27.  
  28. double rownanie(double x)
  29. {
  30. return (x*(exp(x)))-pow(x,2.);//e
  31. }
  32.  
  33. double pochodna(double x)
  34. {
  35. return (exp(x)*(x+1))-(2*x);
  36. //return x*((exp(x))*x*(x+3.)-2.);
  37. }
  38.  
  39. double wzor(double x)//5
  40. {
  41. double u=rownanie(x)/pochodna(x);
  42. return -((u/(1.*(2.*pochodna(x)))*(3.*pochodna(x)-pochodna(x-u))));
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement