MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Function evaluation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17639] Re: [mg17611] Re: Function evaluation
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 21 May 1999 03:37:32 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Bob:

>A problem can still arise with s identically zero (integer zero).
>Note the following:
>
>f[s_,n_]:=BesselK[0,n*(1-s)]-BesselK[0,n]*
>	BesselI[0,n*(1-s)]/BesselI[0,n];
>
>Table[f[0, n], {n, 0.01, 1.0, 0.01}]
>
>{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 2.220446049250313*^-16, 0., 0., 0.,
>  1.110223024625156*^-16, 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>  1.110223024625156*^-16, 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
>  0., 0., 0., 5.551115123125782*^-17, 0., 0., 0., 0., 0.}

Agreed -- but, for this example, surely it would be better to do

	Table[Evaluate[f[0, n]], {n, 0.01, 1.0, 0.01}]

anyway.

>Consequently, both 0 and 0. should be covered by the special case.
>The following handles both cases:
>
>f[s_ /; s==0, n_] := 0;

This works fine for testing against 0.  However, suppose the function was

  g[s_,n_]:=10^6 (BesselK[0,n s]-BesselK[0,n] BesselI[0,n s]/BesselI[0,n]);
  g[s_ /; s==1,n_]:= 0

instead. Because there is machine dependence on what is treated as a "1".
E.g., on a DEC alpha,

  In[1]:= 1.00000000000002 == 1

  Out[1]= True

the second definition will lead to other problems (since g[1,n] is now
significantly different to g[1.00000000000002,n]).

Cheers,
	Paul




  • Prev by Date: Kernel Execute of Menu Commands
  • Next by Date: Re: RE: Re: Function evaluation
  • Previous by thread: Re: Function evaluation
  • Next by thread: Re: RE: Re: Function evaluation