0
$\begingroup$

I would like to solve the initial value problem \begin{align} y'(t)&=c_1p(t)-c_2y(t)\\ y(t_0=0)&=y_0 \end{align} with Microsoft Excel. The constants $c_1,c_2>0$ and the function $p(t)$ are given, but note that I have no formula of $p$. I have a column with entries of $p$ and I want to find out the graph of $y$. I know that this is not an exact solution, but I get a picture of it.

From Taylor's formula I get \begin{align} y(t+h)&\approx y(t)+y'(t)h\\ &=y(t)+(c_1p(t)-c_2y(t))h\\ &=(1-c_2h)y(t)+c_1hp(t) \end{align} If I choose $h=1$ and $y_i=y(t_i)$, I have a numerical solution in the points $\lbrace t_0,t_1,t_2,\ldots\rbrace=\lbrace 0,1,2,\ldots\rbrace$.

This is almost the Euler method, but I'm not completely sure if I can apply it, because there we have an IVP $y'(t)=f(t,y(t))$ with $y(t_0)=y_0$ and I have $y'(t)=f(p(t),y(t))$ with $y(t_0)=y_0$.

Is my approach correct or do I have to improve the "Euler method"?

The question can be generalized to, how you can solve \begin{align} y'(t)&=f(p(t),y(t))\\ y(t_0)&=y_0 \end{align} with a numerical method (which I can implement in Excel). This would be sufficient for me to answer

$\endgroup$
5
  • $\begingroup$ This is the Euler method $\endgroup$
    – Dylan
    Nov 6, 2017 at 19:45
  • $\begingroup$ @Dylan So it's the correct way? $\endgroup$ Nov 6, 2017 at 19:52
  • $\begingroup$ @Dylan For $y'(t)=f(p(t),y(t))$ it's $y(t+h)\approx y(t)+f(p(t),y(t))h$ too? $\endgroup$ Nov 6, 2017 at 19:54
  • $\begingroup$ $f(p(t),y(t))$ is no different from $f(t,y(t))$. Either way your RHS is a functional of $t$ and $y$ $\endgroup$
    – Dylan
    Nov 6, 2017 at 20:04
  • $\begingroup$ @Dylan Thank you! If you write an answer below, I will accept it. $\endgroup$ Nov 6, 2017 at 20:10

1 Answer 1

1
$\begingroup$

Euler's method applies to ODEs of the form $y'(t) = f(t,y(t))$. As noted by Dylan, your specific case corresponds to $$f(t,y) = c_1 p(t) - c_2 y.$$

Without the means to explicitly compute $p(t)$ you must either limit yourself to the values available or perform interpolation. You can use linear interpolation between neighboring points.

Specifically, if you know $p(t_1)$ and $p(t_2)$ and you need $p(t)$ where $t_1 < t < t_2$ in order to do the current step of Euler's method, then approximate $$p(t) \approx \frac{t-t_2}{t_1 - t_2} p(t_1) + \frac{t_1 - t}{t_1 - t_2} p(t_2).$$

$\endgroup$
2
  • $\begingroup$ Ok, in my case the function $p$ is given in the points $t_0,t_1,t_2,\ldots$ The values of $p$ in some points between them is not in my interest. Or do i misunderstand you? $\endgroup$ Nov 6, 2017 at 21:05
  • $\begingroup$ You may well be contend with the $p$ values that you know. If you find that you need a better approximation of $y$ you will need to reduce the time step. In this, case you will need some way of generating new values of $p$. $\endgroup$ Nov 6, 2017 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .