c语言编写中点法求数值微分?跟着小编一起来看一看吧!

c语言编写中点法求数值微分?牛顿法解方程题目要求:,我来为大家讲解一下关于c语言编写中点法求数值微分?跟着小编一起来看一看吧!
c语言编写中点法求数值微分
牛顿法解方程
题目要求:
应用牛顿法解方程:
#include "stdio.h"#include "math.h"float func(float x){return pow(x,4) pow(x,3) 1;}float x(float a,float b,int k){return a k*(b-a)/4;}float ING(float a,float b){return ((b-a)/90)*(7*func(x(a,b,0)) 32*func(x(a,b,1))12*func(x(a,b,2)) 32*func(x(a,b,3)) 7*func(x(a,b,4)));}main(){float a,b;printf("Please input the low & high limitation and the accuracy\n");printf("Low limitation:");scanf("%f",&a);printf("High limitation:");scanf("%f",&b);printf("The result of integration is %f",ING(a,b));getche();}
运行结果:
运行结果
欧拉方法求解微分方程
题目要求:
已知微分方程的初值问题如下:
求y(1)的值。
#include "stdio.h"#include "math.h"double SQRT(double a){/*迭代法开方运算*/double xx = a,x = 0.0; /*迭代初值*/while(fabs(xx - x)>0.00001){x = xx;xx = 0.5*(xa / x) ;}return xx;/*返回迭代结果*/}main(){double a,r;printf("Please input a digit for squart\n");scanf("%lf",&a);r = SQRT(a);printf("Sqrt(%f) = %f\n",a,r);getche();}
运行结果:
运行结果
