Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALG 1 METODA NEWTON PT F(X)=0
- #include <iostream>
- #include <math.h>
- #include <conio.h>
- using namespace std;
- #define ITMAX 100
- double error = 0.0001;
- double f1(double x) {
- return x * exp(x) - 1;
- }
- double f2(double x) {
- return exp(x) + x * exp(x);
- }
- int main() {
- int n = 1;
- double x = 0;
- while (fabs(f1(x)) > error && n <= ITMAX) {
- x = x - ( f1(x) / f2(x) );
- n = n + 1;
- }
- if (n > ITMAX) {
- cout << "In " << n << " iterati nu a fost realizata aproximarea dorita." << endl;
- } else {
- cout << "Aproximarea dorita este: " << x << endl;
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement