# Negative part of a function

**URL:** <https://community.freefem.org/t/negative-part-of-a-function/132>\
**Category:** General Discussion\
**Created:** [September 8, 2019, 4:53pm UTC](https://community.freefem.org/t/negative-part-of-a-function/132 "2019-09-08T16:53:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolopiers](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/paolopiers/32/48_2.png) [@paolopiers](https://community.freefem.org/u/paolopiers)\
**Post date:** [September 8, 2019, 4:53pm UTC](https://community.freefem.org/t/negative-part-of-a-function/132/1 "2019-09-08T16:53:20Z")

</div>

Hello everyone.  
Today I would like to ask the following question:  
How do you implement, in FreeFem++, the negative part of a function defined over the integration domain of your variational equations?

By definition,

NegativePart(f)=- min{f,0}.

How do I vode this nonlinear fuction?

Thanks in advance and best regards,

Paolo

---

<div class="post-metadata">

**Author:** ![denis.crete](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@denis.crete](https://community.freefem.org/u/denis.crete)\
**Post date:** [January 4, 2020, 9:56pm UTC](https://community.freefem.org/t/negative-part-of-a-function/132/2 "2020-01-04T21:56:07Z")

</div>

Hello,  
This is probably easier to code:  
NegativePart(f)=(abs(f)-f)/2;  
HTH  
Denis
