I have a problem that requires a root finding algorithm. Originally I hard coded a Newton’s method algorithm, but with the extra operations it may make the code slower. So, I tried using the “algebra_solver” function instead:

```
functions
{
vector algebra_system(vector y, vector theta, real[] x_r, int[] x_i)
{
vector[1] ret;
ret[1] = y[1] - theta[1]*sin(y[1]) - theta[2];
return ret;
}
real BoundMeanAnomaly(real e, real dt)
{
vector[2] theta;
vector[1] y_guess;
vector[1] ret;
real x_r[0];
int x_i[0];
y_guess[1] = dt + e*sin(dt) + e*e*sin(2.0*dt)/2.0;
theta[1] = e;
theta[2] = dt;
ret = algebra_solver(algebra_system, y_guess, theta, x_r, x_i);
return ret[1];
}
}
```

Here “BoundMeanAnomaly” used to have the Newton’s method code that I am replacing with the algebra_solver. But, I am getting these syntax errors:

second argument to algebra_solver (initial guess) must be data only and not reference parameters

fourth argument to algebra_solver (real data) must be data only and not reference parameters

It seems that “y_guess” must be data only (I’m guessing in the C++ code it needs to of type “double” and not type “stan::var”?). But, it depends on the inputed parameter e and dt! Also, with “x_r”, I have no clue on how to pass in a dummy “data only” vector.

I’m at a lost on how to implement this function.