Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list of numbers that are numerical samples of a function for which I need to find the Cauchy principal value integral. I thought I should be able to combine Interpolation with Integrate to do this, but it appears not. A simple function that shows this problem is 1/x. If the actual function is known Mathematica can do the integral.

Integrate[1/x, {x, -1, 2}, PrincipalValue -> True]

giving the answer Log[2]. But if I only have a numerical approximation to this function the "obvious" way to try this does not work.

foo = Interpolation[Table[{x, 1/x}, {x, -1.1, 2.1, 0.0123}]]
Integrate[foo[x], {x, -1, 2}, PrincipalValue -> True]

gives the error message General::ivar: "PrincipalValue->True is not a valid variable."

Can anyone tell me how to estimate the Cauchy principal value integral of a numerically sampled function?

share|improve this question
"Can anyone tell me how to estimate the Cauchy principal value integral of a numerically sampled function?" - depends. Do you know where the singularity is located? – J. M. May 30 '13 at 16:54
Yes. I know where the singularity is. How would it be done for my example problem 1/x where singularity is known to be at x=0 ? – Simon May 31 '13 at 10:36
You need to choose or come up with a method for approximating the CPV. Then this site can help you implement it. The naive way of doing (just implementing the definition) produces results rather sensitive to how the function was sampled. Perhaps you should consider asking for mathematical methods on math.SE. – Michael E2 May 31 '13 at 20:36
The purpose of my question is to check if Mathematica already has a way of handling principal value integration for sampled functions. It does for analytical functions, e.g., Integrate[1/x, {x, -1, 2}, PrincipalValue -> True], and it has for functions that require numerical integration, e.g., NIntegrate[1/(x - x^2), {x, -1, 0, 1, 2}, Method -> {"PrincipalValue", "SingularPointIntegrationRadius" -> 1/4}] – Simon Jun 3 '13 at 12:06
I was checking that I'd not missed something for lists, either built-in or as an add-on package. – Simon Jun 3 '13 at 12:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.