# How to define a function with three cases?

**URL:** https://community.freefem.org/t/how-to-define-a-function-with-three-cases/2906
**Category:** General Discussion
**Created:** [January 25, 2024, 10:14am UTC](https://community.freefem.org/t/how-to-define-a-function-with-three-cases/2906 "2024-01-25T10:14:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RaghunathBandha](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/raghunathbandha/32/1843_2.png) [@RaghunathBandha](https://community.freefem.org/u/RaghunathBandha)
#### Post date: [January 25, 2024, 10:14am UTC](https://community.freefem.org/t/how-to-define-a-function-with-three-cases/2906/1 "2024-01-25T10:14:07Z")

</div>

Let f(x,y)=0 for (x,y)=(0,0) and f(x,y)=x^2/(x^2+y^2) for x^2\>y^2 and f(x,y)=y^2/(x^2+y^2) for x^2\<y^2. How to do this.

---

<div class="post-metadata">

### Author: ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)
#### Post date: [January 25, 2024, 5:54pm UTC](https://community.freefem.org/t/how-to-define-a-function-with-three-cases/2906/2 "2024-01-25T17:54:32Z")

</div>

Please avoid multiple posting. I answered the first [here](https://community.freefem.org/t/how-to-find-polar-angle-made-by-the-line-by-joining-the-given-point-in-cartesian-plane-with-origin-i-want-a-unique-angle-which-will-be-from-0-2-pi/2899/4)
