MathGroup Archive 1999

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

Search the Archive

Re: Function evaluation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17611] Re: Function evaluation
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 18 May 1999 02:45:16 -0400
  • Organization: University of Western Australia
  • References: <7hgdks$4c6@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

phpcp at csv.warwick.ac.uk wrote:

> I have a function defined as
> 
> f[s_,n_]:=BesselK[0,n*(1-s)]-BesselK[0,n]*BesselI[0,n*(1-s)]/BesselI[0,n]
> 
> We can see that at s=0, f is zero. but mathematica returns a small number,
> i think it is the workingprecision. I have tried to change the working
> precision, but that does not help. the function still evaluates to a
> 10^-16 number. I am using this function to define other functions. Ccan
> someone help me find a way to evaluate this function correctly.

For your function,

In[1]:= f[s_,n_]:=BesselK[0,n*(1-s)]-BesselK[0,n]*
	BesselI[0,n*(1-s)]/BesselI[0,n]

Mathematica has no problem for s exactly 0.

In[2]:= f[0,n]

Out[2]= 0

A numerical problem can arise if both s and n are floating point
numbers:

In[3]:= f[0., 80.]

                  -52
Out[3]= 3.34096 10

or if n is very large:

In[4]:= f[0., 1000]

             -448
Out[4]= 0. 10

You could always treat s=0. (i.e. a floating point 0) as a special case:

In[5]:= f[0.,n_] := 0

In[6]:= f[0.,1000]

Out[6]= 0

Note that you can control the precision of the arguments using
SetPrecision 
(via `)

In[7]:= f[0.`40, 1000`40]

              -472
Out[7]= 0. 10

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia           
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au 
AUSTRALIA                        http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Mathematica>eps>pdf problems with Epilog and PlotRegion
  • Next by Date: Re: Draw straight line, but display zigzag line!
  • Previous by thread: RE: Re: Function evaluation
  • Next by thread: Re: Re: Function evaluation