求解低阶定积分
题目要求:
计算下列定积分的值:
迭代法开平方运算
题目要求:
用迭代法求 。 已知求平方根的迭代运算公式为:
要求前后两次求出的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();
}
运行结果:
,