Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define eps 1e-6
- #define dx 1e-8
- double f(double x)
- {
- return (x*x*x - 2*x*x - 11*x + 12);
- }
- double df(double x)
- {
- return (3*x*x - 4*x - 11);
- }
- int main(void)
- {
- double x,delta,y;
- int i;
- for (double x0=2.3528 ; x0>1e-4 ; x0=x0-5e-2)
- {
- x=x0;
- do
- {
- y=x;
- x=x-f(x)/df(x);
- delta=(x-y);
- } while (delta>eps);
- printf("%lf \t %lf \t %lf \n",x0,x,f(x)); // bacia de atração
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement