[Date Index]
[Thread Index]
[Author Index]
Re: Can't calculate numerical derivative of EllipticTheta
*To*: mathgroup at smc.vnet.net
*Subject*: [mg82689] Re: [mg82659] Can't calculate numerical derivative of EllipticTheta
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Sun, 28 Oct 2007 04:07:56 -0500 (EST)
*References*: <200710271006.GAA11228@smc.vnet.net>
On 27 Oct 2007, at 19:06, Scott Hemphill wrote:
> I realize that my version of Mathematica is getting a little old. Is
> this fixed in later releases?
>
> In[1]:= $Version
>
> Out[1]= 5.1 for Linux (October 25, 2004)
>
> In[2]:= pdf[x_,x0_,sig_] := 1/(Sqrt[2Pi]sig) Exp[-(x-x0)^2/(2sig^2)];
>
> In[3]:= Sum[pdf[x,0,sig],{x,-Infinity,Infinity}]
>
> 2
> -1/(2 sig )
> EllipticTheta[3, 0, E ]
> Out[3]= ---------------------------------
> Sqrt[2 Pi] sig
>
> In[4]:= f[sig_]=%;
>
> In[5]:= f'[1.]
>
> (0,0,1)
> Out[5]= -1. + 0.241971 EllipticTheta [3, 0, 0.606531]
>
> I expected to see a number on this last line.
>
> Scott
> --
> Scott Hemphill hemphill at alumni.caltech.edu
> "This isn't flying. This is falling, with style." -- Buzz Lightyear
>
You can get correct numerical answer by using instead of f'[1.]
N[f'[1],10]
0.0193719
Note that simply N[f'[1]] will not work. This is reasonable because
using MachinePrecision would not produce an accurate answer. You can
see this by defining your function in a somewhat different way.
Replace your definition
f[sig_]=%
with
f[sig_?NumericQ] = %;
Now you can differenitate numerically (but not in Mathematica 6 !)
f'[1.]
-2.115267372136438*^-7
The only problem is that this answer is clearly wrong. This is due to
numerical instability of this problem which makes it unsuited to
using MachinePrecision numbers.
Andrzej Kozlowski
Prev by Date:
**Re: Ordering function weird?**
Next by Date:
**Re: Ordering function weird?**
Previous by thread:
**Can't calculate numerical derivative of EllipticTheta**
Next by thread:
**Re: Can't calculate numerical derivative of EllipticTheta**
| |