0
$\begingroup$

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[2]*Sqrt[1 + v])/4)*(1 + v))*
      D[P[LL, v], v] + ((Sqrt[1 + v])/(2 Sqrt[2]) - 1)*P[LL, v])
s = NDSolve[{FPE == 0, P[0, v] == D[Tanh[n (v - 1)], v]}, 
   P, {LL, 0, 30}, {v, 1, 30}][[1]]

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?

$\endgroup$
1
$\begingroup$

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}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – rami_salazar Feb 7 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.