Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- double funkcja(double x)
- {
- return 2 * x - sin(x) + 4 * cos(3 * x*x);
- }
- double pochodna(double x)
- {
- return 2 - cos(x) - 24 * x*sin(3 * x*x);
- }
- int main()
- {
- double a, b,E;
- cout << "Podaj przedzial: "<<endl;
- cin >> a;
- cin >> b;
- cout << "Podaj dozwolone przyblizenie: ";
- cin >> E;
- cout << "Metoda Newtona (stycznych): ";
- double tmp = a;
- while (true)
- {
- cout << tmp << " " << funkcja(tmp) << endl;
- if (abs(funkcja(tmp)) < E)
- {
- cout << "Rozwiazaniem rownania jest: " << tmp;
- break;
- }
- double a = tmp;
- tmp =a- funkcja(a) / pochodna(a);
- }
- cout << "Metoda siecznych: ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement