hyqd.net
当前位置:首页 >> 编写程序,用牛顿迭代法求方程F(x)= x^3+4x^2%8=0 >>

编写程序,用牛顿迭代法求方程F(x)= x^3+4x^2%8=0

#include <stdio.h>#include <math.h> int main() { double x1 = 1, x2; do { x2 = x1; x1 = x2 - (x1*x1*x1 + 4*x1*x1 - 8) / (2*x1*x1 + 8*x1); } while(fabs(x1-x2) > 1e-4); printf("%f", x1); }

#include int main(){ double x1 = 1, x2; do { x2 = x1; x1 = x2 - (x1*x1*x1 + 4*x1*x1 - 8) / (2*x1*x1 + 8*x1); } while(fabs(x1-x2) > 1e-4); printf("%f", x1);}

#include"stdio.h"#include"math.h"int m;float f(float x) /*求f(x)= x^3/2+2x^2-8的函数值*/{ float y; y=0.5*x*x*x-2*x*x-8; return y;} float f1(float x) /*求f(x)的导函数的值*/{ float y; y=1.5*x*x-3; return y;} float newton_dd(float x0,float e){ int i; float p,p1,x; for

#include main() {float x,x0,f,f1; x=1.5; do {x0=x; f=x0*x0*(x0+4)-10; f1=x0*(3*x0+8); /* f的导数,即它的切线 */ x=x0-f/f1; /* 切线与x轴的交点 */ } while(fabs(x-x0)>=1e-5); printf("The root is %8.7f\n",x); }

2x-4x+3x-6=0(2x-4x)+(3x-6)=02x(x-2)+3(x-2)=0(x-2)(2x+3)=0x1=22x+3=02x=-3x=-3/2x=±√6i/2

你把x=1.2写在循环外边,就是上边.就可以.

'题库的标准答案:private sub form_activate() x1 = 2 do x0 = x1 f = 3 * x0 ^ 3 - 4 * x0 ^ 2 - 5 * x0 + 13 f1 = 9 * x0 ^ 2 - 8 * x0 - 5 x1 = x0 - f / f1 loop until abs(x1 - x0) 评论0 0 0

#include "stdio.h"int main(int argc,char *argv[]){ double x,t; for(x=2.3;x<=2.7;x+=0.00000001) if((t=3*x*x*x-4*x*x-5*x-13)>-0.000001 && t<0.000001){ printf("x ≈ %g\n",x); break; } if(x>2.7) printf("There is no solution\n"); return 0;}

#include"stdio.h"//#include"conio.h"#include"math.h" float fun(float x) { return (x*x*x+4*x*x-10); } float xpoint(float x1,float x2) { return (x1+x2)/2; } float root(float x1,float x2) { float x,y,y1,y2; y1=fun(x1); printf(""); y2=fun(x2); do {x=xpoint(x1,x2);

你好!问题不清 如有疑问,请追问.

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.hyqd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com