Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: joukaval
- *
- * Created on 12. lokakuuta 2011, 15:46
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- /*
- *
- */
- int main(int argc, char** argv) {
- double f = 0;
- double F = 0;
- double y = 0;
- double eps = 0.000001;
- double x = 1;
- if (x != 0.0)
- for (int i = 0; i < 100; i++) {
- f = (x * x);
- F = (2 * x);
- y = x - (f / F);
- printf("%i. iteraatio f: %f x: %f y: %f \n", i + 1, f, x, y);
- if (fabs(y - x) < eps)
- break;
- x = y;
- }
- x = 3;
- printf("toinen polynomi\n");
- if (x != 0.0)
- for (int i = 0; i < 100; i++) {
- f = (x * x)+(eps / 2);
- F = (2 * x);
- y = x - (f / F);
- //printf("ABC %f\n", y);
- printf("%i. iteraatio f: %f x: %f y: %f \n", i + 1, f, x, y);
- if (fabs(y - x) < eps)
- break;
- x = y;
- }
- return (EXIT_SUCCESS);
- }
Add Comment
Please, Sign In to add comment