Menu

#22 turn off/limit interpolation

None
closed
None
5
2014-03-16
2010-10-29
Anonymous
No

Hi,

Thanks for a great program! I'm using GLE to write graphs for a calculus solution manual, and I'd like the ability to turn off the interpolation of y-values (or at least limit it to a certain threshold) in a "let" expression. I graph lots of functions with jump discontinuities, and I want those to show up as gaps in the graph, rather than having a line segment connect the two pieces of the function on either side of the discontinuity.

Example: floor function. If I do the following:

*****
xmin = -4.7
xmax = 4.7
ymin = -5
ymax = 5.7

sub floor x
if x>=0 then
return int(x)
else if x=int(x) then
return int(x)
else
return int(x)-1
end if
end sub

begin graph
math
scale auto
xaxis min xmin max xmax
yaxis min ymin max ymax
xaxis format "fix 0"
yaxis format "fix 0"
x2axis off
y2axis off
let d1 = floor(x) step 0.01
d1 lstyle 1 color black
end graph
*****

then the graph has short, almost vertical segments connecting each horizontal "step" of the floor function. In order *not* to have these appear, I have to replace the graph block with the following:

*****
begin graph
math
scale auto
xaxis min xmin max xmax
yaxis min ymin max ymax
xaxis format "fix 0"
yaxis format "fix 0"
x2axis off
y2axis off
let d1 = floor(x) step 0.01
let d2 = d1 where ((d1=-5) or (d1=-3) or (d1=-1) or (d1=1) or (d1=3))
let d3 = d1 where ((d1=-4) or (d1=-2) or (d1=0) or (d1=2) or (d1=4))
dn lstyle 1 color black
end graph
*****

and then GLE doesn't interpolate between the horizontal "steps", presumably because they're too far apart. It would be simpler to just say something like

let d1 = floor(x) step 0.01 max_yskip 0.1

where "max_yskip" tells GLE not to connect successive points if their y-values are bigger than 0.1. (This is just telling GLE "this function has a discontinuity here", essentially.)

Discussion

  • Jan Struyf

    Jan Struyf - 2010-10-30

    This is a good suggestion. I've implemented it right away.

    I've added the command:

    discontinuity threshold X

    with X a percentage of the axis range to the graph block.

    This will automatically identify something as a discontinuity if it is a bigger gap than the given threshold. There is also an adaptive algorithm to find the X-value of the discontinuity so it is not needed to set step to a small value.

    If you have compiled GLE yourself, you can get this feature from the GIT repository. If you are using Windows or Mac, please let me know (contact info at <http://www.struyf-ye.org/janstruyf/research/>) then I'll make a new build for you.

    I'm also attaching an example.

    Best Regards,

    Jan

     
  • Jan Struyf

    Jan Struyf - 2010-10-30
     
  • Anonymous

    Anonymous - 2010-11-02

    Thanks very much! I will email you; I am using the Windows build. I appreciate your quick response, too!

    -Justin

     
  • Jan Struyf

    Jan Struyf - 2014-03-16
    • status: open --> closed
    • assigned_to: Jan Struyf
    • Group: -->
     

Log in to post a comment.