Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-31-2008, 07:55 PM   #1
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Nth-order derivative of an arbitrary function

I've been trying to use Maxima to calculate the Nth-order derivative of a numerically-calculated function, which it obviously has a huge problem doing. This isn't any surprise since it would probably need to take N^2 samples of the function to differentiate N times, but there really isn't another way to do it.
d    /   1     x        m-1           \
---  |  ----  ∫ (x - y)     f(y) dy |
  n  \  Γ(m)   0                      /
You might recognize this as the fractional derivative of f(x) of order n-m. I've actually calculated this symbolically for the f(x) in question (with some very liberal interpretations,) but I'm trying to calculate it the formal way to see how close the symbolic version is. The symbolic version matches perfectly for integer orders, but I used a set of fit curves to find the in-between orders, which probably isn't an actual fractional derivative. Also, it only worked symbolically because I strategically avoided constants, but I'd like to be able to calculate this with an arbitrary f(x). I'm exporting it to gnuplot in the form of a pm3d splot with x on the x-axis, n-m on the y-axis, and the resulting value on the z-axis.

Has anyone been able to calculate something like this? I have Matlab sitting around ready to install, but I haven't ever used it. My other thought is to write a loop and/or use a matrix. Thanks.

Last edited by ta0kira; 12-31-2008 at 10:09 PM.
Old 12-31-2008, 11:50 PM   #2
Sergei Steshenko
Senior Member
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
You can't, generally speaking, calculate the n-the derivative because, generally speaking, not every function is that smooth.
Old 01-01-2009, 02:07 AM   #3
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Supposing it's smooth for x+[0,δ] where δ is some sample range, what would be the simplest way to calculate the Nth derivative? I'll mostly be dealing with harmonic functions and natural exponents, all in the real domain. My first thought is to sample N+1 times initially, then recursively difference pairs of two until the Nth order:
2^x | x=1, N=3, δ=0.1

d \ x	1.0	1.033	1.067	1.1	       0	2.0	2.047	2.095	2.144	Δ/(δ/3) →
1	1.402	1.435	1.469		Δ/(δ/3) →
2	0.983	1.006			Δ/(δ/3) →
3	0.690    (actual: ln(2)^3*2^x=0.666)
The only problem I see with this is that the entire process would need to be repeated for every point on the plot, not to mention the fact that using the function in my initial post would also require numerical calculation of the integral, giving me at least x*y*(N+1)/2 calculations of that integral. With my plot as it is, 80x50 & N=[0,8] that would be 18,000 numerical integral calculations! Of course, programatically I could carry over points and might be able to get away with ~9,000 calculations of the integral, but I'm not in the mood to write my own fractional-derivative mapper. I suppose that might be in order if I decide to continue this path of research. If not, it's still the sort of thing I would occupy myself with just to prove I haven't been beaten! It really only needs to be within about 10% at this point since I'm doing mostly visual analyses right now. Thanks.

PS Something I just thought of is that the functions I'll deal with will almost always be symbolically differentiable to any integer order (without converging to a constant,) so for real-order n I could calculate symbolically to order ⌈n⌉, then calculate the fractional integral ⌈n⌉-n of that, which should get me down to 4,000 numerical integrations. I don't know who's idea it was to differentiate after the fractional integral! Now I need to figure out how to get Maxima to numerically integrate for a plot (could actually be a gnuplot problem; I'll try exporting to a data file.)

PPS I understand that the issue stated initially isn't exactly what it actually is. Sorry.

Last edited by ta0kira; 01-01-2009 at 02:17 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: A Derivative of Open Source: What is Crowdsourcing? LXer Syndicated Linux News 0 12-27-2008 06:50 PM
do you find #include order to be arbitrary? ta0kira Programming 2 08-29-2008 01:02 AM
n00b to the Nth degree flarpo Member Intro 3 08-17-2005 06:14 PM
Derivative OpenCD Error ice_hockey Linux - Software 0 07-11-2005 09:52 AM
Closed-Source Derivative Works under GLP--possible? alxdotnet General 6 03-30-2004 01:39 PM

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration