4

How do I define the following function in Sage and compute some values?

The function is $$P(n) = \sqrt{\frac{e^{-h}h^n}{n!}},$$

where $h$ is a real variable and $n$ is a nonnegative integer. I want to see the values of $P(n)$ for $h = 20$ from $n = 0$ to $n = 50$.

After this, I would like to use the function in other formulas such as $$A(n,t) = P(n)\cos(t\sqrt(n+1))\cos(\theta) - iP(n+1)$$

So, if you help me out with computing $P(n),$ I think I will be able to do the rest. Thank you!

  • I think I just did it. All I needed to do was print in the command box the following code: "P(n) = sqrt(((exp(-h))*h^n)/(factorial(n)))" – Holden Karl Jul 24 '13 at 19:13
  • For questions about Sage syntax, the Q&A site http://ask.sagemath.org is usually a better choice. – 40 votes Jul 24 '13 at 22:25

1 Answers1

4
sage: var('h')
h
sage: P(n) = sqrt(e^-h * h^n/factorial(n))
sage: points((n,P(n).subs(h=20)) for n in [0..50])

enter image description here

kcrisman
  • 2,195