Just to close this issue, i found that the best solution is to perform the deruvative in mathematica and then write this in c languaje via Cform[ ] command. It will gives you the function and you can add it to the stan code exporting to a file “func.txt” and then just importing and pasting this text in the stan code like:
“… return” <> file <> ;
}
Otherfunction(…"
Hope it helps to someone