Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <complex.h>
- #include <float.h>
- #include <math.h>
- #include <stdio.h>
- static inline complex double f(complex double z) {
- return z * z + 5 * z + 7;
- }
- static inline complex double df(complex double z) {
- return 2 * z + 5;
- }
- int main(void) {
- for (int i = -10; i <= 10; ++i) {
- for (int j = -10; j <= 10; ++j) {
- if (i == 0 || j == 0) {
- continue;
- }
- int c = 0;
- complex double z0 = i / 10. + j / 10. * I;
- complex double z = z0 - f(z0) / df(z0);
- for (; fabs(z - z0) > DBL_EPSILON;
- ++c, z0 = z, z = z0 - f(z0) / df(z0)) {
- ;
- }
- printf("z = %f %+f * I, c = %d, z0 = %f %+f * I\n",
- creal(z), cimag(z), c, i / 10., j / 10.);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement