1
$\begingroup$

When I execute this code:

\[Sigma] = 0.3;
\[Mu] = 5;
xmax = 10;
f[x_]= Exp [-(1/2) ((x - \[Mu])/\[Sigma])^2]/(\[Sigma]*Sqrt[2*\[Pi]]);
Plot[f[x], {x, 0, xmax}, PlotRange -> {0, +2}]

I get the plot:

enter image description here

But when I change f to g..

\[Sigma] = 0.3;
\[Mu] = 5;
xmax = 10;
g[x_]= Exp [-(1/2) ((x - \[Mu])/\[Sigma])^2]/(\[Sigma]*Sqrt[2*\[Pi]]);
Plot[g[x], {x, 0, xmax}, PlotRange -> {0, +2}]

I do not get anything:

enter image description here

Do we always have to use f as the function being plotted? Or am I missing something important here?

$\endgroup$
5
  • 4
    $\begingroup$ Works for me. I think you have a cached definition. Try Clear[g] and give it another go $\endgroup$
    – b3m2a1
    Commented Jan 14, 2020 at 22:25
  • $\begingroup$ Ohh, I didn't know that there is such a thing. I will check. Can I disable caching completely? $\endgroup$
    – Gouz
    Commented Jan 14, 2020 at 22:27
  • 1
    $\begingroup$ Nah. It's how the functions are built into the system. Basically a bunch of pattern rules. But that means you might have an extant pattern for g or one of the constants or something that's getting in the way. $\endgroup$
    – b3m2a1
    Commented Jan 14, 2020 at 22:28
  • $\begingroup$ It worked. Thanx $\endgroup$
    – Gouz
    Commented Jan 14, 2020 at 22:30
  • 4
    $\begingroup$ I always start my function definitions with ClearAll[g] (for func. g). That's how I disable cached definitions. $\endgroup$
    – Michael E2
    Commented Jan 14, 2020 at 22:47

0