This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Interpolation of expression results in negative numbers with non-negative data.

0 votes

Hello,

I have some data that I use to initialize a Function which is non-negative. Upon interpolation, the Function contains negative values.

Can anyone explain or provide a reference for why this happens? Also, is there a nifty way to prevent this from happening without explicitly setting the negative values to zero?

Thanks!

asked Jan 22, 2014 by pf4d FEniCS User (2,970 points)

1 Answer

+3 votes
 
Best answer

Example: Assume you have data points (x, y): (-1, 0.5), (0.9, 0.31) and (1, 0.5) and try to fit a second order polynomial (y = f(x) ) to these (for instance f(x) = x^2 - 0.5) . Then, there are c such that f(c) < 0 for instance c = 0 even though all your y data are positive.

More information (like a minimal running code example) would be useful in order to provide more hints.

answered Jan 22, 2014 by Marie E. Rognes FEniCS User (5,380 points)
selected Jun 12, 2014 by pf4d
...