| Home | Libraries | People | FAQ | More

## Class template bulirsch_stoer

boost::numeric::odeint::bulirsch_stoer — The Bulirsch-Stoer algorithm.

## Synopsis

    // In header: <boost/numeric/odeint/stepper/bulirsch_stoer.hpp>

    template<typename State, typename Value = double, typename Deriv = State,
             typename Time = Value,
             typename Algebra = typename algebra_dispatcher< State >::algebra_type,
             typename Operations = typename operations_dispatcher< State >::operations_type,
             typename Resizer = initially_resizer>
    class bulirsch_stoer {
    public:
      // types
      typedef State      state_type;
      typedef Value      value_type;
      typedef Deriv      deriv_type;
      typedef Time       time_type;
      typedef Algebra    algebra_type;
      typedef Operations operations_type;
      typedef Resizer    resizer_type;

      // construct/copy/destruct
      bulirsch_stoer(value_type = 1E-6, value_type = 1E-6, value_type = 1.0,
                     value_type = 1.0, time_type = static_cast< time_type >(0));

      // public member functions
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step(System, StateInOut &, time_type &, time_type &);
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step(System, const StateInOut &, time_type &, time_type &);
      template<typename System, typename StateInOut, typename DerivIn>
        controlled_step_result
        try_step(System, StateInOut &, const DerivIn &, time_type &, time_type &);
      template<typename System, typename StateIn, typename StateOut>
        boost::disable_if< boost::is_same< StateIn, time_type >, controlled_step_result >::type
        try_step(System, const StateIn &, time_type &, StateOut &, time_type &);
      template<typename System, typename StateIn, typename DerivIn,
               typename StateOut>
        controlled_step_result
        try_step(System, const StateIn &, const DerivIn &, time_type &,
                 StateOut &, time_type &);
      void reset();
      template<typename StateIn> void adjust_size(const StateIn &);

      // private member functions
      template<typename StateIn> bool resize_m_dxdt(const StateIn &);
      template<typename StateIn> bool resize_m_xnew(const StateIn &);
      template<typename StateIn> bool resize_impl(const StateIn &);
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step_v1(System, StateInOut &, time_type &, time_type &);
      template<typename StateInOut>
        void extrapolate(size_t, state_table_type &, const value_matrix &,
                         StateInOut &);
      time_type calc_h_opt(time_type, value_type, size_t) const;
      controlled_step_result
      set_k_opt(size_t, const inv_time_vector &, const time_vector &, time_type &);
      bool in_convergence_window(size_t) const;
      bool should_reject(value_type, size_t) const;

      // public data members
      static const size_t m_k_max;
    };

## Description

The Bulirsch-Stoer is a controlled stepper that adjusts both step size and order of the method. The algorithm uses the modified midpoint and a polynomial extrapolation compute the solution.

### Template Parameters

1.     typename State

   The state type.

2.     typename Value = double

   The value type.

3.     typename Deriv = State

   The type representing the time derivative of the state.

4.     typename Time = Value

   The time representing the independent variable - the time.

5.     typename Algebra = typename algebra_dispatcher< State >::algebra_type

   The algebra type.

6.     typename Operations = typename operations_dispatcher< State >::operations_type

   The operations type.

7.     typename Resizer = initially_resizer

   The resizer policy type.

### `bulirsch_stoer` public construct/copy/destruct

1.     bulirsch_stoer(value_type eps_abs = 1E-6, value_type eps_rel = 1E-6,
                      value_type factor_x = 1.0, value_type factor_dxdt = 1.0,
                      time_type max_dt = static_cast< time_type >(0));

   Constructs the `bulirsch_stoer` class, including initialization of the error bounds.

   Parameters:

   `eps_abs` | Absolute tolerance level.
   `eps_rel` | Relative tolerance level.
   `factor_dxdt` | Factor for the weight of the derivative.
   `factor_x` | Factor for the weight of the state.

### `bulirsch_stoer` public member functions

1.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step(System system, StateInOut & x, time_type & t, time_type & dt);

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed. Also, the internal order of the stepper is adjusted if required.

   Parameters:

   `dt` | The step size. Updated.
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `t` | The value of the time. Updated if the step is successful.
   `x` | The state of the ODE which should be solved. Overwritten if the step is successful.

   Returns: | success if the step was accepted, fail otherwise.

2.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step(System system, const StateInOut & x, time_type & t, time_type & dt);

   Second version to solve the forwarding problem, can be used with Boost.Range as StateInOut.

3.     template<typename System, typename StateInOut, typename DerivIn>
         controlled_step_result
         try_step(System system, StateInOut & x, const DerivIn & dxdt, time_type & t,
                  time_type & dt);

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed. Also, the internal order of the stepper is adjusted if required.

   Parameters:

   `dt` | The step size. Updated.
   `dxdt` | The derivative of state.
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `t` | The value of the time. Updated if the step is successful.
   `x` | The state of the ODE which should be solved. Overwritten if the step is successful.

   Returns: | success if the step was accepted, fail otherwise.

4.     template<typename System, typename StateIn, typename StateOut>
         boost::disable_if< boost::is_same< StateIn, time_type >, controlled_step_result >::type
         try_step(System system, const StateIn & in, time_type & t, StateOut & out,
                  time_type & dt);

   Tries to perform one step.

   | Note
   This method is disabled if state_type=time_type to avoid ambiguity.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed. Also, the internal order of the stepper is adjusted if required.

   Parameters:

   `dt` | The step size. Updated.
   `in` | The state of the ODE which should be solved.
   `out` | Used to store the result of the step.
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `t` | The value of the time. Updated if the step is successful.

   Returns: | success if the step was accepted, fail otherwise.

5.     template<typename System, typename StateIn, typename DerivIn,
                typename StateOut>
         controlled_step_result
         try_step(System system, const StateIn & in, const DerivIn & dxdt,
                  time_type & t, StateOut & out, time_type & dt);

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed. Also, the internal order of the stepper is adjusted if required.

   Parameters:

   `dt` | The step size. Updated.
   `dxdt` | The derivative of state.
   `in` | The state of the ODE which should be solved.
   `out` | Used to store the result of the step.
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `t` | The value of the time. Updated if the step is successful.

   Returns: | success if the step was accepted, fail otherwise.

6.     void reset();

   Resets the internal state of the stepper.

7.     template<typename StateIn> void adjust_size(const StateIn & x);

   Adjust the size of all temporaries in the stepper manually.

   Parameters:

   `x` | A state from which the size of the temporaries to be resized is deduced.

### `bulirsch_stoer` private member functions

1.     template<typename StateIn> bool resize_m_dxdt(const StateIn & x);

2.     template<typename StateIn> bool resize_m_xnew(const StateIn & x);

3.     template<typename StateIn> bool resize_impl(const StateIn & x);

4.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step_v1(System system, StateInOut & x, time_type & t, time_type & dt);

5.     template<typename StateInOut>
         void extrapolate(size_t k, state_table_type & table,
                          const value_matrix & coeff, StateInOut & xest);

6.     time_type calc_h_opt(time_type h, value_type error, size_t k) const;

7.     controlled_step_result
       set_k_opt(size_t k, const inv_time_vector & work, const time_vector & h_opt,
                 time_type & dt);

8.     bool in_convergence_window(size_t k) const;

9.     bool should_reject(value_type error, size_t k) const;