Skip to main content

pmath

Bringing the math tools of Python to the command-line

Doing math on the command-line is hard. Integer math can be done with BASH, but the only utility around for floating-point math is bc, and that can be confusing with its scale and precision. What if you want the power of Python’s math, perhaps programmatically? Enter: pmath.

Examples

Basic input:

$ pmath '3 + 4'
7
$ echo '3+4' | pmath
7
$ pmath <<< 3+4
7
$ pmath 'x=3;x+2'
5

You can set the output format with a -f switch:

$ pmath -f .4f <<< pow(2000, 1/3)
12.5992
$ pmath -f .4f <<< sin(pi/2)
1.0000

Enabling complex math operations is straightforward with -c:

$ pmath -c <<< exp(1j*pi).real
-1.0
$ pmath -f.2f -c 'ang=3*pi/4; exp(1j*ang)'
-0.71+0.71j

Installation

Running pip install pmath will install the command-line utility.

Release files for pmath 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pmath 0.3
File Size Uploaded
pmath-0.3.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pmath 0.3
File Interpreter ABI Platform
pmath-0.3.linux-x86_64.tar.gz Details

Total release size: 6.9 kB

Release files / pmath-0.3.tar.gz

Download URL pmath-0.3.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
91ded83466c854a139d9afc322cb1a65d17bba3bb88101e87c5eeb4a9314ee96
BLAKE2b-256 checksum
How to use checksums
3aebfbdf409d71b59f8aba3760142bb7f229492f1bff795df86c419525e00d90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pmath-0.3.linux-x86_64.tar.gz

Download URL pmath-0.3.linux-x86_64.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e41ed56229f04a681f6e4b5b4979d676902af56c6eae6d0405686fd7488662ec
BLAKE2b-256 checksum
How to use checksums
a74c9624f08dd21d7b3482183b62cf4cf75d6142ad1cc7b17ddaa1b0959ef0d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page