I am trying to plot this function $f$ which satisfies $f$ bounded, monotone, $C^\infty$, but $f'(x) \nrightarrow 0$ as $x\rightarrow\infty$. I am running a linux computer with mathematica 12.3. My code is

h[x_] := Piecewise[{{Exp[100]*Exp[-1/x^2 - 1/(x - 1)^2], 
0 < x < 1 }},0]

g[x_] := h[Floor[x]^2 (x - Floor[x])]

f[x_] := NIntegrate[g[t], {t, 0, x}]


However the output is enter image description here

The Exp[100] is there because otherwise I get this error: NIntegrate

How can I fix this to see this beauty?

  • 2
    $\begingroup$ Works for me on Mac running Mathematica 13.0. $\endgroup$
    – B flat
    Dec 30, 2021 at 7:27
  • 2
    $\begingroup$ I get this plot when I run your code. I am on v12.2.0 Win7-x64. Please restart Mathematica and try with a fresh kernel. $\endgroup$
    – Syed
    Dec 30, 2021 at 8:00
  • $\begingroup$ Without more information, my best guess is that you have not actually assigned h. $\endgroup$ Dec 30, 2021 at 9:11
  • 1
    $\begingroup$ I get the same plot as user: Syed when I run your code. I am on v13.0. Win10-x64. $\endgroup$ Dec 30, 2021 at 14:06
  • 1
    $\begingroup$ As a general rule, the arguments of functions that use numeric techniques should be restricted to numeric values, e.g., f[x_?NumericQ] := NIntegrate[g[t], {t, 0, x}] $\endgroup$
    – Bob Hanlon
    Dec 30, 2021 at 15:22

1 Answer 1


Put in semicolons. Works fine:

enter image description here


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