phys_581.assignment_4
=====================

.. py:module:: phys_581.assignment_4

.. autoapi-nested-parse::

   Assignment 4: Chaos



Functions
---------

.. autoapisummary::

   phys_581.assignment_4.compute_lyapunov


Module Contents
---------------

.. py:function:: compute_lyapunov(compute_dy_dt, y0, dy0=None, t0=0, dt=None, min_norm=None, Nsamples=None, norm=np.linalg.norm, rng=_DEFAULT_RNG, debug=False, solve_ivp_args=None)

   Return a list of uncorrelated values `lams` estimating the maximal Lyapunov
   exponent for the ODE.

   The arguments here follow the conventions required by `solve_ivp`, but the actual
   solver used is up to implementer.

   :param compute_dy_dt: Return ``dy_dt = compute_dy_dt(t, y)``.
   :type compute_dy_dt: function
   :param y0: Initial state.
   :type y0: array-like
   :param dy0: Initial direction to store.  If `None`, then this is chosen randomly.
   :type dy0: array-like, None
   :param t0: Initial time.
   :type t0: float
   :param dt: Evolve for this length of time when computing the exponent.  If `None`, then
              a reasonable value should be estimated by the code.  (The code may adaptively
              update `dt`.)
   :type dt: float, None
   :param min_norm: Minimum norm. Start with states separated by `min_norm`, then evolve by `dt`,
                    extract the exponent, add this to the samples, then pull the state back along
                    the same direction to have length `min_norm` and repeat.  If `None`, then
                    reasonable values should be estimated by the code.
   :type min_norm: float, None
   :param Nsamples: Number of samples to use when estimating the Lyapunov exponent.  The estimate
                    should be the mean of this many samples with an error as the standard deviation.
   :type Nsamples: int
   :param norm: Use this function to compute the norm of the difference between states.
                (Default is `np.linalg.norm`.)
   :type norm: function
   :param rng: Random number generator such as returned by `np.random.default_rng()`, which is
               used by default if one is not provided.
   :type rng: random number generator
   :param debug: If `True`, then return `(lams, ts, ys, dys)` with the sample evolution.
   :type debug: bool
   :param solve_ivp_args: Additional arguments for `solve_ivp`.
   :type solve_ivp_args: dict, None

   :returns: * **lams** (*array of floats*) -- Array of maximal Lyapunov exponents such that the mean and standard deviations
               give a good estimate.  These should be uncorrelated.
             * **ts, ys, dys** (*array*) -- Only provided if `debug` is `True`.  Times, states, and separations used in
               sampling.


