# finding min S such that integral is greater than some value

I have this function $$R(r)$$, and $$r*R^2$$ is a probability density function.

R[n_, l_, r_] :=
Sqrt[(n - l - 1)!/(2*n*((l + 1)!)^3)]*(2/(n*a))^(l + 1/2)*
D[LaguerreL[n + l, (2*r)/(n*a)], {r, 2*l + 1}]*r^l*Exp[-r/(n*a)]


I am basically trying to find the value of $$s$$ such that the integral of the function $$R(r)$$ as $$r$$ goes from $$0$$ to $$s$$ is $$95\%$$ probability.

In the function below, I need the argmin $$s$$ such that the integral value is at least $$0.95$$. Solve didn't work for an exact number. How do I set it up to solve for "at least" 0.95?

Solve[Integrate[(r*R[1, 0, r])^2, {r, 0, s}] == 0.95, s]


Integrate[(r*R[1, 0, r])^2, {r, 0, s}] /. s -> σ*a // FullSimplify
(*    1 + E^(-2σ) (-1 - 2σ (1 + σ))    *)

FindRoot[% == 0.95, {σ, 3}]
(*    {σ -> 3.1479}    *)


In one line:

FindRoot[Integrate[(r*R[1, 0, r])^2, {r, 0, σ*a}] == 0.95, {σ, 3}]
(*    {σ -> 3.1479}    *)

• Or as analytical Root expression: Solve[Integrate[(r*R[1, 0, r])^2, {r, 0, \[Sigma]*a}] == 95/100, \[Sigma], Reals]  yields {{\[Sigma] -> Root[{-20 + E^(2 #1) - 40 #1 - 40 #1^2 &, 3.14789681093599487090}]}}  Commented Sep 6, 2021 at 17:20
• @Akku14 isn't the Root object just a camouflaged FindRoot in practice? Commented Sep 6, 2021 at 19:34
• It's great. Did we just get lucky that the acanceled in that expression? Would it not have worked if a did not cancel? Commented Sep 9, 2021 at 15:46
• @Frank It's not a coincidence that $a$ cancelled. The integrand looks like a radial quantum wave function ($R$ is the radial wave function and $r^2$ the Jacobian) and $a$ is its length scale. So by dimensional analysis the result must be a multiple of $a$. Commented Sep 9, 2021 at 17:23