Skip to main content

Solving library for simultaneous equations and inequalities

Project description

equid

下の方に日本語の説明があります

Overview

  • Solving library for simultaneous equations and inequalities

Usage

import equid as eq

# Example of solving an equation
res = eq.solve(cond = (eq.x + 3 == 5))
print(res)	# -> {"x": 2.0}

# Inequalities and series are also possible. If there is more than one solution, one is randomly chosen.
cond = (
	(eq.x + 2 == eq.y) &
	(eq.x >= 10)
)
res = eq.solve(cond = cond)
print(res)	# -> e.g. {"x": 10.0, "y": 12.0}

# Assign
print((eq.x + 5).fix(x = 3))	# -> 8
print((5 + eq.x + eq.y).fix(x = 3))	# -> (+ 8 (var y))

# Mathematical programming (find the one with the smallest loss among those satisfying cond)
res = eq.solve(cond = (3 * eq.x - eq.y == 0),
	loss = (eq.y - 1) ** 2)
print(res)	# -> {"x": 0.333, "y": 1}

# convert to javascript code
print(eq.to_js((3 + eq.x) ** 2))	# -> Running "(OUTPUT_STR({x: 1}))" in javascript will output 16.

# Algorithmic differentiation (automatic differentiation)
print((eq.x ** 2).diff("x")) # -> (* 2 (var x))

Advanced Usage

# 執筆中 (under_construction)

概略

  • 連立方程式/不等式の求解ライブラリ

利用例

import equid as eq

# 方程式を解く例
res = eq.solve(cond = (eq.x + 3 == 5))
print(res)	# -> {"x": 2.0}

# 不等式・連立もできる。解が複数あるときはひとつ選ばれる
cond = (
	(eq.x + 2 == eq.y) &
	(eq.x >= 10)
)
res = eq.solve(cond = cond)
print(res)	# -> 例えば{"x": 10.0, "y": 12.0}

# 代入
print((eq.x + 5).fix(x = 3))	# -> 8
print((5 + eq.x + eq.y).fix(x = 3))	# -> (+ 8 (var y))

# 数理計画 (condを満たす中でlossが最小のものを見つける)
res = eq.solve(cond = (3 * eq.x - eq.y == 0),
	loss = (eq.y - 1) ** 2)
print(res)	# -> {"x": 0.333, "y": 1}

# javascriptコードに変換
print(eq.to_js((3 + eq.x) ** 2))	# -> 「(出てきた文字列)({x: 1})」をjavascriptで実行すると16を出力する

# アルゴリズム的微分 (自動微分)
print((eq.x ** 2).diff("x")) # -> (* 2 (var x))

発展的な利用例

# 執筆中 (under_construction)

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

equid-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

equid-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file equid-0.1.0.tar.gz.

File metadata

  • Download URL: equid-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for equid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4eea5e46d95e8bf2646277f24aa6c7cc85b5fc005faa112cf8016910bf59e0bb
MD5 690ddc228bdc7eb142cf5f6f8c634794
BLAKE2b-256 b784726727d987ac5534eacf02e0112ca5a00a7cb7a457ec91b2ebc01da633b8

See more details on using hashes here.

File details

Details for the file equid-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: equid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for equid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10c66e932a816896e327b3e49224dab7f05acdbeba5b9f00fbca32e54f88ecab
MD5 9a06e10b052826cbe486525a057d4012
BLAKE2b-256 e3a00dea922057ee9770a75d2ba70d65edf07e3fd0c0c8ce5e9cce6f378cb4b4

See more details on using hashes here.

Supported by

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