Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #3684
| Path | csiph.com!news.mixmin.net!news.unit0.net!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail |
|---|---|
| From | Hans-Bernhard Bröker <HBBroeker@t-online.de> |
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: Undefined value during function evaluation |
| Date | Tue, 27 Jun 2017 21:44:56 +0200 |
| Lines | 45 |
| Message-ID | <erfqttF2ib5U1@mid.dfncis.de> (permalink) |
| References | <c0cd7d4c-8778-4302-9cd7-f1ed87d5734b@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.dfncis.de CvR/wPbxWPWM1ZiBLLMEyQIkf1CF5APqn5DEW25CNwhLPVwnu4W+XiBWzM |
| Cancel-Lock | sha1:zJnkZB7boBuwCBUCtAYWb+3lo2U= |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
| In-Reply-To | <c0cd7d4c-8778-4302-9cd7-f1ed87d5734b@googlegroups.com> |
| Content-Language | de-DE |
| Xref | csiph.com comp.graphics.apps.gnuplot:3684 |
Show key headers only | View raw
Am 27.06.2017 um 15:54 schrieb schmidtanna114@gmail.com:
> 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)
That's a somewhat suboptimal way of setting up your function. It would
make a lot more sense to do it more piecemeal:
# Let's refer to things by their usual name (some do without the pis...)
sinc(x)=sin(pi*x)/(pi*x)
# use atan2 instead of atan:
f1(x,d,e)=sin(atan2(x-d,e))
# Note: this doesn't really need to use trig functions.
# alternative:
#f1(x,d,e) = (x-d) / sqrt((x-d)**2 + e**2)
# Using these, and after spotting that f(x) consists of terms that are
# all_ squared, so the square can be moved to the outer edge, one gets:
f(x,a,b,c,d,e) = (a*b * sinc(b/c*f1(x,d,e)))**2
One thing this makes much easier to see is that there's a redundancy in
your parameters:
f(x,a*b,1,c/b,d,e)=f(x,a,b,c,d,e) for all k,x,a,...
Another thing more obvious is how this function's value can become
undefined: for x==d, f1(x,d,e) is zero, so the argument to sinc()
becomes zero, and you hit the function's undefined spot:
gnuplot> print f(d,a,b,c,d,e)
^
undefined value
To avoid that, you can use sinc()'s continuous extension instead:
sinc(x) = (x == 0) ? 1.0 : sin(pi*x)/(pi*x)
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
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