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

2
  • 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: [email protected] Commented Apr 7, 2016 at 5:57
  • stackoverflow.com/questions/49587741/… Commented Apr 6, 2018 at 15:09

1 Answer 1

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"]);
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.