Skip to main content

kalimusada: a Python library for solving the Ma-Chen financial chaotic system

Python 3.8+ PyPI version License: MIT Code style: black DOI

NumPy SciPy Matplotlib Pandas netCDF4 imageio tqdm

A Python-based solver for demonstrating sensitivity to initial conditions in economic dynamics.

Ma-Chen Chaotic Dynamics

Model

The Ma-Chen system describes financial dynamics through three coupled ordinary differential equations:

$$ \dot{x} = z + (y - a)x, \quad \dot{y} = 1 - by - x^2, \quad \dot{z} = -x - cz $$

where the state variables are:

Variable Description Economic interpretation
$x(t)$ Interest rate Cost of borrowing capital
$y(t)$ Investment demand Aggregate investment activity
$z(t)$ Price index General price level

and the parameters are:

Parameter Description Chaotic value
$a$ Savings rate $0.9$
$b$ Investment cost coefficient $0.2$
$c$ Demand elasticity $1.2$

The solver simulates two trajectories with infinitesimal initial separation $\delta_0 \sim \mathcal{O}(10^{-5})$ to visualize exponential divergence characteristic of deterministic chaos.

Installation

From PyPI:

pip install kalimusada

From source:

git clone https://github.com/sandyherho/kalimusada.git
cd kalimusada
pip install -e .

Quick start

CLI:

kalimusada case1          # run standard chaos scenario
kalimusada --all          # run all test cases

Python API:

from kalimusada import MaChenSolver, MaChenSystem

system = MaChenSystem(a=0.9, b=0.2, c=1.2)
solver = MaChenSolver()

result = solver.solve(
    system=system,
    init_A=[1.0, 2.0, 0.5],
    init_B=[1.00001, 2.0, 0.5],
    t_span=(0, 250),
    n_points=100000
)

print(f"Max divergence: {result['max_euclidean_distance']:.6f}")

Features

  • High-precision ODE integration (LSODA)
  • Dual trajectory sensitivity analysis
  • Error metrics: Euclidean distance, RMSE, log divergence
  • Output formats: CSV, NetCDF, PNG, GIF

License

MIT © Sandy H. S. Herho

Citation

@article{herho2026butterfly,
  title = {{T}he butterfly effect in economics: {E}xploring chaos with a simple financial model},
  author = {Herho, Sandy H. S.},
  journal = {CODEE Journal},
  volume = {20},
  number = {1},
  pages = {1},
  year = {2026},
  note = {https://scholarship.claremont.edu/codee/vol20/iss1/1}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kalimusada-0.0.2.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kalimusada-0.0.2-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file kalimusada-0.0.2.tar.gz.

File metadata

  • Download URL: kalimusada-0.0.2.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for kalimusada-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5b372eca3b9c304a61ef204f89d33730b652e9a302e241dc178d2f8a0cfe4097
MD5 c9ed25fc87f3e9c0cf684f60e2357481
BLAKE2b-256 8bb1e2b7f32565e2a64d75d6d096955797195cec952a8c504692222a3390182a

See more details on using hashes here.

File details

Details for the file kalimusada-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: kalimusada-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for kalimusada-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81726bf144f2968f447618058c2d74bc23d28314342fd70a8e02235d21215a12
MD5 0a723d2f13c56bdfa999f89517c225a8
BLAKE2b-256 487a719ddf335eb6c9f4579cf2a51c08831f78bcc8e2084106b776183fcaeba8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page