# Simple problem related to \`macro\` keyword

**URL:** <https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530>\
**Category:** General Discussion\
**Created:** [October 4, 2024, 11:32am UTC](https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530 "2024-10-04T11:32:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [October 4, 2024, 11:32am UTC](https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530/1 "2024-10-04T11:32:01Z")

</div>

Hi all, I’m trying to use the `macro` keyword to include some functions into my weak form (just to tidy up my code and to make mistakes less likely when typing). However, when playing around with the `macro` keyword, I ran into a strange issue where I receive the following error:

_Warning ambiguity Polymorphic Find 2_

The code which generates such an error is simply:

```auto
macro tt(u) 2*exp(u) //
cout<<"tt(2)="<<tt(2)<<endl;

```

I assumed that maybe this was because of the presence of `exp()` in my function; however the following code also contains `exp()` and does _not_ result in any error:

```auto
macro L11(a1, a2) 1.16014e-7*exp(-24.0473*(-1.5048e-5*a2+0.239777)^0.399839)*exp(-2819.27*exp(-12.4785*(-1.5048e-5*a2+0.239777)^0.335995)*a1^(-1.5048e-5*a2+0.239777)) //
cout<<"L11="<<L11(2,3)<<endl;

```

Can someone explain to me why the first line of code generates such an error? Is there a work around?

Many thanks.

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [October 4, 2024, 11:43am UTC](https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530/2 "2024-10-04T11:43:05Z")

</div>

Hi all, I’ve found a solution, so I’ll put it here just in case anyone else has the same issue in the future:

The following equivalent code works:

```auto
macro tt(u) 2*exp(1e0*u) //
cout<<"tt(2)="<<tt(2)<<endl;

```

So, for some reason, you must include a coefficient in standard form next to your argument. So, if you just want `exp(u)` you must write `exp(1e0*u)`.

Apologies, I know this is a very simple issue and probably didn’t need putting here.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [October 4, 2024, 11:50am UTC](https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530/3 "2024-10-04T11:50:10Z")

</div>

When you call exp(), FF has to know what kind of argument it is (real, complex, matrix, vector of values…). `exp` is a polymorphic function.  
In your first code, the type of “2” is not declared, which is the problem.  
When you write your macro L11, you have real numbers, identified by “.”. Hence the result is a real number. The same occurs in your last def with 1e0\*u.  
Another way to make it work is

```auto
macro tt(u) 2*exp(u) //
cout<<"tt(2)="<<tt(2.)<<endl;

```

so that 2. is declared as a real number.  
Note that “integer” is not an admissible type of argument for `exp`.

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [October 4, 2024, 12:03pm UTC](https://community.freefem.org/t/simple-problem-related-to-macro-keyword/3530/4 "2024-10-04T12:03:39Z")

</div>

Hi, thanks for your reply! I’ll keep this all in mind.
