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 '19 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 – steeldriver Oct 3 '19 at 16:57

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));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.