From: Cristobal Navarro on
Hello everyone!
this is my first message,

i am having a problem with numerical derivative, which i think is related to logarithm issues.

I have a set of points (v,Z(v)) which i call them the Z function.
for example:

Z(v): http://dl.dropbox.com/u/6380744/img/zfunction.png

from Z, i can get U.

U(v) = (1+v)*d(log(Z))/dv

and U Should look like this:

U(v) = http://dl.dropbox.com/u/6380744/img/ufunction.png

Where is The Problem?:

I have a C/C++ program which does numerically the same steps. First i compute Z Function and i get the same one as the reference which was done in Mathematica symbolically.

Numerical Z(v): http://dl.dropbox.com/u/6380744/img/zNumeric.png

but when computing U, i get errors near v=-1.0
U = http://dl.dropbox.com/u/6380744/img/uNumeric.png

i am computing the numerical derivative at each point with this method.

f(x)' = [f(x+h) - f(x-h)] / 2h

and i am using double presicion.
you guys have much knowledge on mathematics than me, what is the problem with that tail effect on U near v=-1.0 ??
is there a way to solve it?

in case you want to reproduce the problem,
here is the Z function data.
http://dl.dropbox.com/u/6380744/zData.txt
any help is welcome, best regards
Cristobal
From: Rob Johnson on
In article <229418221.27156.1279666093138.JavaMail.root(a)gallium.mathforum.org>,
Cristobal Navarro <axischire(a)gmail.com> wrote:
>i am having a problem with numerical derivative, which i think is related to logarithm issues.
>
>I have a set of points (v,Z(v)) which i call them the Z function.
>for example:
>
>Z(v): http://dl.dropbox.com/u/6380744/img/zfunction.png
>
>from Z, i can get U.
>
>U(v) = (1+v)*d(log(Z))/dv
>
>and U Should look like this:
>
>U(v) = http://dl.dropbox.com/u/6380744/img/ufunction.png
>
>Where is The Problem?:
>
>I have a C/C++ program which does numerically the same steps. First
>i compute Z Function and i get the same one as the reference which
>was done in Mathematica symbolically.
>
>Numerical Z(v): http://dl.dropbox.com/u/6380744/img/zNumeric.png
>
>but when computing U, i get errors near v=-1.0
>U = http://dl.dropbox.com/u/6380744/img/uNumeric.png
>
>i am computing the numerical derivative at each point with this
>method.
>
>f(x)' = [f(x+h) - f(x-h)] / 2h
>
>and i am using double presicion.
>you guys have much knowledge on mathematics than me, what is the
>problem with that tail effect on U near v=-1.0 ??
>is there a way to solve it?
>
>in case you want to reproduce the problem,
>here is the Z function data.
>http://dl.dropbox.com/u/6380744/zData.txt

It appears that Z vanishes at v = -1.0. The problem most likely
arises because log(Z) blows up near v = -1.0. However, U does not
blow up since (1+v) vanishes near v = -1.0 (faster than log(Z) blows
up). Unfortunately, you need to compute log(Z) before you can take
its derivative and multiply by (1+v).

Since your data only goes to -.999000 in -.000999 steps, I don't
know what method for taking the derivative at -1.0 is. The data
for Z appears to be approaching 0 at -1 quadratically. However,
I would guess that a numerical derivation program might try to
extrapolate the data linearly, in which case the value of Z(-1)
would be negative, which would cause a problem when taking the
logarithm.

Rob Johnson <rob(a)trash.whim.org>
take out the trash before replying
to view any ASCII art, display article in a monospaced font
From: Cristobal Navarro on
thanks for the comments,

i think i have an idea.

i will try to compute it to a certaing value of v close to -1.0, and the rest of the curve i will try to extrapolate with a polinomial.