Search code examples
functionplotgnuplot

gnuplot function not plotting - Order of Operation Issue?


The gnuplot (Version 5.4 Windows patchlevel 5) for the function described in the first line below does not work, the second one does. What is going on?

plot  [0:2] [0:4] f(x) = 1/2/(pi*d)**0.5*exp(-1*(1-x)**2/(4*d)), d = 0.0065, f(x)
#plot  [0:2] [0:4] f(x) = 1/(2*(pi*d)**0.5)*exp(-1*(1-x)**2/(4*d)), d = 0.0065, f(x)

The above two lines are the narrowed down version from several alternatives involving sqrt instead of **2.


Solution

  • This is the "everlasting" gnuplot pitfall: integer division, i.e. 1/2=0. Use for example f(x) = 1.0/2/... instead.