Looking for a particular algorithm for numerical integration

245 views Asked by At

Consider the following differential equation
f(x) = g'(x)
I have a build a code that spits out values of the function f(x) for the variable x, where x goes from 0 to very large.

Now, I'm looking for a scheme that will analyse these values of f(x) in order to determine g(x). Does anybody have any suggestions? The main problem is that if I would calculate g(x) = Integral (f(x) * dx), then I'll end up with just a number (i.e. the area under the graph), but I need to know the actual function of g(x).

I've cross-posted this question here: https://math.stackexchange.com/questions/1326854/looking-for-a-particular-algorithm-for-numerical-integration

1

There are 1 answers

0
Spektre On BEST ANSWER
  1. numerical integration always return just a number

    • if you do not want the number but function instead
    • then you can not use numerical integration for this task directly
  2. Polynomial approach

    • you can use any approximation/interpolation technique to obtain a polynomial representing f(x)
    • then integrate as standard polynomial (just change in exponent and multiplication constant)
    • this is not suited for transcendent, periodical or complex shaped functions
    • most common approaches is use of L'Grange or Taylor series
    • for both you need a parser capable of returning value of f(x) for any given x
  3. algebraic integration

    • this is not solvable for any f(x) because we do not know how to integrate everything
    • so you would need to program all the rules for integration
    • like per-partes,substitutions,Z or L'Place transforms
    • and write a solver within string/symbol paradigm
    • that is huge amount of work
    • may be there are libs or dlls that can do that
    • from programs like Derive or Matlab ...

[edit1] As the function f(x) is just a table in form

  • double f[][2]={ x1,f(x1),x2,f(x2),...xn,f(xn) };
  • you can create the same table for g(x)=Integral(f(x)) at interval <0,x>
  • so:

    g(x1)=f(x1)*(x1-0)
    g(x2)=f(x1)*(x1-0)+f(x2)*(x2-x1)
    g(x3)=f(x1)*(x1-0)+f(x2)*(x2-x1)+f(x3)*(x3-x2)
    ...
    
  • this is just a table so if you want actual function you need to convert this to polynomial via L'Grange or any other interpolation...

  • you can also use DFFT and for the function as set of sin-waves