2.3. CoefficientFunctions#

In NGSolve, CoefficientFunctions are representations of functions defined on the computational domain. Examples are expressions of coordinate variables \(x, y, z\) and functions that are constant on subdomains. Much of the magic behind the seamless integration of NGSolve with python lies in CoefficientFunctions. This tutorial introduces you to them.

After this tutorial you will know how to

  • define a CoefficientFunction,

  • visualize a CoefficientFunction,

  • evaluate CoefficientFunctions at points,

  • print the expression tree of CoefficientFunction,

  • integrate a CoefficientFunction,

  • differentiate a CoefficientFunction,

  • include parameter in CoefficientFunctions,

  • interpolate a CoefficientFunction into a finite element space,

  • define vector-valued CoefficientFunctions,

  • mesh-dependant CoefficientFunctions and,

  • compile CoefficientFunctions.

from ngsolve import *
from ngsolve.webgui import Draw
import matplotlib.pyplot as plt
mesh = Mesh (unit_square.GenerateMesh(maxh=0.2))

2.3.1. Define a function#

myfunc = x*(1-x)
myfunc   # You have just created a CoefficientFunction
<ngsolve.fem.CoefficientFunction at 0x7fc6e786df70>
x     # This is a built-in CoefficientFunction
<ngsolve.fem.CoefficientFunction at 0x7fc7ac4facf0>

2.3.2. Visualize the function#

Use the mesh to visualize the function.

Draw(myfunc, mesh);

2.3.3. Evaluate the function#

mip = mesh(0.2, 0.2)
myfunc(mip)
0.16000000000000003

Note that myfunc(0.2,2) will not evaluate the function: one must give points in the form of MappedIntegrationPoints like mip above. The mesh knows how to produce them.

2.3.4. Examining functions on sets of points#

pts = [(0.1*i, 0.2) for i in range(11)]
vals = [myfunc(mesh(*p)) for p in pts] 
for p,v in zip(pts, vals):
    print("point=(%3.2f,%3.2f), value=%6.5f"
         %(p[0], p[1], v))
point=(0.00,0.20), value=0.00000
point=(0.10,0.20), value=0.09000
point=(0.20,0.20), value=0.16000
point=(0.30,0.20), value=0.21000
point=(0.40,0.20), value=0.24000
point=(0.50,0.20), value=0.25000
point=(0.60,0.20), value=0.24000
point=(0.70,0.20), value=0.21000
point=(0.80,0.20), value=0.16000
point=(0.90,0.20), value=0.09000
point=(1.00,0.20), value=0.00000

Here is the vectorized version of the same code using numpy.

import numpy as np
X = np.linspace(0, 1, num=11)
Y = np.ones_like(X) * 0.2
myfunc(mesh(X, Y))
array([[0.  ],
       [0.09],
       [0.16],
       [0.21],
       [0.24],
       [0.25],
       [0.24],
       [0.21],
       [0.16],
       [0.09],
       [0.  ]])

We may plot the restriction of the CoefficientFunction on a line using matplotlib.

X = np.linspace(0, 1, num=100)
Y = np.ones_like(X) * 0.2
plt.plot(X, myfunc(mesh(X, Y)))
plt.xlabel('x')
plt.show()
../_images/e7ec401a9e4bcb7659352fef3b82ea68d0c9394a8af54a6fefba2fc1a5996a41.png

2.3.5. Expression tree of a function#

Internally, coefficient functions are implemented as an expression tree made from building blocks like x, y, sin, etc., and arithmetic operations. (Knowing this will provide context for the later discussion of speeding up their evaluations.) For example, the expression tree for myfunc = x*(1-x) looks like this:

print(myfunc) 
coef binary operation '*', real
  coef coordinate x, real
  coef binary operation '-', real
    coef 1, real
    coef coordinate x, real

2.3.6. Integrate a function#

We can numerically integrate the function using the mesh:

Integrate(myfunc, mesh, order=5)
0.166666666666666

You can change the precision of the quadrature rule used for the integration using the key word argument order.

2.3.7. Differentiate a function#

Automatic differentiation of a CoefficientFunction is possible through the Diff method. Here is how you get \(\partial / \partial x\) of myfunc:

diff_myfunc = myfunc.Diff(x)
Draw(diff_myfunc, mesh, "derivative");

See if you can recognize an implementation of the product rule

\[ \frac{\partial}{\partial x} x (1-x) = \frac{\partial x}{\partial x} (1-x) + x\frac{\partial (1-x)}{\partial x} \]

in the tree-representation of the differentiated coefficient function, printed below.

print(diff_myfunc)
coef binary operation '+', real
  coef binary operation '*', real
    coef coordinate x, real
    coef scale -1, real
      coef 1, real
  coef binary operation '*', real
    coef binary operation '-', real
      coef 1, real
      coef coordinate x, real
    coef 1, real

2.3.8. Parameters in functions#

When building complex coefficient functions from simple ones like x and y, you may often want to introduce Parameters, which are constants whose value may be changed later.

