# Usage of nloptLBFGS - interpret error

**URL:** https://community.freefem.org/t/usage-of-nloptlbfgs-interpret-error/408
**Category:** General Discussion
**Created:** [May 13, 2020, 7:56pm UTC](https://community.freefem.org/t/usage-of-nloptlbfgs-interpret-error/408 "2020-05-13T19:56:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BeniaminBogosel](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@BeniaminBogosel](https://community.freefem.org/u/BeniaminBogosel)
#### Post date: [May 13, 2020, 7:56pm UTC](https://community.freefem.org/t/usage-of-nloptlbfgs-interpret-error/408/1 "2020-05-13T19:56:47Z")

</div>

Hello, I want to use nloptLBFGS for an optimization problem. I managed to get a minimal test running, but when I try to apply the same syntax to the problem of interest I get the error below. It talks about a macro error, but I used “func” to define the gradient.

the line where the optimizer is called looks like:  
`nloptLBFGS(J,u[],grad=GradJ);`

The error report is given below:

```
nloptLBFGS(J,u[],grad= we waiting for a '('
  current line = 109
Compile error : err macro 
	line number :109, =
error Compile error : err macro 
	line number :109, =
 code = 1 mpirank: 0

```

* * *

On the other hand, the following example seems to work:

```
load "ff-NLopt"

func real J(real[int] &v){
   real[int] ve = v.*v;
   return ve.sum;
}

func real[int] GradJ(real[int] &v){
   real[int] res = 2*v;
   return v;
}

real[int] x0 = [1.1,2,-1];
real mm = nloptLBFGS(J,x0,grad=GradJ);

cout << "Minimum: " << mm ;
cout << x0 <<endl;
```

---

<div class="post-metadata">

### Author: ![BeniaminBogosel](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@BeniaminBogosel](https://community.freefem.org/u/BeniaminBogosel)
#### Post date: [May 13, 2020, 10:16pm UTC](https://community.freefem.org/t/usage-of-nloptlbfgs-interpret-error/408/2 "2020-05-13T22:16:17Z")

</div>

Sorry for bothering you… I found the solution. It turns out I defined a macro named `grad` before, so when calling the option `grad=GradJ` FreeFem tried to replace the macro.  
Best regards,  
Beniamin
