文档库 最新最全的文档下载
当前位置:文档库 › 数值分析实验报告——龙贝格求积算法

数值分析实验报告——龙贝格求积算法

数值分析实验报告

专业 信息与计算科学 班级 信计101 姓名 学号 协作队员 实验日期 2013 年 1 月 5 日 星期 六

成绩评定 教师签名 批改日期 题目

一、 问题提出

教材136页12题用龙贝格求积算法计算其近似值(加速3次) 地球卫星轨道是一个椭圆,椭圆周长的计算公式是

θθπ

d a c a S ???? ??-=2

022

sin 1 这里a 是椭圆的半长轴,c 是地球中心与轨道中心(椭圆中心)的距离,记h 为近地点距离,H 为远地点距离,R=6371(km )为地球半径,则2/)2(h H R a ++=,2/)(h H c -=

我国第一颗人造地球卫星近地点距离h=439(km ),远地点距离H=2384(km ),试求卫星轨道的周长。

二、 模型建立

,2,1 , )(141)2(144 )(1)1(1)

( =---=-+-k h T h T T k m m k m m m k m

龙贝格求积算法

称为 当加速3次时,龙贝格求积算法如下:

.6316364 : 3,m 2n n n C C R -==龙贝格积分公式

三、 求解方法

#ifndef A

#define A

#include "math.h"

class T

{

public:

double operator()(const double& x)const

{

return (double)sin(x)/(1+x);

}

};

template

class Rombeg{

public :

void Solve(double a,double b,int MAX_N,int DengFenShu,double e);

private :

T R;

};

#endif

/*方法实现*/

#include "iostream"

#include "LongBeiGe.h"

#include "math.h"

#define MAX_SIZE 255

using namespace std;

template

void Rombeg::Solve(double a,double b,int MAX_XunHuan,int DengFenShu,double e) {

double t[MAX_SIZE][MAX_SIZE];

int n=DengFenShu;

double h=(b-a)/n;

double s=0;

int flag=0;

int i;

for(i=1;i

s+=R(a+i*h);

t[0][1]=h*(s+(R(a)+R(b))/2);

n*=2;

int m;

for(m=1;m

{

for(i=0;i

t[i][0]=t[i][1];

h=(b-a)/n;

s=0;

int j;

for(j=1;j

s=s+R(a+j*h);

t[0][1]=h*(s+(R(a)+R(b))/2.0);

n*=2;

for(i=1;i<=m;i++)

t[i][1]=t[i-1][1]+(t[i-1][1]-t[i-1][0])/(pow((double)2,(double)2*m)-1);

if(fabs(t[m][1]-t[m-1][1])

{

flag=1;

cout<

break;

}

}

if(flag==0)

cout<<"无解";;//无解

}

/*主函数*/

#include "iostream"

#include "LongBeiGe.h"

#include "LongBeiGe.cpp"

int main()

{

Rombeg r;

double a,b,e;

int DengFenShu;

int Max_XunHuan;

cout<<"输入积分上限:";

cin>>b;

cout<<"输入积分下限:";

cin>>a;

cout<<"输入等份次数:";

cin>>DengFenShu;

cout<<"输入最大循环次数:";

cin>>Max_XunHuan;

cout<<"输入最大误差:";

cin>>e;

r.Solve(a,b,Max_XunHuan,DengFenShu,e);

return 0;

四、输出结果

由以上程序求出了卫星轨道的周长S=48708km

五、结果分析

运用龙贝格求积算法计算出近似值的方法,简单,操作性强,且计算结果比较精确。

相关文档