# From python function to UFL expression

I fear this post is poor even for my low standards, but for the life of me I could not find a solution after quite a search.
I would like to understand a bit more about UFL, for one how to translate a function to an UFL expression.
Looking for example at the Poisson Tutorial v4.0, I see this code snipped

``````import ufl
from petsc4py.PETSc import ScalarType
x = ufl.SpatialCoordinate(domain)
beta = fem.Constant(domain, ScalarType(12))
R0 = fem.Constant(domain, ScalarType(0.3))
p = 4 * ufl.exp(-beta**2 * (x[0]**2 + (x[1] - R0)**2))
``````

to to define a Gaussian f source term.
What to do if I wanted my source term to be say a polynomial?
I search for an `UFL` method, could find all sorts of methods `ufl.asin`, `ufl.bessel ` but not anything I could use.
I fear even the cheap hack of using for example

``````ufl.ln(ufl.exp(x[0]**2))
``````

does not work, as the type of the latter expression is different from the one of the`ufl.exp()` expression above (also mysterios to me yet).

Any hints please to go from a python function to UFL, thanks a lot for your patience

Why not just use `p=x[0]**2`?

Oh it was that easy, thank you very much. I though anything that is used later to define the weak form but be somehow ufl-compliant. Is there then a particular reason to use the ufl.exp method in the tutorial, instead of say just defininf f as a function with np.exp()? Doesnot one lose some features with the approach you suggest, such e.g. ufl derivation and so, if ever needed? Thanks

`x` is defined as a ufl object, ie

This means that it is interpeted as the physical coordinate in the physical cell at evaluation, which means that during assembly it is equal to the quadrature points on the physical cell (not reference element), giving exact integration of the quadrature degree is ser suffficiently high for polynomials.