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


未完 ......

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

上一篇:c语言编写任意进制转换


下一篇:2021秋季《离散数学》_序关系