Alec <alec314159@yahoo.com> writes:
On Wednesday 09 January 2002 06:50 am, S.D.Mechveliani wrote:
Zhe Fu <fuzhezheng@hotmail.com> writes
Is there any built-in functions in Haskell to implement diffential operation and partial diffential operation? Or can anyone give me some advices about how to implement them with Haskell? Thanks.
If you are going to implement differential operators, try first to implement, for example, polynomial multiplication. After this, differentiation would not look hard. But it depends on what one wants to differentiate, one has to formulate first what kind of expressions are supposed to be differentiated.
how about this:
diff f x = (f (x + epsilon) - f (x - epsilon)) / (2 * epsilon) where epsilon = 0.00001
every call to say "diff sin" will cost you about as much as every call to "sin"
I used to toy with these kinds (i.e. numerical differentiation, as opposed to what SDM is talking about ) of functions a bit. One improvement, IMHO, would be to make diff parametric in epsilon, i.e. diff e f x = (f (x+e) - f (x-e)) / (2 * e) the "diff" above would simply be diff' = diff 0.00001 You can also apply diff to itself, getting second derivatives and such, but numerical accuracy will quickly start to suffer unless you're careful. Jerzy Karczmarczuk has some interesting papers on his web site using a different approach to differentiation, maintaining, IIRC, a lazy list of all derivatives of functions. I don't have the URL ready, but a your favorite search engine should be able to help you out. -kzm -- If I haven't seen further, it is by standing in the footprints of giants