k = Parameter(2.0)
f = sin(k*y)
Draw(f, mesh);

The same f may be given a different value of k later:

k.Set(10)
Draw(f, mesh, order=3);

Look at the expression tree of f:

print(f)
coef unary operation 'sin', real
  coef binary operation '*', real
    coef N5ngfem28ParameterCoefficientFunctionIdEE, real
    coef coordinate y, real

Note how the parameter is now a node in the expression tree. You can differentiate a coefficient function with respect to such quantities by passing it as argument to Diff:

print (f.Diff(k))
coef binary operation '*', real
  coef unary operation 'cos', real
    coef binary operation '*', real
      coef N5ngfem28ParameterCoefficientFunctionIdEE, real
      coef coordinate y, real
  coef binary operation '*', real
    coef coordinate y, real
    coef 1, real
Integrate((f.Diff(k) - y*cos(k*y))**2, mesh)
0.0

2.3.9. Interpolate a function#

We may Set a GridFunction using a CoefficientFunction:

fes = H1(mesh, order=1)
u = GridFunction(fes)
u.Set(myfunc)
Draw(u); 
  • The Set method interpolates myfunc to an element u in the finite element space.

  • Set does an Oswald-type interpolation as follows:

    • It first zeros the grid function;

    • It then projects myfunc in \(L^2\) on each mesh element;

    • It then averages dofs on element interfaces for conformity.

2.3.10. Vector-valued CoefficientFunction#

Here is an example of a vector-valued coefficient function.

vecfun = CoefficientFunction((-y, sin(x)))

Instead of writing the long name, you can abbreviate:

vecfun = CF((-y, sin(6*x)))   # CF = CoefficientFunction

To draw the vector field in the webgui using arrows, use the vectors keyword argument.

Draw(vecfun, mesh, vectors=True);

Another example of a vector-valued coefficient function is the gradient of a scalar GridFunction. Here is an example using the above-set GridFunction called u. The colors represent the magnitude of the vector field and the arrows give the direction.

u.Set(myfunc)
gradu = grad(u)
Draw(gradu, mesh, vectors={"grid_size":30});

2.3.11. Mesh-dependant CoefficientFunctions#

From a mesh it is possible to define different coefficient functions (more on creation of domains and meshes in the next unit.)

Ignore this cell and go to the next one.

from netgen.occ import *

outer = Circle((0,0), 1).Face()
outer.faces.name = 'outer'
outer.edges.name = 'nonshared'
inner = Circle( (0,0), 0.2).Face()
inner.faces.name = 'inner'
inner.edges.name = 'shared'

geo = Glue([outer - inner, inner])
mesh = Mesh(OCCGeometry(geo , dim=2).GenerateMesh(maxh=0.1))
gfu = GridFunction(H1(mesh))


Draw(mesh)
BaseWebGuiScene

Look at the names in the mesh above !

# pass a dict of values
domain_values = {'inner': 3.7,  'outer': x*y}
materialCF = mesh.MaterialCF(domain_values)

gfu.Set(materialCF)

Draw(gfu, mesh, 'material')
BaseWebGuiScene
boundary_values = {'nonshared': -(x*x -y), 'shared': 1}
boundaryCF = mesh.BoundaryCF(boundary_values, default=0)


gfu.Set(boundaryCF, definedon=mesh.Boundaries('nonshared|shared'))

Draw(gfu, mesh, 'material')
BaseWebGuiScene

2.3.12. Compiled CoefficientFunction#

Evaluation of a CoefficientFunction at a point is usually done by traversing its expression tree and evaluating each node of the tree. When the tree has repeated nodes, this is likely wasteful. NGSolve allows you to “compile” a CoefficientFunction to increase the efficiency of its evaluation. The compilation translates the expression tree into a sequence of linear steps.

Continuing with our simple myfunc example, here is how to use the Compile method:

myfunc_compiled = myfunc.Compile()

Now look at the differences between the compiled and non-compiled CoefficientFunction:

print(myfunc)
coef binary operation '*', real
  coef coordinate x, real
  coef binary operation '-', real
    coef 1, real
    coef coordinate x, real
print(myfunc_compiled)
Compiled CF:
Step 0: coordinate x
Step 1: 1
Step 2: binary operation '-'
     input: 1 0 
Step 3: binary operation '*'
     input: 0 2 

Evaluation of the compiled function is now a linear sequence of Steps 0, 1, 2, and 3 above. The output description of Steps 2 and 3 above means the following:

  • Step 2: (Output of Step 1) - (Output of Step 0)

  • Step 3: (Output of Step 0) * (Output of Step 2)

Here is another example, along with differences in timings for integrating the same coefficient function, in three different forms, on the same mesh.

f0 = myfunc
f1 = f0*y 
f2 = f1*f1 + f1*f0 + f0*f0 
f3 = f2*f2*f2*f0**2 + f0*f2**2 + f0**2 + f1**2 + f2**2

