This page was generated from unit-1.2-coefficient/coefficientfunction.ipynb.

1.2 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, and

  • compile CoefficientFunctions.

[1]:
from ngsolve import *
from ngsolve.webgui import Draw
from netgen.geom2d import unit_square
import matplotlib.pyplot as plt
mesh = Mesh (unit_square.GenerateMesh(maxh=0.2))

Define a function

[2]:
myfunc = x*(1-x)
myfunc   # You have just created a CoefficientFunction
[2]:
<ngsolve.fem.CoefficientFunction at 0x7f4b910e4b80>
[3]:
x        # This is a built-in CoefficientFunction
[3]:
<ngsolve.fem.CoefficientFunction at 0x7f4be866d770>

Visualize the function

Use the mesh to visualize the function in Netgen’s GUI.

[4]:
Draw(myfunc, mesh, "firstfun")
[4]:
BaseWebGuiScene

Evaluate the function

[5]:
mip = mesh(0.2, 0.2)
myfunc(mip)
[5]:
0.16000000000000003

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

Examining functions on sets of points

[6]:
pts = [(0.1*i, 0.2) for i in range(10)]
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

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

[7]:
px = [0.01*i for i in range(100)]
vals = [myfunc(mesh(p,0.5)) for p in px]
plt.plot(px,vals)
plt.xlabel('x')
plt.show()
../../_images/i-tutorials_unit-1.2-coefficient_coefficientfunction_13_0.png

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.

E.g., the expression tree for myfunc = x*(1-x) looks like this:

[8]:
print(myfunc)
coef binary operation '*', real
  coef coordinate x, real
  coef binary operation '-', real
    coef 1, real
    coef coordinate x, real

Integrate a function

We can numerically integrate the function using the mesh:

[9]:
Integrate(myfunc, mesh)
[9]:
0.16666666666666596

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

Differentiate a function

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

[10]:
diff_myfunc = myfunc.Diff(x)
Draw(diff_myfunc, mesh, "derivative")
[10]:
BaseWebGuiScene

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.

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

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.

[12]:
k = Parameter(1.0)
f = sin(k*y)
Draw(f, mesh, "f")
[12]:
BaseWebGuiScene

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

[13]:
k.Set(10)
Draw(f, mesh, "f")
[13]:
BaseWebGuiScene

Look at the expression tree of f:

[14]:
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:

[15]:
f.Diff(k)
[15]:
<ngsolve.fem.CoefficientFunction at 0x7f4bce987040>
[16]:
Integrate((f.Diff(k) - y*cos(k*y))**2, mesh)
[16]:
0.0

Interpolate a function

We may Set a GridFunction using a CoefficientFunction:

[17]:
fes = H1(mesh, order=1)
u = GridFunction(fes)
u.Set(myfunc)
Draw(u)         # Cf. Draw(myfunc, mesh, "firstfun")
[17]:
BaseWebGuiScene
  • 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.

  • We will see other ways to interpolate in 2.10.

Vector-valued CoefficientFunction

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

[18]:
vecfun = CoefficientFunction((-y, sin(x)))
Draw(vecfun, mesh, "vecfun")
[18]:
BaseWebGuiScene

Click on Draw Surface Vectors in the Visual menu to visualize this vector field.

Another example of a vector-valued coefficient function is the gradient of the above-set GridFunction.

[19]:
u.Set(myfunc)
gradu = grad(u)
Draw(gradu, mesh, "grad_firstfun")
[19]:
BaseWebGuiScene

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:

[20]:
myfunc_compiled = myfunc.Compile()

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

[21]:
print(myfunc)
coef binary operation '*', real
  coef coordinate x, real
  coef binary operation '-', real
    coef 1, real
    coef coordinate x, real

[22]:
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. We understand the printed description of Steps 2 and 3 above to mean 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 coefficient function on the mesh.

[23]:
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()
[24]:
%timeit Integrate(final, mesh, order=10)
1.39 ms ± 344 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
[25]:
%timeit Integrate(finalc, mesh, order=10)
146 µs ± 69.5 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

If your NGSolve installation has a compiler script (you likely do if you built from source using a compiler), then you have the option of letting that compiler optimize your coefficient function further. Here is an example:

[26]:
finalcc = final.Compile(realcompile=True, wait=True)
[27]:
%timeit Integrate(finalcc, mesh, order=10)
97 µs ± 7.88 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
[28]:
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

[29]:
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