矩形法求定积分的公式(求解低阶定积分和迭代法开平方运算)
求解低阶定积分
题目要求:
计算下列定积分的值:
迭代法开平方运算
题目要求:
用迭代法求 。 已知求平方根的迭代运算公式为:
要求前后两次求出的x的差的绝对值小于10-5。
/*求解低阶定积分*/
#include "stdio.h"
float func(float x)
{
return 2*x 3;
}
float ING(float a,float b)
{
return (b-a)/2*(func(a) func(b));
}
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();
}
运行结果:
/*迭代法开平方运算*/
#include "stdio.h"
#include "math.h"
float func(float x)
{
return pow(x,3) 2*x-1;
}
float ING(float a,float b)
{
return ((b-a)/6)*(func(a) 4*func((a b)/2) func(b));
}
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();
}
运行结果:
,
免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com