Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #3682

Re: Undefined value during function evaluation

From Karl Ratzsch <mail.kfr@gmx.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Undefined value during function evaluation
Date 2017-06-27 18:01 +0200
Organization solani.org
Message-ID <oitvgn$rbc$1@solani.org> (permalink)
References <c0cd7d4c-8778-4302-9cd7-f1ed87d5734b@googlegroups.com>

Show all headers | View raw


Am 27.06.2017 um 15:54 schrieb schmidtanna114@gmail.com:
> Gnuplot always ansers with this problem:
> Current data point
> =========================
> #               = 31 out of 55
> x               = 100000         
> z               = 225            
> 
> Current set of parameters
> =========================
> a               = 100000         
> b               = 0.00015        
> d               = 30             
> 
>          "Einzelspalt.plt", line 10: Undefined value during function evaluation
> 
> 
> 
> My input is:
> 
> a=100000
> b=0.15e-3
> c=633e-9
> d=30
> e=880
> f(x)=((a)**2)*((b)**2)*((c/(pi*b*sin(atan((x-d)/e))))**2)*((sin((pi*b*sin(atan((x-d)/e)))/c))**2)
> fit f(x) 'Einzelspalt.txt' using ($1):($2) via a,b,d
> plot f(x), 'Einzelspalt.txt' using ($1):($2)
> 
> If I comment the fit out, gnuplot plots the Funktion f(x) with the values for a,b,c,d,e that I have definied before. And it also plots the data of "Einzelspalt.txt". I tested it with a polynomial as f(x), what makes no physikal sense, and it worked. Gnoplot fitted that polynomial to my data and gave me the values.
> Because it prints the function in case that I don´t want to fit it, I think gnuplot also "understands" f(x).
> So I can not imagine what the problem is. Could anyone help me, please?
> 

(b^2 cancels out, if I did the math right, leaving b only in the last
sinus. So your function simplifies to

f(x) = a**2 * c**2 * (1/(pi*sin(atan((x-d)/e))))**2 *
(sin((pi*b*sin(atan((x-d)/e)))/c))**2

And gnuplot expects angles in radians, not degrees. I guess from your
starting value of "d" your datafile contains abscissa values in degrees,
right?

 fit f(x) dataf us ($1/180*pi):2 via a,b,d,e
 plot f(x), dataf us ($1/180*pi):2

 )

Are the supplied parameters in the right region, i.e. is the function
already close to the data _before fitting_?

The function you give is complicated enough to never converge on your
data if the starting parameters are off. At some point most probably a
division by zero happened due to diverging parameter values.

Try predetermining the parameters using simpler functions e.g. only on a
part of the whole dataset, or by using the "stats" command:

  stats "Einzelspalt.txt" us ($1/180*pi):2
  d=STATS_pos_max_y
  # run the fit without d
  # then re-fit all variables



  Karl



Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Undefined value during function evaluation schmidtanna114@gmail.com - 2017-06-27 06:54 -0700
  Re: Undefined value during function evaluation Karl Ratzsch <mail.kfr@gmx.net> - 2017-06-27 18:01 +0200
  Re: Undefined value during function evaluation schmidtanna114@gmail.com - 2017-06-27 12:40 -0700
  Re: Undefined value during function evaluation Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2017-06-27 21:44 +0200
  Re: Undefined value during function evaluation schmidtanna114@gmail.com - 2017-06-28 07:16 -0700

csiph-web