Hi Guys,

I am getting this error while using the solver.

Chain 1: Exception: Exception: Exception: algebra_solver: the norm of the algebraic function is: 0.33599 but should be lower than the function tolerance: 1e-06. Consider decreasing the relative tolerance and increasing the max_num_steps.

Any idea how to debug this?

The solver cannot find a solution. Are you sure the equation system always *does* have a solution? What is the equation youâ€™re trying to solve?

1 Like

its a polynomial equation of the 4th order.

However I think the problem is with the ode function part. I am trying to add the control parameters to the ode function. it is giving me an error while calling the ode function saying that the first argument should be a function of type real, real [ ], and so onâ€¦

in my case, the function is already defined as Real [ ] and all the arguments are correctly specified. Why is it still giving me this error?

@nhuurre rel_tol, abs_tol and max_steps should be specified in the ode solver function like this,

integrate_ode_bdf(DICdynamics_Coral, y0_calib, t0, ts, var_calib, x_r, x_i, rel_tol, abs_tol, max_steps)

but not in the ode function definition?

real[ ] DICdynamics_Coral(real t, //time

real[ ] y, //state

real[ ] var_fn, //parameters change name to variables

data real[ ] x_r,

data int[ ] x_i){

// data real abs_tol,

// data real max_steps) {

Thatâ€™s correct. The tolerance only affects at what times the solver evaluates the objective function. The function itself does not see the tolerance arguments.

A general fourth order polynomial could look like this

I donâ€™t know exactly how the solver works but I imagine it could get stuck in the local minimum on the right. Also thereâ€™s two roots on the left so it might give you the wrong one. Itâ€™s important to choose the initial guess close to the solution you want. Of course the particular equation you have may be different.

Generally debugging means inserting print statements in the code and figuring out what the parameter values are when things go wrong. If youâ€™re using RStan `expose_stan_functions()`

can also help.