# How Freefem++ assemble the forms with variable coefficient?

**URL:** <https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178>\
**Category:** General Discussion\
**Created:** [November 18, 2019, 12:35pm UTC](https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178 "2019-11-18T12:35:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Psywah](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/psywah/32/65_2.png) [@Psywah](https://community.freefem.org/u/Psywah)\
**Post date:** [November 18, 2019, 12:35pm UTC](https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178/1 "2019-11-18T12:35:01Z")

</div>

Hello,

I want to make clear about how FreeFEM deal with the variable coefficient while assembling.

Here is an example:  
$$ a(u, v) = \int c \nabla u \cdot \nabla v $$  
where c = \cos (x) is a given function.

Is there an explicit step to interpolate c to a high order FE function first?

Or it is to apply numerical integral directly, namely c is evaluated at the quadrature points?

Shihua

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [November 18, 2019, 3:26pm UTC](https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178/2 "2019-11-18T15:26:07Z")

</div>

The complete expression inside the integral is evaluated at the quadrature points. If “c” is an explicitly-defined function of “x”, it is evaluated exactly at each point. If “c” is defined on a finite element basis, then it is a function of its finite element space. So it is evaluated through interpolation on that space (not a higher-order one).

---

<div class="post-metadata">

**Author:** ![Psywah](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/psywah/32/65_2.png) [@Psywah](https://community.freefem.org/u/Psywah)\
**Post date:** [November 18, 2019, 4:06pm UTC](https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178/3 "2019-11-18T16:06:11Z")

</div>

Got it. Thank you Chris.

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [November 19, 2019, 3:59pm UTC](https://community.freefem.org/t/how-freefem-assemble-the-forms-with-variable-coefficient/178/4 "2019-11-19T15:59:09Z")

</div>

Trivial, if just write  
varf va(u,v) = int2d(Th)(cos(x) \*grad(u)’\*grad(v));  
Frederic Hecht.
