|
From: Pieter-Tjerk de B. <ptd...@cs...> - 2011-06-16 23:03:03
|
Hello, On Wed, Jun 15, 2011 at 05:35:54PM -0700, 3snoW wrote: > I've searched the web for ways to integrate in gnuplot and only found people > saying it is not possible. Unsatisfied, I decided to see if i could make one > myself. I could :D Nice! > Let me know if you have any ideas to make it better I'd suggest using the recursion not to cover the interval _linearly_, but using the recursion to _bisect_ the interval, like this: intf(a,x,n) = (n==0) ? f((a+x)/2)*(x-a) : ( intf(a,(a+x)/2,n-1) + intf((a+x)/2,x,n-1) ) The last parameter n is the number of recursions, and which equals the 2log of the number of points in which to cut the interval. This approach should practically avoid stack overflows, since much less recursion depth is needed for the same accuracy. Regards, Pieter-Tjerk |