The background is as follows: I consider the following differential equation

$$\phi_{xx}+u\phi=\lambda \phi,\ \ \lambda=-k^2$$

where $u=u(x),\ \phi=\phi(x,\lambda)$, $\lambda$ is the spectral parameter.

I designed a new solving algorithm that can numerically solve the above equation. I want to test the performance of my algorithm, so I hope to generate some random $u$ for testing, but I require these random $u$ to satisfy some conditions, such as tends to $0$ at infinity.

I know that without additional conditions, we can use Gaussian Random Field (GRF) to generate a random function with certain continuity within a certain interval (in numerical form, of course.)

But if I have additional conditions, like the conditions we mentioned above, or conditions that require equal to 0 at the two endpoints $[x_L, x_R]$, what method should I use to generate them?

  • $\begingroup$ How smooth do you want your $u$ to be? Non-smooth, maybe even discontinuous, $u$ are likely to create challenges for numerical methods. $\endgroup$ Nov 28, 2023 at 15:59
  • $\begingroup$ @Robert Israel If it is an exact expression, the minimum requirement is continuous, and of course $C^{\infty}$ is better. If it is discrete, it is not easy to talk about continuity, but it is required to change as gently as possible. Just like when using the radial basis function as the covariance function of GRF, there is a parameter that can control the continuity of the random function of the generated value. $\endgroup$ Dec 1, 2023 at 10:00

1 Answer 1


You can simulate functions $u$ vanishing at $\infty$ using the formula $$u(x)=u_N(x):=\sum_{n=0}^N \xi_n l_n(x),$$ where $N$ is a natural number, the $\xi_n$'s are independent standard normal (or other) random variables, $l_n(x):=e^{-x/2}L_n(x)$, and $L_n(x)$ is the $n$th Laguerre polynomial, so that the $l_n$'s form a complete orthonormal sequence in $L^2(0,\infty)$. Of course, you can rescale this $u$ horizontally and/or vertically.

If you also want $u$ to vanish at $0$, you can similarly use the generalized Laguerre polynomials.

If you want $u$ to vanish at both $\infty$ and $-\infty$, you can similarly use the Hermite polynomials.

If you want $u$ to vanish at the endpoints of a finite interval, you can similarly use the Chebyshev polynomials.

Much more on orthogonal polynomials can be found in Szegő's book.

  • $\begingroup$ Thanks for your reply, but it seems that the construction using Laguerre polynomials only decays exponentially to 0 on one side, but does not satisfy my requirements on the other side. $\endgroup$ Dec 1, 2023 at 9:40
  • $\begingroup$ @miaozhengwu : Your post does not mention "the other side". When one says "infinity", it usually means $\infty$, which means $+\infty$ in the context of real numbers. Please try to be maximally precise and specific when asking questions, so as not to waste your own and other people's time. Anyhow, If you want $u$ to vanish at both $\infty$ and $-\infty$, you can similarly use the Hermite polynomials, as is now stated in the answer. Please let me know if you have other concerns about this answer. $\endgroup$ Dec 1, 2023 at 14:33
  • $\begingroup$ Thank you for your prompt reply and I apologize for not clarifying the question clearly. My problem has been solved. $\endgroup$ Dec 1, 2023 at 14:53
  • $\begingroup$ @miaozhengwu : Then the following guidelines may be relevant here. $\endgroup$ Dec 1, 2023 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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