Home | Develop | Download | Contact
example_matrix_math_integration.cpp
1
22#include <Pds/Ra>
23#include <iostream>
24#include <cmath>
25
26double func1(double x)
27{
28 if (x*x<2) return sqrt(2-x*x);
29 else return 0;
30}
31
32double func2(double x)
33{
34 return 2/(1+x*x);
35}
36
37int main(void)
38{
39 double S;
40
41 S = Pds::Integration::Simpson(func1,-sqrt(2.0),+sqrt(2.0),10000);
42 std::cout<<"S:"<<S<<std::endl;
43
44 S = Pds::Integration::Improper(func2,0.0,10000);
45 std::cout<<"S:"<<S<<std::endl;
46
47 return 0;
48}
double Improper(double(*f)(double), double a, unsigned int n)
Evalúa la integral de a-->infinito de la función f(x), aplicando el cambio de variable u<–1/(x+1) par...
double Simpson(double(*f)(double), double a, double b, unsigned int n)
Evalúa la integral de a-->b de la función f(x), aplicando la regla de Simpson con n divisiones,...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed