# How to evaluate variational formulation

**URL:** <https://fenicsproject.discourse.group/t/how-to-evaluate-variational-formulation/5017>\
**Category:** Uncategorized\
**Created:** [February 2, 2021, 11:21am UTC](https://fenicsproject.discourse.group/t/how-to-evaluate-variational-formulation/5017 "2021-02-02T11:21:45Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [February 2, 2021, 3:31pm UTC](https://fenicsproject.discourse.group/t/how-to-evaluate-variational-formulation/5017/12 "2021-02-02T15:31:33Z")

</div>

Note that in `r` you have a trial function (u). This has to be replaced by your solution to the problem, using  
For instance `ufl.replace`. See [Derivative function has no attribute 'subs' - #2 by dokken](https://fenicsproject.discourse.group/t/derivative-function-has-no-attribute-subs/4956/2) on how to use replace. If there are no test or trial functions in the residual, the assembly (r\*dx) simply becomes a scalar value.  
If you want to look at the spatial variation of the residual, you should project it into a suitable function space and save the result to pvd or xdmf

---

_[View the full topic](https://fenicsproject.discourse.group/t/how-to-evaluate-variational-formulation/5017)._
