Re: numerical derivatives at very high x-values: precision problem
- To: mathgroup at smc.vnet.net
- Subject: [mg64039] Re: [mg64021] numerical derivatives at very high x-values: precision problem
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Sat, 28 Jan 2006 02:24:05 -0500 (EST)
- References: <200601271013.FAA19073@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Nadir Kaplan wrote: >Hi, > >When calculating partial numerical derivatives, namely the formula [f(x+h, >y)-f(x-h, y) ] / (2h), at very high x values, let's say x~10^12 , I should > > I think you can do this using NDSolve`FiniteDifferenceDerivative in the NDSolve Advanced Documentation Hope this helps Pratik >choose h=(10^a)*|x| where x should be <-16 in order to get accurate results. >We know that the MachineEpsilon is approx. 2.2*10^(-16) , but I think I >should somehow use a number less than that for h, otherwise the answers are >not satisfiying. How will I do this in order to get high precision (or >accuracy) ? I added SetPrecision command everywhere, but it seems it didn't >work out well, besides it looks dumb (or not? I'm new at Mathematica ). > > > >Any help will be appreciated... > > > >The values are f.e. (from a set of recursion relations) : > >---------------------------------------------------------------------------- > >J[40]= 1.12970494019605678505771742460*10^12 > >mu[40]= 3.38911605114868836337349826143*10^12 > >V[40]= -8.47278910237611083984375000000*10^11 > >T1[40]= 5.64852470100879638671875000000*10^11 > > > >The function to be partial-differentiated: > >------------------------------------------------------------ > >lngamma1[J_, mu_, V_, t1_]:= > > Module[{mu2, U1, U2, Umax}, mu2=SetPrecision[mu/(2*d), 30]; > > U1=SetPrecision[0, 30]; > > U2=SetPrecision[1.5*mu2+func1[0.5*mu2, t1], 30]; > > Umax= Max[U1, U2]; > > >SetPrecision[Umax+Log[Exp[U1-Umax]+2*Exp[U2-Umax]*func2[0.5*mu2, t1]], 30] > > ] > > > >The derivative formula: > >---------------------------------------------------------------- > >derivt1[func_, J_, mu_, V_, t1_]:= > > Module[ {h}, h=SetPrecision[10^-15*Abs[t1],30] ; > > SetPrecision[(func[J, mu, V, t1+h]-func[J, mu, V, t1-h])/(2*h), 30] > > ] > > > >
- References:
- numerical derivatives at very high x-values: precision problem
- From: "Nadir Kaplan" <nadir.kaplan@pclabs.gen.tr>
- numerical derivatives at very high x-values: precision problem