I see. Can you analytically differentiate dx/dt = F(x,t) once more? For the finite differences, presumably you tried using a large stencil? Here some old Matlab code of mine in case you haven't tried:
function dy_dx = diff_o4(y,dx) % differentiates x numerically with O(dx^4) % see schieser (1991) dy_dx = 2*[0; 0; 0; 0; y] - 16*[0; 0; 0; y; 0] + 16*[0; y; 0; 0; 0] - 2*[y; 0; 0; 0; 0]; dy_dx = dy_dx(3:end-2); dy_dx(1) = -50*y(1) + 96*y(2) - 72*y(3) +32*y(4) - 6*y(5); dy_dx(2) = -6*y(1) - 20*y(2) + 36*y(3) - 12*y(4) + 2*y(5); dy_dx(end-1) = 6*y(end) + 20*y(end-1) - 36*y(end-2) + 12*y(end-3) - 2*y(end-4); dy_dx(end) = 50*y(end) - 96*y(end-1) + 72*y(end-2) - 32*y(end-3) + 6*y(end-4); dy_dx = 1/24/dx*dy_dx; On Tue, 2015-08-25 at 14:37, Spencer Lyon <spencerly...@gmail.com> wrote: > Hey Mauro, > > That’s right. The ODE solver does give me the first derivative. The problem > is that I need the first two derivatives! > > So what I’ve done to test all my numerical tools for accuracy is to compare > the approximated first derivative with the actual one given my by the ODE > solver. That’s how I know that the approximations are all very poor (an > average error of 75%, where this is computed as abs((actual - > approx)./actual)). If I could find a way to get accurate approximations of > the first derivative, then I could apply these techniques to the actual first > derivative to get an estimate of the second derivative. > > > > // Spencer > > From:Mauro <mauro...@runbox.com> > Reply:julia-users@googlegroups.com <julia-users@googlegroups.com>> > Date:August 25, 2015 at 8:31:50 AM > To:julia-users@googlegroups.com <julia-users@googlegroups.com>> > Subject: Re: [julia-users] Re: ANN: JuliaDiff -- differentiation tools in > Julia > >> About the data, it should be pretty smooth. It is generated as the output >> of applying a stiff ODE solver where the domain is covered by 10,000 points >> on the unit interval. I've tried using all 10,000 (x, y) points. I was >> concerned about overfitting, so I also tried thinning the data by taking >> every `n`th point, but that didn't help. > > The ODE solver should, at least internally, have an estimate of the > derivative. Maybe there is a way to get at that? Otherwise, if the ODE > is in the form dx/dt = F(x,t) then just plug your x and t into that. If > it is of the form 0=F(dx/dt,x,t) then you could solve the system of > equations for dx/dt for all x,t. > >> That's a good point regarding regression or Bayesean techniques. I'll >> definitely consider that. >> >> Thanks again for the comments! >> >> >> On Tuesday, August 25, 2015 at 5:45:08 AM UTC-4, Christoph Ortner wrote: >>> >>> P.S.: I think your problem is unrelated to `julia-diff` which deals with a >>> completely different class of differentiation algorithms. >>>