# Question about how to program to realize some functions in freefem++?

**URL:** <https://community.freefem.org/t/question-about-how-to-program-to-realize-some-functions-in-freefem/826>\
**Category:** General Discussion\
**Created:** [February 25, 2021, 7:16am UTC](https://community.freefem.org/t/question-about-how-to-program-to-realize-some-functions-in-freefem/826 "2021-02-25T07:16:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duzi100](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/duzi100/32/441_2.png) [@Duzi100](https://community.freefem.org/u/Duzi100)\
**Post date:** [February 25, 2021, 7:16am UTC](https://community.freefem.org/t/question-about-how-to-program-to-realize-some-functions-in-freefem/826/1 "2021-02-25T07:16:11Z")

</div>

Dear Friends

I’m a green hand in using Freefem++, and I sincerely hope get some help form you guys.

There is my question.  
How to realize the definition and call of functions with parameter input and output. Just like writing the ".m file " in MATLAB.

I will be every grateful for your solution.

---

<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:** [March 1, 2021, 9:41am UTC](https://community.freefem.org/t/question-about-how-to-program-to-realize-some-functions-in-freefem/826/2 "2021-03-01T09:41:54Z")

</div>

You have to 2 ways:

// a line function

```
func foo = t+y; // here the variable t mush be define before , x will be the current abcisse.

```

// a more complexe function ,  
func real J(real[int] & Z){  
Vh u ;  
u[]=Z;  
real s = int2d(Th)(Ie\*(u-ud)^2);  
return s;

```
}

```

or use a macro generation as like a function

macro f(x) (x)\*2 //

and finally you can put all the definition aN .idp file and include it.

---

<div class="post-metadata">

**Author:** ![Duzi100](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/duzi100/32/441_2.png) [@Duzi100](https://community.freefem.org/u/Duzi100)\
**Post date:** [March 1, 2021, 10:51am UTC](https://community.freefem.org/t/question-about-how-to-program-to-realize-some-functions-in-freefem/826/3 "2021-03-01T10:51:36Z")

</div>

Thanks a lot for your solutions with so many details. I will try to program as these examples one by one.
