复化梯形公式 复化梯形公式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
public class lbg
{
const int MAXRepeat = 100;
public double f(double x)//被积函数,根据自己的需要手工输入
{
double s;
s = 4.0 / (1 + x * x);
re...
复化梯形公式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
public class lbg
{
const int MAXRepeat = 100;
public double f(double x)//被积
数,根据自己的需要手工输入
{
double s;
s = 4.0 / (1 + x * x);
return s;
}
public double Romberg(double a, double b, double epsion)
{
m = 1; int
int n = 1;
int k;
double h;
double ep;
double p1;
double xk;
double p2;
double q = 0.0;
h = b - a;
p1 = 0.5 * h * (f(a) + f(b));
ep = epsion + 1.0;
while (ep >= epsion)
{
p1 = 0.0;
for (k = 0; k < n; k++)
{
xk = a + (k + 0.5) * h; // n-1
p2 = p2+ f(xk); //计算?f(xk+h/2),T
} // k=0
p2 = (p1 + h * p) / 2.0; //T`m`(h/2),变步长梯形求积公式
ep = Math.Abs(p2-p1);
m++;
p1 = p2;
n *= 2; // 2 4 8 16
h /= 2.0;
}
return q;
}
}
class Program
{
static void Main(string[] args)
{
lbg l = new lbg();
Console.Write("请输入下界值:");
double x = double.Parse(Console.ReadLine());
Console.Write("请输入上界值:");
double y = double.Parse(Console.ReadLine());
double s = l.Romberg(x, y, 0.000001);
Console.Write("积分值为:{0}", s.ToString("0.000000000"));
Console.ReadLine();
}
}
}
本文档为【复化梯形公式 】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。