0
votes

I'm trying to plot the following function but with no result. It's a very complex funtion and I don't really know if this is the reason or it's just a stupid mistake since I'm not very familiar with Wolfram. Any suggestion on how to solve this problem even in other languages is more than welcome.

f[y_, n_] := n*exp (-n^2/y)/(sqrt (Pi)*y^((n + 3)/2))*(HermiteH[n, (y + 2 n)/(2*sqrt (y))] - 
    sqrt (y)*HermiteH[n - 1, (y + 2 n)/(2*sqrt (y))])

Plot[f[y, 500], {y, 0, 6000}]

Thank you

2
Python and Mathematica as tags? The mathematical function looks like it's written using Python syntax and the rest looks like Mathematica. You cannot mix both syntax. Use Exp[], Sqrt[], etc... - Gilles-Philippe Paillé

2 Answers

1
votes

When I try Gilles-Philippe Paillé's example in version 12 I get

General munfl 4.697873421421826967046763728`16.*^-9856 is too small to represent as a
normalized machine number, precision may be lost.

repeated over and over followed by what looks like an empty plot

Try this as a work-around

f[y_, n_] := n*Exp[-n^2/y]/(Sqrt[Pi]*y^((n + 3)/2))*(HermiteH[n, (y + 2 )/
  (2*Sqrt[y])] - Sqrt[y]*HermiteH[n - 1, (y + 2 n)/(2*Sqrt[y])]);
ListPlot[Table[f[y, 500], {y, 10, 6000,10}],PlotRange->All,Joined->True]

which still gives me warnings about the size of numbers, but displays the plot afterwards. (I start the table at 10 to avoid the division by zero)

1
votes

Considering the tags of your question, you mixed Python and Mathematica. The following code works on Mathematica 10.4 (see Bill's answer for version 12):

f[y_, n_] := n*Exp[-n^2/y]/(Sqrt[Pi]*y^((n + 3)/2))*(HermiteH[n, (y + 2 n)/(2*Sqrt[y])] -
    Sqrt[y]*HermiteH[n - 1, (y + 2 n)/(2*Sqrt[y])])
Plot[f[y, 500], {y, 0, 6000}, PlotRange -> All]