|
From: 3snoW <vas...@gm...> - 2011-06-16 00:36:00
|
Hello, I'm not sure if this qualifies as "Dev", If it doesn't I'm sorry. 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 This was the result: intfAux1(a,x,h)=(x>a?(f(x)-f(a))*h+intfAux1(a,x-h,h):0); intfAux2(a,x,h)=(x<a?(f(x)-f(a))*h+intfAux2(a,x+h,h):0); intf(a,x)=x>a?intfAux1(a,x-abs(x-a)/90./2,abs(x-a)/90.)+f(a)*(x-a):-intfAux2(a,x+abs(x-a)/90./2,abs(x-a)/90.)+f(a)*(x-a); Basically, intfAux 1 and 2 are just functions for this thing to work, and intf(a,b) integrates f(x) from a to b. You can just type this in every time you want to integrate f(x), or you can download the gnuplot.ini that i made with this function and put it into your binary folder: http://old.nabble.com/file/p31856137/gnuplot.ini gnuplot.ini Here is also a demonstration of using this: http://old.nabble.com/file/p31856137/Integrate%2B.png There are two problems with this function (that I know of): -It will most likely not work with self recursive functions because this function itself is self recursive, and gnuplot has a "stack overflow" limit. This makes it impossible to double integrate using this function. I made it so it was not at the limit, it is almost there, so, for example having a function g(x)=h(intf(0,x)) should not be a problem. By the way, if anyone knows of a way to set the stack overflow limit higher, I'd appreciate posting it here. -The other problem is that it will integrate specifically f(x), so if you want to integrate another function, g(x) for example, you would have to create an intg(a,b). To make this task easier, I made it so that if you replace in those 3 lines of code all the f's with the name of your function, g for example (again), you would have your intg made. This way you can just open notepad, use the "replace" command and copy the result to gnuplot. Let me know if you have any ideas to make it better or if you find any bug using it! I hope this was helpful! 3snoW -- View this message in context: http://old.nabble.com/Integration-in-gnuplot-IS-possible%21-tp31856137p31856137.html Sent from the Gnuplot - Dev mailing list archive at Nabble.com. |