SIMPSON integral algorithm

xiaoxiao2021-03-06  13

#define pr double

TypeDef Pr (* FUN) (PR); // Defines a pointer to the active function

Class Integral {Private: Pr Lower, Upper; // Lower - Point Lower; Upper - Integral Limit Fun Integrand; // Integrand - Bottom Function PUBLIC: Integral (Pr L = 0, PR U = 0, Fun F = 0): LOWER (L), Upper (U), Integrand (f) {} void PutchangeBd (Pr L, PR U); // Setting the integral upper limit, lower Void Put_Indegrand (FUN F); // Setting the integration function PR Solution (long n); // solve points with SIMPSON 3/8.

Void Integral :: PutchangeBd (Pr L, PR U) // Sets the integration lower limit, upper limit {Lower = L; Upper = u;}

Void Integral :: PUT_INTEGRAND (FUN F) // Set integration function {integrand = f;}

Pr Integral :: Solution (long n) // Separate points {PR H, Result = 0, TEMP = 0; h = (Upper-Lower) / 3 / N; Result = Integrand (Lower) Integrand (Upper); for (int i = 1; i <= n; i ) TEMP = (Integrand (Lower (3 * I-1) * H) Integrand (Lower (3 * I-2) * h)) Result = 3 * Temp; Temp = 0; for (int i = 1; i

转载请注明原文地址:https://www.9cbs.com/read-48859.html

New Post(0)