when I type sqrt(4) I get

invalid command

how do I calculate the square root of a positive real number with gnuplot?

  • 1
    You should probably be using a tool designed for calculations such as bc or dc. The sqrt() function in gnuplot is intended for manipulating data under the plot command, not as a command in-and-of itself.
    – doneal24
    Oct 3, 2019 at 16:29
  • 1
    What are you trying to do, exactly? sqrt(4) on its own is an invalid gnuplot command - but (for example) plot sqrt(4) should be valid Oct 3, 2019 at 16:57

1 Answer 1


If you want gnuplot to show you the result of a square root, then use the print() function in any of these ways:

> print(sqrt(4));


> a=sqrt(4);print(a);


> a=4;print(sqrt(a));

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .