Allowable error tolerance relative to state value during a simulation


RelativeTolerance is a property of the SolverOptions object, which is a property of a Configset object. It is available for the ode solvers (ode15s, ode23t, ode45, and sundials).

The RelativeTolerance property specifies the allowable error tolerance relative to the state vector at each simulation step. The state vector contains values for all the state variables, for example, amounts for all the species.

If you set the RelativeTolerance at 1e-2, you are specifying that an error of 1% relative to each state value is acceptable at each simulation step.


At each simulation step, the solver estimates the local error ei in the ith state vector y. Simulation converges at that time step if ei satisfies the following equation:


Thus at higher state values, convergence is determined by RelativeTolerance. As the state values approach zero, convergence is controlled by AbsoluteTolerance. The choice of values for RelativeTolerance and AbsoluteTolerance will vary depending on the problem. The default values should work for first trials of the simulation; however if you want to optimize the solution, consider that there is a trade-off between speed and accuracy. If the simulation takes too long, you can increase the values of RelativeTolerance and AbsoluteTolerance at the cost of some accuracy. If the results appear to be inaccurate, you can decrease the tolerance values but this will slow down the solver. If the magnitude of the state values is high, you can try to decrease the relative tolerance to get more accurate results.


Applies toObject: SolverOptions
Data typedouble
Data valuesPositive scalar that is <1. Default is 1e-3.


This example shows how to change AbsoluteTolerance.

  1. Retrieve the configset object from the modelObj.

    modelObj  = sbiomodel('cell');
    configsetObj = getconfigset(modelObj)
  2. Change the AbsoluteTolerance to 1e-8.

    set(configsetObj.SolverOptions, 'RelativeTolerance', 1.0e-6);
    get(configsetObj.SolverOptions, 'RelativeTolerance')
    ans =
Was this topic helpful?