# Sum of functions

**URL:** <https://community.freefem.org/t/sum-of-functions/666>\
**Category:** General Discussion\
**Created:** [November 22, 2020, 9:59pm UTC](https://community.freefem.org/t/sum-of-functions/666 "2020-11-22T21:59:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [November 22, 2020, 9:59pm UTC](https://community.freefem.org/t/sum-of-functions/666/1 "2020-11-22T21:59:25Z")

</div>

Dear FF++ users

I would like to ask please,  
I have functions which are connected via an index “i”  
how can I sum these functions concerning this index?

For example, if I define  
macro kappai(x,y,xi,yi) ((x-xi)^2+(y-yi)^2\<=r^2)//

and would like to sum them for i=1…10?

Thanks in advance,

Mordechai.

---

<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 23, 2020, 5:23pm UTC](https://community.freefem.org/t/sum-of-functions/666/2 "2020-11-23T17:23:03Z")

</div>

use a true func not a macro

```
func real kappa(real x, real y, real[int] xi, real[int] yi)
 {
 // do the loop here ... 
 }
```

---

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [November 23, 2020, 5:28pm UTC](https://community.freefem.org/t/sum-of-functions/666/3 "2020-11-23T17:28:18Z")

</div>

Hello professor Hecht,

Thank you very much.
