# Using interpolating polynomial inside NIntegrate

I have a PDE which I solve via

n = 20;
Theta = 0.001;
FPE = D[P[LL, v], LL] -
Theta*(.5*(1 + v)^3*
D[P[LL, v], {v, 2}] + (1 +
v)*((1 + v) + ((3*v - 1 + 2*Sqrt*Sqrt[1 + v])/4)*(1 + v))*
D[P[LL, v], v] + ((Sqrt[1 + v])/(2 Sqrt) - 1)*P[LL, v])
s = NDSolve[{FPE == 0, P[0, v] == D[Tanh[n (v - 1)], v]},
P, {LL, 0, 30}, {v, 1, 30}][]


which gives me $$P(L,v)$$ as an interpolating polynomial. I want to use this function, which is in-fact a probability density function, to calculate the mean of a quantity which is

$$\mathbb{E}[Q(L)] = \int_{1}^{\infty} \bigg(\frac{v-1}{v+1}\bigg)p(L,v)dv$$

for a fixed $$v,$$ where $$v\in[1,\infty).$$ Say $$v=2.$$

I then try to integrate this via

 NIntegrate[(v - 1)/(v + 1)*Evaluate[P[LL, v] /. s], {v, 1, 1000},
Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0,
"MaxErrorIncreases" -> 10000, "SingularityHandler" -> "IMT"},
MaxRecursion -> 100, PrecisionGoal -> 4]


which gives a value if I set the $$LL$$ to be a number. How can I plot this integral with the value of it on the $$y$$ axis and $$LL$$ on the x-axis?

Simply define a function with SetDelayed:

int[LL_] := NIntegrate[(v - 1)/(v + 1)*Evaluate[P[LL, v] /. s], {v, 1, 1000},
Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0,
"MaxErrorIncreases" -> 10000, "SingularityHandler" -> "IMT"},
MaxRecursion -> 100, PrecisionGoal -> 4]


Note however that you provide only one BC for a second-order ODE, hence the error:

NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable v. Artificial boundary effects may be present in the solution.

The plot below might therefore be meaningless.

Plot[int[LL], {LL, 0, 10}] • Hi thanks for your help. Yes I understand that problem with the conditions. I'm trying to enforce some boundary conditions. I think I should assume that $p$ tends to 0 as L and eta tend to infinity. – rami_salazar Feb 7 '20 at 16:12