chemical-equation: Balance chemical equations
Balance coefficients of chemical equations. You only give the list of reactants, the program will automatically find out on which side of the equation the reactants are placed. However, the first reactant is always placed on the left side and the order of all reactants is preserved as good as possible.
$ balance-chemical-equation C O2 CO2 C + O2 <=> CO2
$ balance-chemical-equation CH4 O2 CO2 H2O CH4 + 2 O2 <=> CO2 + 2 H2O
$ balance-chemical-equation C8H18 O2 CO2 H2O 2 C8H18 + 25 O2 <=> 16 CO2 + 18 H2O
You may use a custom reaction arrow:
$ balance-chemical-equation --arrow="->" HCl NaOH NaCl H2O HCl + NaOH -> NaCl + H2O
You may choose output of Unicode subscript and arrow characters:
$ balance-chemical-equation --unicode --arrow=$'\u21CC' N2 H2 NH3
If you mix multiple reactions then the program takes them apart, again. However, the resulting partial reactions may not be chemically sensible.
$ balance-chemical-equation C CH4 O2 CO2 H2O 2 C + 2 H2O <=> CH4 + CO2 C + O2 <=> CO2
The program knows nothing about chemistry and has no dictionary of elements. It cannot check whether the reactants are existing chemical substances or whether the reactions can happen in the real world. It accepts any capital letter followed by many lower-case letters as element symbols.
Mathematically speaking, balancing a reaction equation means computing the nullspace of an integer matrix, where all coefficients in the nullspace vectors are in turn integers. The matrix has a row for every element and a column for every reactant and every cell contains the multiplicity of an element in the according reactant. Our solver transforms this matrix to Reduced Row Echelon form, a generalization of Gauss elimination.
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| flint | Implementation using FLINT library | Disabled |
| lapack | Enable experimental implementation using LAPACK | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- chemical-equation-0.0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.0, 0.0.1 |
|---|---|
| Dependencies | base (>=4.5 && <5), comfort-array (>=0.5 && <0.6), containers (>=0.4 && <0.9), non-empty (>=0.3 && <0.4), numeric-quest (>=0.2.1 && <0.3), optparse-applicative (>=0.11 && <0.20), parsec (>=3.1 && <3.2), shell-utility (>=0.1 && <0.2), transformers (>=0.3 && <0.7), unicode (>=0.0 && <0.1), utility-ht (>=0.0.11 && <0.1) [details] |
| License | BSD-3-Clause |
| Author | Henning Thielemann |
| Maintainer | haskell@henning-thielemann.de |
| Uploaded | by HenningThielemann at 2026-04-28T15:54:12Z |
| Category | Chemistry |
| Home page | https://hub.darcs.net/thielema/chemical-equation |
| Source repo | this: darcs get https://hub.darcs.net/thielema/chemical-equation --tag 0.0.1 head: darcs get https://hub.darcs.net/thielema/chemical-equation |
| Distributions | |
| Executables | balance-chemical-equation-lapack, balance-chemical-equation-flint, balance-chemical-equation |
| Downloads | 4 total (4 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs not available [build log] Last success reported on 2026-04-28 [all 1 reports] |