Search code examples
mathdifferential-equationsnumerical-integration

Numerical integration of an unknown function


For a school project I have to determine a function u(t) of time. I have derived an expression of the following form:

(https://i.sstatic.net/vNrYb.png)

with a,b,c,d constants (not necessarily integers). I have figured out that this problem is only solvable with numerical integration with initial condition u(0)=u_0, yet I don't know how to do this particular problem.

I have looked at all the numerical integration methods I have learnt so far, but they all seem to apply for polynomials or for functions where you know the function evaluations at specific points.


Solution

  • There are lots of ways to calculate an approximate value for u(t), some simple but requiring a lot of iterations, and more complex requiring fewer iterations. Assuming a,b,c,d are real numbers, and u_0 = u(0) then for t > 0, one could just split the interval between 0 and t into N sub-intervals and calculate

    u_(i+1) = u_i + (du/dt)(t_i)*t/N

    where t_i = i*t/N

    then,

    u_N = u(t).

    If N is not sufficiently large, the result will be inaccurate. To obtain a satisfactory N is more art than science. Just printing the results for increasing N should give you an idea of how large N needs to be to obtain the level of accuracy you need. Adding higher order terms (d^2u/dt^2 etc.) can sometimes improve speed and accuracy.