编程语言
首页 > 编程语言> > C++ 计算定积分、不定积分、蒙特卡洛积分法

C++ 计算定积分、不定积分、蒙特卡洛积分法

作者:互联网

封装成了一个类,头文件和源文件如下:

integral.h

#pragma once

//Microsoft Visual Studio 2015 Enterprise

#include <iostream>
#include <cmath>
#include <ctime>

using std::cout;
using std::endl;

class integral
{
private:
    struct info
    {
        //value表示积分值,error表示误差
        double value;
        double error;
    };
public:
    double definiteIntegral(double(*f)(double), double a, double b, double step = 0.01);
    double infiniteIntegral(double(*f)(double), double a, double step = 0.01, int N = 100, double precision = 0.01, int type = 1);
    info monteCarloDefiniteIntegral(double(*f)(double), double a, double b, double precision = 0.01);

integral.cpp


未完 ......

点击访问原文(进入后根据右侧标签,快速定位到本文)

标签:info,int,double,不定积分,0.01,integral,C++,积分法,include
来源: https://www.cnblogs.com/sinicheveen/p/12009802.html