Sorry for the title, I struggled to describe my problem concisely.

I have a function \phi(p,Z) which is evaluated on a grid `pgrid`

, `Zgrid`

and available as a matrix `phi`

. My goal is to calculate the second derivative (later also first one) with respect to the parameter p. For that I employed a simple finite difference method, but I encountered some unusually large derivatives. I traced it back to the following problem:

- \phi(p,Z) has two nodes as a function of Z (actually the positions are symmetric wrt Z=0)
- The position of the nodes and extrema is moving depending on p
- The matrix
`phi[:,:]`

was determined by finding a specific eigenvector for many values of`p`

and storing that vector into the row`phi[p,:]`

.

Moving of zeros and extremas of \phi(p,Z) with p:

Since the eigenvectors came from many separate calls to an eigensolver routine, the global sign of each eigenvector is arbitrary. Hence, in the matrix `phi`

it changes for each value of p, i.e. I have many artificial oscillations. As a result the calculation of the second derivative has huge errors.

Arbitrary global sign of \phi(p,Z) with p:

I had a similar problem in the past, however for nodeless eigenfunctions (i.e. they were either purely positive, or purely negative). There, it was easy to enforce the same global sign by dividing by the sign of the function at a specific point, e.g. the central point). However in my current case, the function approaches zero at the edges (i.e. random Â± 1e-16), and the central point can be either a zero or an extremum.

Just to be clear: I understand that this is not a problem of the eigensolver routine, but normal behavior. But does anyone have a good idea how to ensure the same â€śglobalâ€ť sign of \phi, such that the behavior as a function of p is smooth?