Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- float f(float); // Function
- float ff(float); //1st Derivative
- float nut(void);
- int main() {
- float z;
- z=nut();
- printf("Koren' yravneniya: x=%.10f\n\n",z);
- }
- float f(float x) {
- return x*x*cos(3.0*x)+0.5;
- }
- float ff(float x) {
- return 2*x*cos(3.0*x)-3*x*x*sin(3.0*x);
- }
- float nut() {
- float x,xx,e;
- printf("Vvedite x0, eps:\n");
- scanf("%f%f",&x,&e);
- while(true) {
- xx=x-f(x)/ff(x);
- //printf("x=%.10f\n",xx);
- if(fabs(f(xx))<e) break;
- x=xx;
- }
- return xx;
- }
Advertisement
Add Comment
Please, Sign In to add comment