Add the keyword degree=2
when creating the Expression
's:
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
g = Expression("sin(5*x[0])", degree=2)
That said, you are using a version of FEniCS that is not compatible with the demo you are looking at (version 1.5.0). You should make sure that the documentation you are reading matches the version of FEniCS that you are using.