# New to functions, having difficulty with code

**URL:** <https://forum.dynare.org/t/new-to-functions-having-difficulty-with-code/20319>\
**Category:** Installation and Setup\
**Created:** [8 May 2022 03:51 UTC](https://forum.dynare.org/t/new-to-functions-having-difficulty-with-code/20319 "2022-05-08T03:51:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pancake](https://forum.dynare.org/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@pancake](https://forum.dynare.org/u/pancake)\
**Post date:** [8 May 2022 03:51 UTC](https://forum.dynare.org/t/new-to-functions-having-difficulty-with-code/20319/1 "2022-05-08T03:51:36Z")

</div>

I want to run a script with a simple function. However, I keep getting this error:

Calling Dynare with arguments: none  
Starting preprocessing of the model file …  
ERROR: PS\_4.mod: line 25, cols 1-0: syntax error, unexpected end of file

Is there any way to fix this code so that the function will work. I’ve spent hours and really need some help. Thank you very much.

G = 0.4;  
alpha = 0.8;  
beta = 0.9;  
sigma = 0.7;

results = optimize(0.3);  
disp(results);

function sol = optimize(T)  
syms x y  
eqns = [  
x^sigma == ((1-T)\*(1-alpha))/(y^alpha);  
x + G == y^(1-alpha);  
];  
solRaw = vpasolve(eqns,[x, y]);  
sol = [double(solRaw.x), double(solRaw.y)];  
end;

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [9 May 2022 09:37 UTC](https://forum.dynare.org/t/new-to-functions-having-difficulty-with-code/20319/2 "2022-05-09T09:37:13Z")

</div>

What you posted is not Dynare code. If you want to include this in a Dynare file, you may have to put it into a `verbatim`-block. Also, you cannot nest functions within a mod-file.
