⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d5r6.cpp

📁 visual c++查过能用数值算法 附带光盘里面的源代码
💻 CPP
字号:
#include "iostream.h"
#include "math.h"

double func(double x)
{
    return (x * x) * (x * x - 2.0) * sin(x);
}

double  fint(double x)
{
    //integral of func
	double aaa;
    aaa = 4.0 * x * ((x * x) - 7.0) * sin(x);
    return aaa - ((pow(x , 4) - 14.0 * (x * x) + 28.0)) * cos(x);
}

void main()
{
    //program d5r6
    //driver for routine chint
    int nval = 40;
    double a,b,x,aaa,pio2 = 1.5707963;
    double c[41], cint1[41];
    a = -pio2;
    b = pio2;
    chebft(a, b, c, nval);
    //test integral
    cout<<endl;
    cout<<"How many terms in chebyshev evaluation?"<<endl;
    //input mval , between 6 and 40, mval=0 to end
    int mval = 20;
    cout<<mval<<endl;
    if ((mval <= 0) || (mval > nval))
	{
		return;
	}
    chint(a, b, c, cint1, mval);
    cout<<"         x         Actual    Cheby. integ."<<endl;
	cout.setf(ios::fixed|ios::right);
	cout.precision(6);
    for (int i = -8; i<=8; i++)
	{
        x = i * pio2 / 10.0;
		cout.width(13);
        cout<<x;
		cout.width(13);
        cout<<(fint(x) - fint(-pio2));
        aaa = chebev(a, b, cint1, mval, x);
		cout.width(13);
        cout<<aaa<<endl;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -