Jump to content



Photo
- - - - -

Luaplot/plotfunc And Sign Function


  • Please log in to reply
1 reply to this topic

#1 Alvise

Alvise

    Newbie

  • Members
  • Pip
  • 8 posts

  • Calculators:
    Classpad 300Plus

Posted 23 October 2005 - 10:53 AM

Posted ImagePosted Image
Hi.
In the lua program i have defined sign function as |x|/x and i've ploted it. In the second image is possible to see the plot, and is possible to see that around "0" the plot is ... "so strange". The function goes vertically.. anyone know why ?
Thanks.

#2 PAP

PAP

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 681 posts
  • Gender:Male
  • Location:Somewhere in Europe.
  • Interests:Computer Algebra, Numerical Analysis.

  • Calculators:
    ClassPad 300 (plus an old Casio model, with only a few Kb ram).

Posted 23 October 2005 - 01:31 PM

In the lua program i have defined sign function as |x|/x and i've ploted it. In the second image is possible to see the plot, and is possible to see that around "0" the plot is ... "so strange". The function goes vertically.. anyone know why ?

Obviously, your "sign" function is undefined at x=0. Change it by the math.sign function, already included in CPLua. Note that, even then, you will see an almost vertical line connecting (0,-1), (0,0), and (0,1). This is because of the definition of the math.sign function (for x=0, it's equal to 0, as in every programming language that supports a similar function). Note that PlotFunc is not designed to plot non-continuous functions; this behavior may change in the future, but I think that it's rather not important, and has a low priority in my list to "to do" things"..

Edit: Fixed; LuaNumAn version 1.50 includes a way to handle discontinuities in PlotFunc.

Edited by PAP, 13 March 2006 - 11:23 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users