--- license: apache-2.0 license_link: LICENSE library_name: discrete-math-ai999x language: - en inference: false pipeline_tag: question-answering tags: - discrete-math - number-theory - combinatorics - graph-theory - logic - cryptography - modular-arithmetic - propositional-logic - rsa - question-answering - rust - discrete-math-solver - step-by-step-solutions - homework-help - offline - zero-hallucination - python - ai999x model-index: - name: discrete-math-ai999x results: - task: type: question-answering name: discrete math question answering dataset: name: "Golden answers (566 documented questions, Windows + Linux Python 3.10-3.14)" type: ai999x-evaluation metrics: - type: accuracy value: 1.0 name: "identical on every platform" --- # Discrete Math (discrete-math-ai999x) Discrete Math covers number theory, modular arithmetic, combinatorics, graph theory and network algorithms, logic and the mathematics of cryptography: 103 calculations in 9 topics, each with its formula, its steps and its units, and a plain reason instead of a number when an input is missing or out of range. One compiled engine, four ways to use it: the desktop app, the command line, the browser and Python. Everything runs on your own computer, offline. [![The Discrete Math desktop app: Modular multiplicative inverse, with its worked example and live scene](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/hero.webp)](https://www.ai999x.com/models/discrete-math-ai999x/) ## Four ways to use it | | | |---|---| | **Desktop app** (Windows, Linux) | [Windows](https://github.com/AI999X/ai999x-desktop/releases/download/v1.6.7/ai999x-discrete-math-1.6.7-windows-x86_64.zip) · [Linux](https://github.com/AI999X/ai999x-desktop/releases/download/v1.6.7/ai999x-discrete-math-1.6.7-linux-x86_64.tar.gz) | | **Command line** `discrete-math` (Windows, Linux) | [Windows](https://github.com/AI999X/ai999x-desktop/releases/download/v1.6.7/ai999x-cli-1.6.7-windows-x86_64.zip) · [Linux](https://github.com/AI999X/ai999x-desktop/releases/download/v1.6.7/ai999x-cli-1.6.7-linux-x86_64.tar.gz) | | **Browser** (any device) | [Try it on the model page](https://www.ai999x.com/models/discrete-math-ai999x/#capabilities) | | **Python** 3.10+ | `pip install discrete-math-ai999x`: on Windows and Linux (x86-64) `pip` installs the same compiled engine; on other systems (macOS, ARM) it installs a pure-Python build that gives the same answers | ## See it From the Discrete Math desktop app: every scene and chart is drawn from the computed answer. [![Discrete Math desktop app: a slider moves an input and the answer, the scene and the charts follow](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/clip-loop.webp)](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/clip.mp4) *[Watch the full clip (MP4)](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/clip.mp4)* | | | |---|---| | [![Modular multiplicative inverse: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-1.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-mod_inverse)
Modular multiplicative inverse | [![Derangements: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-2.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-derangements)
Derangements | | [![Chromatic number of a small graph: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-3.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-chromatic_number)
Chromatic number of a small graph | [![Tautology test: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-4.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-logic_tautology)
Tautology test | | [![Affine cipher: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-5.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-affine_cipher)
Affine cipher | [![Base (radix) conversion: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-6.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-base_convert)
Base (radix) conversion | | [![Venn diagram with three sets (inclusion-exclusion): the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-7.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-venn_three_sets)
Venn diagram with three sets (inclusion-exclusion) | [![Apportionment: Hamilton, Jefferson, Webster, Adams and Huntington-Hill: the live scene in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/scene-8.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-apportionment)
Apportionment: Hamilton, Jefferson, Webster, Adams and Huntington-Hill | Charts: | | | | | |---|---|---|---| | [![Modular multiplicative inverse: a chart in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/chart-1.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-mod_inverse)
Modular multiplicative inverse | [![Derangements: a chart in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/chart-2.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-derangements)
Derangements | [![Chromatic number of a small graph: a chart in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/chart-3.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-chromatic_number)
Chromatic number of a small graph | [![Tautology test: a chart in the Discrete Math desktop app](https://www.ai999x.com/?ax_shot=discrete-math-ai999x/chart-4.webp)](https://www.ai999x.com/models/discrete-math-ai999x/#cap-logic_tautology)
Tautology test | ## Ask in words: 15 examples Each question below was asked on this release; the comment under it is the line it printed. ```python import discrete_math_ai999x as discrete_math a = discrete_math.ask("What is the 5th Bell number?") print(a.outcome, a.values) # SOLVED {'bell': 52} a = discrete_math.ask( "Encrypt \"AFFINE CIPHER\" with the affine cipher a = 5, b = 8." ) print(a.outcome, a.values) # SOLVED {'result': 'IHHWVCSWFRCP'} a = discrete_math.ask("Is p & ~p a contradiction?") print(a.outcome, a.values) # SOLVED {'contradiction': True, 'true_rows': 0, 'witness': None} a = discrete_math.ask( "Solve x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7)." ) print(a.outcome, a.values) # SOLVED {'x': 23, 'modulus': 105} a = discrete_math.ask("Convert 1011 from base 2 to base 10.") print(a.outcome, a.values) # SOLVED {'result': '11', 'decimal': 11} a = discrete_math.ask("Compute the Carmichael function of 15.") print(a.outcome, a.values) # SOLVED {'lambda': 4} a = discrete_math.ask("What is the Bernoulli number B_10?") print(a.outcome, a.values) # SOLVED {'numerator': 5, 'denominator': 66, 'value': 0.07575757575757576} a = discrete_math.ask( "Encrypt \"HELLO WORLD\" with a Caesar shift of 3." ) print(a.outcome, a.values) # SOLVED {'result': 'KHOORZRUOG'} a = discrete_math.ask( "Is the graph with edges A-B, B-C, C-D, D-A bipartite?" ) print(a.outcome, a.values) # SOLVED {'is_bipartite': True} a = discrete_math.ask( "Evaluate (p -> q) & ~r when p = true, q = false, r = false." ) print(a.outcome, a.values) # SOLVED {'value': False} a = discrete_math.ask("Find the smallest x with 3^x ≡ 13 (mod 17).") print(a.outcome, a.values) # SOLVED {'x': 4} a = discrete_math.ask("What is the 8-bit two's complement of -5?") print(a.outcome, a.values) # SOLVED {'bits_text': '11111011', 'unsigned': 251} a = discrete_math.ask("Find the continued fraction of 415/93.") print(a.outcome, a.values) # SOLVED {'terms': [4, 2, 6, 7], 'length': 4} a = discrete_math.ask( "Venn diagram: n(A) = 45, n(B) = 60, n(A and B) = 20, n(U) = 100. " "Find the count of every region." ) print(a.outcome, a.values) # SOLVED {'union': 85, 'only_a': 25, 'only_b': 40, 'neither': 15} a = discrete_math.ask( "How many bracelets with 6 beads can be made using 2 colours?" ) print(a.outcome, a.values) # SOLVED {'bracelets': 13, 'necklaces': 14} ``` ## Command line: 15 examples Each command below was run with `discrete-math` of this release; the lines under it are the answer it printed (the full answer goes on with the method, every input in SI units and the conditions it assumes). ```text $ discrete-math solve bell n=5 bell = 52 $ discrete-math solve affine_cipher a=5 b=8 "message=AFFINE CIPHER" mode=encrypt result = IHHWVCSWFRCP $ discrete-math solve articulation_points "edges=A-B, B-C, C-A, C-D, D-E" count = 2 points = ["C","D"] $ discrete-math solve logic_contradiction "formula=p & ~p" contradiction = true true_rows = 0 witness = null $ discrete-math solve crt "residues=[2, 3, 2]" "moduli=[3, 5, 7]" x = 23 modulus = 105 $ discrete-math solve base_convert digits=1011 from_base=2 to_base=10 result = 11 decimal = 11 $ discrete-math solve carmichael_lambda n=15 lambda = 4 $ discrete-math solve venn_three_sets a=30 b=25 c=20 ab=10 ac=8 bc=5 abc=3 universe=60 union = 55 only_a = 15 only_b = 13 only_c = 10 only_a_and_b = 7 only_a_and_c = 5 $ discrete-math solve apportionment method=jefferson seats=10 "populations=[2400, 3300, 4300]" seats = [2,3,5] standard_divisor = 1000 quotas = [2.4,3.3,4.3] total_seats = 10 $ discrete-math solve bernoulli n=10 numerator = 5 denominator = 66 value = 0.07575757576 $ discrete-math solve caesar_cipher "message=HELLO WORLD" mode=encrypt shift=3 result = KHOORZRUOG $ discrete-math solve bipartite "edges=A-B, B-C, C-D, D-A" is_bipartite = true $ discrete-math solve logic_evaluate "formula=(p -> q) & ~r" "assignment=p = true, q = false, r = false" value = false $ discrete-math solve linear_congruence a=3 b=4 m=7 smallest = 6 count = 1 step = 7 $ discrete-math solve twos_complement n=-5 bits=8 bits_text = 11111011 unsigned = 251 ``` ## Guides - Desktop app guide: the window, every calculation, scenes and charts: [PDF](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_desktop_guide.pdf) · [HTML](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_desktop_guide.html) · [Markdown](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_desktop_guide.md) - Python guide: every calculation with a Python example: [PDF](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_capabilities.pdf) · [HTML](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_capabilities.html) · [Markdown](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_capabilities.md) - Command-line guide: every calculation with the command and what it printed: [PDF](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_rust_guide.pdf) · [HTML](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_rust_guide.html) · [Markdown](https://huggingface.co/AI999X/discrete-math-ai999x/blob/main/docs/discrete_math_ai999x_rust_guide.md) Every calculation, with its formula, a worked example and its figures: **[Discrete Math on ai999x.com](https://www.ai999x.com/models/discrete-math-ai999x/)**. Install guides for the app and the command line: [https://www.ai999x.com/desktop-cli/](https://www.ai999x.com/desktop-cli/). Version 1.6.7 · License: Apache-2.0 · Author: Ibnul Jaif Farabi · Organization: AI999X · Contact: support@ai999x.com · [Support the project](https://buymeacoffee.com/ibnuljaiffarabi) *The Future Is Self-Improving.*