final = f3 + f3 + f3 
finalc = final.Compile()
%timeit Integrate(final, mesh, order=10)
8.39 ms ± 20.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
%timeit Integrate(finalc, mesh, order=10)
597 µs ± 303 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

Clearly these experiments show that the evaluation of an expression tree can be made faster by compiling the tree into a set of linear instructions. This conclusion is also supported by looking at the long outputs of the expression tree with and without the compile option.

print(finalc)
Compiled CF:
Step 0: coordinate x
Step 1: 1
Step 2: binary operation '-'
     input: 1 0 
Step 3: binary operation '*'
     input: 0 2 
Step 4: coordinate y
Step 5: binary operation '*'
     input: 3 4 
Step 6: binary operation '*'
     input: 5 5 
Step 7: binary operation '*'
     input: 5 3 
Step 8: binary operation '+'
     input: 6 7 
Step 9: binary operation '*'
     input: 3 3 
Step 10: binary operation '+'
     input: 8 9 
Step 11: binary operation '*'
     input: 10 10 
Step 12: binary operation '*'
     input: 11 10 
Step 13: binary operation '*'
     input: 3 3 
Step 14: binary operation '*'
     input: 12 13 
Step 15: binary operation '*'
     input: 10 10 
Step 16: binary operation '*'
     input: 3 15 
Step 17: binary operation '+'
     input: 14 16 
Step 18: binary operation '*'
     input: 3 3 
Step 19: binary operation '+'
     input: 17 18 
Step 20: binary operation '*'
     input: 5 5 
Step 21: binary operation '+'
     input: 19 20 
Step 22: binary operation '*'
     input: 10 10 
Step 23: binary operation '+'
     input: 21 22 
Step 24: binary operation '+'
     input: 23 23 
Step 25: binary operation '+'
     input: 24 23 

Without compilation the expression tree for this function exceeds 1000 nodes, while with compilation it is reduced to 4 nodes.

print(final)
coef binary operation '+', real
  coef binary operation '+', real
    coef binary operation '+', real
      coef binary operation '+', real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef binary operation '+', real
                    coef binary operation '+', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '+', real
                    coef binary operation '+', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef binary operation '*', real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef coordinate y, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef coordinate y, real
      coef binary operation '*', real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
    coef binary operation '+', real
      coef binary operation '+', real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef binary operation '+', real
                    coef binary operation '+', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '+', real
                    coef binary operation '+', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef binary operation '*', real
                            coef coordinate x, real
                            coef binary operation '-', real
                              coef 1, real
                              coef coordinate x, real
                          coef coordinate y, real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef binary operation '*', real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef coordinate y, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef coordinate y, real
      coef binary operation '*', real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '+', real
          coef binary operation '+', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '*', real
                  coef coordinate x, real
                  coef binary operation '-', real
                    coef 1, real
                    coef coordinate x, real
                coef coordinate y, real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
  coef binary operation '+', real
    coef binary operation '+', real
      coef binary operation '+', real
        coef binary operation '+', real
          coef binary operation '*', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '+', real
                  coef binary operation '+', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef binary operation '*', real
                          coef coordinate x, real
                          coef binary operation '-', real
                            coef 1, real
                            coef coordinate x, real
                        coef coordinate y, real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
              coef binary operation '+', real
                coef binary operation '+', real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '*', real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
            coef binary operation '*', real
              coef binary operation '+', real
                coef binary operation '+', real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '*', real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
              coef binary operation '+', real
                coef binary operation '+', real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                  coef binary operation '*', real
                    coef binary operation '*', real
                      coef binary operation '*', real
                        coef coordinate x, real
                        coef binary operation '-', real
                          coef 1, real
                          coef coordinate x, real
                      coef coordinate y, real
                    coef binary operation '*', real
                      coef coordinate x, real
                      coef binary operation '-', real
                        coef 1, real
                        coef coordinate x, real
                coef binary operation '*', real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
                  coef binary operation '*', real
                    coef coordinate x, real
                    coef binary operation '-', real
                      coef 1, real
                      coef coordinate x, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
      coef binary operation '*', real
        coef binary operation '*', real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
          coef coordinate y, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
          coef coordinate y, real
    coef binary operation '*', real
      coef binary operation '+', real
        coef binary operation '+', real
          coef binary operation '*', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
      coef binary operation '+', real
        coef binary operation '+', real
          coef binary operation '*', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
          coef binary operation '*', real
            coef binary operation '*', real
              coef binary operation '*', real
                coef coordinate x, real
                coef binary operation '-', real
                  coef 1, real
                  coef coordinate x, real
              coef coordinate y, real
            coef binary operation '*', real
              coef coordinate x, real
              coef binary operation '-', real
                coef 1, real
                coef coordinate x, real
        coef binary operation '*', real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real
          coef binary operation '*', real
            coef coordinate x, real
            coef binary operation '-', real
              coef 1, real
              coef coordinate x, real