Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

数值方法求积分 #22

Open
micsama opened this issue Aug 3, 2018 · 0 comments
Open

数值方法求积分 #22

micsama opened this issue Aug 3, 2018 · 0 comments

Comments

@micsama
Copy link
Member

micsama commented Aug 3, 2018

数值方法求积分

double f(double x)
{
    return ;//公式
}
double count(double n,double a,double b)
{
    double sum_in=0;
    double h=(b-a)/n;
    for(double i=0;i<n;i++)
    {
        if((int)i%2==0)
        {
            sum_in+=2*(f(i*h+a));
        }
        else
        {
            sum_in+=4*(f(i*h+a));
        }
    }
    double sum=0;
    sum=h/3*(f(a)+f(b)+sum_in);
    return sum;
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant