
Help Needed
#1
Posted 12 March 2006 - 12:58 PM
Q:How to draw function given in intervals and integrate it later?
I searched instruction and there is nothing. Could anyone help me?
#2
Posted 13 March 2006 - 11:30 AM
You probably mean that you want to define a piecewise function, then integrate it from x=a to x=b. If so, defining a piecewise function is described in the manual. Integration is straightforward, but expect very slow convergence, if build-in integration is used, and the function is not smooth. On the other hand, defining and solving this problem in a CPLua program using LuaNumAn is very easy and accurate. For more details see a similar topic; you will find more information about this problem, and its solution.Hi!
Q:How to draw function given in intervals and integrate it later?
I searched instruction and there is nothing. Could anyone help me?
#3
Posted 13 March 2006 - 04:35 PM
#4
Posted 14 March 2006 - 02:50 PM
You should use nested piecewise functions. For example the following code:What I need is to define a function on many ranges, using piecewise I can define: here-this, rest-this :| it is not satysfying.
piecewise(case1,val1,piecewise(case2,val2,val3))will return val1, if case1 is satisfied; if not, it will return val2, if case2 is satisfied, otherwise, it will return val3. Needless to say that you can nest more than 2 piecewise functions. This way you can define multi-branch functions

Well, built-in definite integration is powerful, but usually slower than LuaNumAn functions. Like you said, a Lua program implementation is the best solution anyway.I already used Lua, not exacly LuaNumAn (sorry for this) and I must say that it was best solution, like always. Integration doesnt have to be so accurate in my case. But Im still interested how to solve my problem without Lua....
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users