Search code examples
gnuplotexponential

How to fit a*e**bx function via gnuplot?


Upon running this code on my file, it fits nothing.

f1(x) = a*e**(b*x)
a = -1
b = 10000
fit f1(x) 'myFile.txt' via a,b
plot 'myFile.txt' with points lc rgb"blue" title ' '

Does gnuplot understand 'e' or do we need to declare its value? i.e. 2.7182.


Solution

  • You must use the exp function for this:

    f1(x) = a*exp(b*x)
    a = -1
    b = 10000
    fit f1(x) 'myFile.txt' via a,b
    plot 'myFile.txt' with points lc rgb"blue" title ' '