Search code examples
functiongraphgnuplot

Gnuplot goes crazy with the function f(x)=(abs(1-(x/0.001))**(-1/2))


Gnuplot does not let me plot a function but Mathematica does.

I am trying to plot the following function in gnuplot

f(x) = (abs(1-(x/0.001))**(-1/2))

But it gives me the following error: empty y range [1:1], adjusting to [0.99:1.01]

I went to wolfram alpha and it was capable of plotting such function over the domain (0.001,100]. I tried to set the xrange and yrange (at it seems that f(x) grows very slow) but then again no plot was given.

DO you have any insights on what to do in order to plot such a function?

Thanks in advance


Solution

  • Gnuplot interprets 1/2 as integer arithmetic, so it evaluates to zero. Add a decimal point to indicate floating point arithmetic and all will be well.

    f(x) = (abs(1-(x/0.001))**(-1/2.))
    set yrange [0:.5]
    plot f(x)
    

    enter image description here