Skip to content

JamesUnicomb/DySyTh

Repository files navigation

DySyTh

Dynamical Systems with Theano

Runge-Kutta - RK4 in Theano

We can solve systems of differential equations using numerical methods. As an example, the equations for the Lorents Attractor:

These written (with more detail in LorentzAttractor.py):

def f(X):
    X_ = T.zeros_like(X)
    X_ = T.set_subtensor(X_[0], sigma * (X[1] - X[0]))
    X_ = T.set_subtensor(X_[1], X[0] * (rho - X[2]) - X[1])
    X_ = T.set_subtensor(X_[2], X[0] * X[1] - beta * X[2])
    return X_

We can obtain a better estimate numerical estimate with RK4:

def step(X):
    k1 = h * f(X)
    k2 = h * f(X + 0.5 * k1)
    k3 = h * f(X + 0.5 * k2)
    k4 = h * f(X + k3)

    X_ = X + (1.0 / 6.0) * k1 + (1.0 / 3.0) * k2 + (1.0 / 3.0) * k3 + (1.0 / 6.0) * k4

    return X_

And we can iteratively solve to find the state of the system.

Lorentz Attractor

Double Pendulum

The equations for the pendulum angles are given by:

And the momentum:

We can use Runge-Kutta to solve these equations to produce:

Time for Pendulum to Flip

For each different starting position we time plot how long it takes for the pendulum to flip, producing a fractal pattern.

Rabinovich-Fabrikant

The system of equations given by:

Mandelbrot Set

Multibrot Set

For the standard Mandelbrot set, we use the equations above, however, we can change the exponent in the equation to produce similar plots. The gif shows the effect of changing the exponent (varying from 0 to 10).

Mandelbar Set

Another result, we take the complex conjugate before squaring, shown in the equtions:

This modified equation produces the following pattern known as the Tricorn.

Mandelbulb Set

The 3D extension to the 2D Mandelbrot set:

For N=3

We perform 10 iterations and produce:

For N=8

We perform 10 iterations and produce:

Taking more iterations

The animation shows the effect of performing further iterations. Eventually we get more detail than our plotting can handle.

About

Dynamical Systems with Theano

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages