3

How to plot floor function in Maxima?

f4(x) := floor(x);

I want to get rid of unnecessary vertical lines: enter image description here

trupanka
  • 693
  • 8
  • 20
  • The hard part of this is to find the points of discontinuity. I don't know how to do that automatically. My advice is to take this to the Maxima mailing list: maxima-discuss@lists.sourceforge.net – Robert Dodier Apr 07 '16 at 05:57
  • https://stackoverflow.com/questions/49587741/how-to-draw-graph-of-gauss-function – Adam Apr 06 '18 at 15:09

1 Answers1

2

Gnuplot doesn't detect points of discontinuity, so you have to make them explicit.

With Gnuplot, you can do:

N=1000
set sample N
plot (abs(x-floor(x))<1./N*(GPVAL_X_MAX-GPVAL_X_MIN))?1/0:floor(x)

With Maxima, you can do the same using the gnuplot_preamble option to set sample:

fl(x,N,Xmin,Xmax):=if (abs(x-floor(x))<1./N*(Xmax-Xmin)) then nan else floor(x);
Xmin:-10; Xmax:10;
plot2d(fl(x,1000,Xmin,Xmax),[x,Xmin,Xmax],[gnuplot_preamble, "set sample 1000"]);
Joce
  • 2,220
  • 15
  • 26
  • Thank you. But can you please provide me a pure `maxima` solution. In my case I didn't get rid of vertical lines with setting `[gnuplot_preamble, 'set sample 1000']` in `plot2d`. What is GPVAL_X_MAX, GPVAL_X_MIN? Do I need to modify `f(x) := floor(x)` line in `maxima`? – trupanka Apr 02 '16 at 18:48