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

📄 d10r8.cpp

📁 Visual C++ 常用数值算法集 源代码
💻 CPP
字号:
#include <process.h>
#include <math.h>
#include <iomanip.h>
#include <iostream.h>
#include <stdlib.h>

double func(double x)
{
	double t;
	t=bessj0( x);
	return t;
}

void  funcd(double x, double &fn,double& df)
{
    fn = bessj0(x);
    df = -bessj1(x);
}

void main()
{
    //program d10r8
    //driver for routine rtnewt
	int n,nbmax,nb,i;
	double  x1,x2,xacc,root,xb1[21], xb2[21],ttt;
    n = 100;
    nbmax = 20;
    x1 = 1.0;
    x2 = 50.0;
    nb = nbmax;
    zbrak(x1, x2, n, xb1, xb2, nb);
    cout<<endl;
    cout<<"Roots of Bessj0:"<<endl;
    cout<<endl;
    cout<<"                    x              f(x)"<<endl;
    for (i = 1; i<=nb; i++)
	{
        xacc = (0.0000010) * (xb1[i] + xb2[i]) / 2.0;
        root = rtnewt(xb1[i], xb2[i], xacc);
        cout<< setw(8)<<"root "<<i;
        cout<< setw(14)<<root;
		ttt=bessj0(root);
        cout<< setw(19)<<ttt<<endl;
    }
}

⌨️ 快捷键说明

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