0
$\begingroup$

Consider the following differential equation \begin{equation} p(t) = \frac{\partial q(t)}{\partial t} \end{equation} where $t \in (0,\infty)$. I have a build a code that spits out values of the function $p$ for the variable $t$.

Now, I'm looking for a scheme that will analyse these values of $p$ in order to determine $q$. Does anybody have any suggestions? The main problem is that if I would calculate $q(t) = \int p(t) \; \mathrm{d}t$, 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 $q(t)$.

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

$\endgroup$
  • 2
    $\begingroup$ This is an introductory problem in every course on numerical methods, and is covered in every book on numerical methods. What have you tried so far where you got stuck? $\endgroup$ – Wolfgang Bangerth Jun 16 '15 at 12:09
  • 1
    $\begingroup$ I looks like you've posted this same question in at least three places. I think it would be best if these questions could be merged by an admin. Please do not cross post. scicomp.stackexchange.com/questions/19944/… math.stackexchange.com/questions/1326854/… stackoverflow.com/questions/30856354/… $\endgroup$ – Doug Lipinski Jun 16 '15 at 12:54
  • 2
    $\begingroup$ If you integrate p(t) you will not get 'just a number' (the area) but will get instead a function of time t (which you should expect as you set this equal to q(t)...). You only get an area (or 'just a number') if you are integrating between two specific values $\endgroup$ – James Jun 16 '15 at 19:32
3
$\begingroup$

I will answer for the simplest case:

$\frac{dy}{dt} = -\lambda{y}, \hspace{4mm} y(0)=1$

Note: You need an initial condition which you did not specify in your original question.

In this simple problem $q(t) = y(t)$ and $p(t) = -\lambda{q(t)}$. If you use a basic forward Euler finite difference we get:

$\frac{y^{n+1}-y^{n}}{dt} = -\lambda{y^{n}}, \hspace{4mm} y^{0} = 1$

Which gives the recurrence relation:

$y^{n+1} = (1-dt\lambda{})y^{n}, \hspace{4mm} y^{0}=1$

You now just march forward using a specific dt to get y at time t. Obviously there is much more to the story. Here we have used the simplest time-stepping scheme (forward Euler). We have also used a very simple and specific example, but hopefully this will get you started. The basic procedure is to first approximate the derivative using a discrete formula (i.e. forward Euler) and then march forward in time starting from the initial condition.

$\endgroup$
3
$\begingroup$

Your confusion mainly seems to be with calculus, not with numerical methods. Specifically,

  • make sure you understand the difference between an indefinite integral and a definite integral.
  • consider what the initial conditions or boundary conditions are for your problem. Perhaps you know $q(t_0) = q_0$ for a given time $t_0$.
  • Write the integral formulation again, explicitly involving the boundary conditions.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.