Hi, I am using odeint to integrate the following delay differential equation df/dx = c + f(x) - f(x-1) To solve it (numerically) I use the following iterative approach. The values of f(x) are given on the interval [0,1]. Then with odeint I can obtain f on [1,2]. Now that f in the interval [1,2] is known, I can use this to compute f on [2,3], etc. All in all this is workable, but somewhat cumbersome. Is it possible in odeint to somehow get intermediate values of the function values? Thanks Nicky
Hi, On Thu, Aug 9, 2012 at 2:15 PM, nicky van foreest <vanforeest@gmail.com> wrote:
I am using odeint to integrate the following delay differential equation
df/dx = c + f(x) - f(x-1)
somewhat cumbersome. Is it possible in odeint to somehow get intermediate values of the function values?
Nicky, I think your easiest way ahead here is to use a spline to fit your previous intervals' solution function, building up your solution using one that meets values and first derivatives at the end points to retain smoothness as you go. Scipy offers several such spline tools. Then you can sample that to your heart's content. -- Robert Clewley, Ph.D. Assistant Professor Neuroscience Institute and Department of Mathematics and Statistics Georgia State University PO Box 5030 Atlanta, GA 30302, USA tel: 404-413-6420 fax: 404-413-5446 http://www2.gsu.edu/~matrhc http://neuroscience.gsu.edu/rclewley.html
Hi Rob, Thanks for the suggestion. I didn't think of using splines. Nicky On 10 August 2012 10:09, Rob Clewley <rob.clewley@gmail.com> wrote:
Hi,
On Thu, Aug 9, 2012 at 2:15 PM, nicky van foreest <vanforeest@gmail.com> wrote:
I am using odeint to integrate the following delay differential equation
df/dx = c + f(x) - f(x-1)
somewhat cumbersome. Is it possible in odeint to somehow get intermediate values of the function values?
Nicky, I think your easiest way ahead here is to use a spline to fit your previous intervals' solution function, building up your solution using one that meets values and first derivatives at the end points to retain smoothness as you go. Scipy offers several such spline tools. Then you can sample that to your heart's content.
-- Robert Clewley, Ph.D. Assistant Professor Neuroscience Institute and Department of Mathematics and Statistics Georgia State University PO Box 5030 Atlanta, GA 30302, USA
tel: 404-413-6420 fax: 404-413-5446 http://www2.gsu.edu/~matrhc http://neuroscience.gsu.edu/rclewley.html _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On Sun, Aug 12, 2012 at 1:49 PM, nicky van foreest <vanforeest@gmail.com>wrote:
Hi Rob,
Thanks for the suggestion. I didn't think of using splines.
Nicky
On 10 August 2012 10:09, Rob Clewley <rob.clewley@gmail.com> wrote:
Hi,
On Thu, Aug 9, 2012 at 2:15 PM, nicky van foreest <vanforeest@gmail.com> wrote:
I am using odeint to integrate the following delay differential equation
df/dx = c + f(x) - f(x-1)
somewhat cumbersome. Is it possible in odeint to somehow get intermediate values of the function values?
Nicky, I think your easiest way ahead here is to use a spline to fit your previous intervals' solution function, building up your solution using one that meets values and first derivatives at the end points to retain smoothness as you go. Scipy offers several such spline tools. Then you can sample that to your heart's content.
-- Robert Clewley, Ph.D. Assistant Professor Neuroscience Institute and Department of Mathematics and Statistics Georgia State University PO Box 5030 Atlanta, GA 30302, USA
Depending on the time interval, it might work to treat the equation as a Chebyshev series by using its values at the Chebyshev points. Both the derivative and the delay are then linear operators that can be represented by matrices, see Trefethen's book<http://people.maths.ox.ac.uk/trefethen/spectral.html>for the differentiation matrices. The boundary conditions might be a bit tricky, but you don't mention how you handle the delay there. Chuck
Hi Chuck, Thanks for your suggestion. I already have something working now, based on the Rob's idea with splines. BTW, I first used interp1d, but that gave some problems at the boundaries due to tiny rounding errors. I now use univariatespline as this gives a function that also extends beyond the boundaries, hence can deal with the rounding problems. Nicky On 16 August 2012 03:58, Charles R Harris <charlesr.harris@gmail.com> wrote:
On Sun, Aug 12, 2012 at 1:49 PM, nicky van foreest <vanforeest@gmail.com> wrote:
Hi Rob,
Thanks for the suggestion. I didn't think of using splines.
Nicky
On 10 August 2012 10:09, Rob Clewley <rob.clewley@gmail.com> wrote:
Hi,
On Thu, Aug 9, 2012 at 2:15 PM, nicky van foreest <vanforeest@gmail.com> wrote:
I am using odeint to integrate the following delay differential equation
df/dx = c + f(x) - f(x-1)
somewhat cumbersome. Is it possible in odeint to somehow get intermediate values of the function values?
Nicky, I think your easiest way ahead here is to use a spline to fit your previous intervals' solution function, building up your solution using one that meets values and first derivatives at the end points to retain smoothness as you go. Scipy offers several such spline tools. Then you can sample that to your heart's content.
-- Robert Clewley, Ph.D. Assistant Professor Neuroscience Institute and Department of Mathematics and Statistics Georgia State University PO Box 5030 Atlanta, GA 30302, USA
Depending on the time interval, it might work to treat the equation as a Chebyshev series by using its values at the Chebyshev points. Both the derivative and the delay are then linear operators that can be represented by matrices, see Trefethen's book for the differentiation matrices. The boundary conditions might be a bit tricky, but you don't mention how you handle the delay there.
Chuck
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
participants (3)
-
Charles R Harris -
nicky van foreest -
Rob Clewley