Skip to main content

Symbolic computation language for Python — pattern matching, algebraic simplification, and computational intelligence

Project description

MikoshiLang

A symbolic computation language for Python — pattern matching, algebraic simplification, and computational intelligence.

Built by Mikoshi Ltd.

Installation

pip install mikoshilang

# With Jupyter support
pip install mikoshilang[jupyter]

# With signal processing
pip install mikoshilang[signal]

# Everything
pip install mikoshilang[all]

Language Syntax

MikoshiLang uses Wolfram-style syntax. Launch the REPL:

mikoshilang

Arithmetic

In[1]:= 2 + 3 * x
Out[1]= 2 + 3*x

In[2]:= x^2 - 4
Out[2]= x^2 - 4

In[3]:= (x + 1)(x - 1)    (* implicit multiplication *)
Out[3]= (x + 1)*(x - 1)

Function Calls (Square Brackets)

In[1]:= Sin[Pi/2]
In[2]:= Diff[x^2, x]
In[3]:= Integrate[x^2, x]
In[4]:= Solve[x^2 - 4 == 0, x]
In[5]:= Simplify[(x^2 - 1)/(x - 1)]
In[6]:= Factor[x^2 - 4]
In[7]:= Expand[(x + 1)^3]
In[8]:= Limit[Sin[x]/x, x -> 0]
In[9]:= Series[Exp[x], {x, 0, 5}]

Lists and Data

In[1]:= {1, 2, 3, 4, 5}
In[2]:= Range[10]
In[3]:= Table[i^2, {i, 1, 10}]
In[4]:= Map[Sin, {1, 2, 3}]
In[5]:= Select[{1, -2, 3, -4}, Positive]

Matrices

In[1]:= Det[{{1, 2}, {3, 4}}]
Out[1]= -2

In[2]:= Inverse[{{1, 2}, {3, 4}}]

Pattern Matching and Rules

In[1]:= x /. x -> 3
In[2]:= f[x_] := x^2
In[3]:= MatchQ[Sin[x], Sin[_]]
In[4]:= ReplaceAll[x + y, {x -> 1, y -> 2}]

Constants

Pi, E, I, Infinity, True, False

Comments

(* This is a comment *)

Jupyter Integration

Install the kernel:

pip install mikoshilang[jupyter]
python -m mikoshilang.jupyter.install

Then open Jupyter Notebook and select the "MikoshiLang" kernel. Features:

  • LaTeX rendering of expressions
  • Inline matplotlib plots with Plot[Sin[x], {x, -Pi, Pi}]
  • Rich display of matrices and lists

Plotting

Plot[Sin[x], {x, -Pi, Pi}]
Plot[{Sin[x], Cos[x]}, {x, -Pi, Pi}]
ListPlot[{1, 4, 9, 16, 25}]
ListLinePlot[{1, 4, 9, 16, 25}]

Physics Units

In[1]:= q = Quantity[9.8, "m/s^2"]
In[2]:= t = Quantity[3, "s"]
In[3]:= q * t
Out[3]= Quantity[29.4, "m/s"]

In[4]:= UnitConvert[Quantity[100, "cm"], "m"]
Out[4]= Quantity[1, "m"]

In[5]:= UnitConvert[Quantity[72, "kg"], "lb"]
Out[5]= Quantity[158.73, "lb"]

Supported Units

Category Units
Length m, cm, mm, km, in, ft, yd, mi
Mass kg, g, mg, lb, oz
Time s, ms, min, h, day
Speed m/s, km/h, mph
Force N, lbf
Energy J, kJ, cal, kcal, eV, kWh
Power W, kW, hp
Pressure Pa, kPa, atm, bar, psi
Temperature K, C, F
Electric A, V, ohm, Farad, H, Coulomb, Hz

Physical Constants

SpeedOfLight, GravitationalConstant, PlanckConstant, BoltzmannConstant, AvogadroNumber, ElementaryCharge

Chemistry

In[1]:= Element["H"]
Out[1]= {name: "Hydrogen", number: 1, mass: 1.008, symbol: "H"}

In[2]:= AtomicMass["O"]
Out[2]= 15.999

In[3]:= ElectronConfiguration["Fe"]
Out[3]= [Ar] 3d6 4s2

In[4]:= MolecularMass["H2O"]
Out[4]= 18.015

In[5]:= MolecularMass["C6H12O6"]
Out[5]= 180.156

In[6]:= BalanceEquation["H2 + O2 -> H2O"]
Out[6]= 2H2 + O2 -> 2H2O

All 118 elements included with atomic number, symbol, name, mass, electron configuration, electronegativity, and category.

Signal Processing

Requires pip install mikoshilang[signal] for filters and spectrogram.

In[1]:= DFT[{1, 2, 3, 4}]
In[2]:= IDFT[{10, -2, -2, -2}]

In[3]:= Convolve[{1, 2, 3}, {0, 1, 0.5}]

In[4]:= HammingWindow[256]
In[5]:= HanningWindow[256]
In[6]:= BlackmanWindow[256]

(* Symbolic Fourier transforms via SymPy *)
In[7]:= FourierTransform[Exp[-t^2], t, w]

(* Filters (require scipy) *)
In[8]:= LowPassFilter[data, cutoff]
In[9]:= HighPassFilter[data, cutoff]
In[10]:= BandPassFilter[data, low, high]

In[11]:= Spectrogram[data, sample_rate]

Python API

from mikoshilang import *

# Parse and evaluate Wolfram-style syntax
result = parse_and_eval("Simplify[(x^2 - 1)/(x - 1)]")

# Or use Python constructors directly
x = Symbol("x")
expr = x**2 + 2*x + 1
print(simplify(expr))
print(to_latex(expr))

# Units
q = Quantity(100, "cm")
print(UnitConvert(q, "m"))

# Chemistry
print(MolecularMass("C6H12O6"))
print(BalanceEquation("H2 + O2 -> H2O"))

Feature Comparison with Wolfram

Feature Wolfram MikoshiLang
Symbolic algebra ✅ (via SymPy)
Pattern matching
Calculus
Linear algebra ✅ (via NumPy)
Number theory
Wolfram-style syntax
Jupyter notebooks
LaTeX output
Plotting ✅ (via Matplotlib)
Physics units
Chemistry ✅ (118 elements)
Signal processing ✅ (via SciPy)
Free & open source

License

Apache 2.0 — Mikoshi Ltd.

Project details


Download files

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

Source Distribution

mikoshilang-0.2.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

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

mikoshilang-0.2.0-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file mikoshilang-0.2.0.tar.gz.

File metadata

  • Download URL: mikoshilang-0.2.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mikoshilang-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0669cc4811fd447a686e06c366bc5b79e8a9bc763663c0a96d90fb681663aa09
MD5 cdb7cca75d33cb5793a702ea15024527
BLAKE2b-256 22075674fd06bd7ec2177921811eeaf90e00200fe1cde79fc3e91b8e820875a9

See more details on using hashes here.

File details

Details for the file mikoshilang-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mikoshilang-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mikoshilang-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 587b801cb10f9bff0aff57fca2d752e11587236f37444ae1a80b97bace1137f7
MD5 9e273986b7b3dc8cff5de5945d34e462
BLAKE2b-256 7da45ac6bbd12a40507e4686a99caef937acb79fc9f8237441ceeb93f8b98846

See more details on using hashes here.

Supported by

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