プロトタイプ · プレビュー版:公式レジストリのすべてのサーバーを掲載し、30分ごとに同期しています。Google でログインするとレビューを書けます。プロトタイプ · 30分ごとに更新
PopNx MCPAIを使う人のためのMCPサーバー · やさしい言葉で解説

Pycodemath

作者:cybersora9バージョン 0.5.2i★ 8iパソコンで動く公式サイト ↗
レジストリ名io.github.cybersora9/pycodemath

インストール方法

What it does

Checks the math in your code and gives AI agents an exact math engine (SymPy + NumPy).

  • Connects パソコンで動く
  • Account or key No key needed
  • Category 開発者ツール

一緒に使える

この種の作業を AI に教える Skill。これと一緒に使えます

rea

Reverse engineer anything with agents, from app behavior down to native binaries.

作者:morluto★ 468,7131 個の skill

Skill · 手順書

andrej-karpathy-skills

A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.

作者:multica-ai★ 234,3281 個の skill

Skill · 手順書ライセンス記載なし

graphify

Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.

作者:Graphify-Labs★ 150,2761 個の skill

Skill · 手順書

この順位の理由

一覧は利用スコア(100 点満点)で並びます。内訳は次のとおり

人気11/80GitHub スターか週間ダウンロード数。大きい方を 60、小さい方を 20 で数えます
新しさ12/1230 日以内のリリースかコード更新で満点
応答中0/8前回の確認でクラウドのエンドポイントが応答
利用スコア23/100

品質: 基本チェック 3/3 項目に合格(表示のみ、並び順には不使用) · 勢い: データなし (「急上昇」タブでのみ使用)

インストール

使っているAIアプリを選んで、設定をコピーしてください。

ひとことで AI にインストールしてもらう

Pycodemath をインストールして。https://mcp.popnx.com/i/cybersora9-pycodemath.md に従い、コマンドを見せて、私が OK するまで実行しないで。

パソコンで作業できる AI(Claude Code や Cursor など)に貼り付けます。手順を読み、コマンドを見せて、あなたの OK を待ちます。キー不要・登録不要。 · AI が読む全文を見る

チェック 3/3 合格 · あなたのパソコンで動きます · ✓ コマンド確認済み 2026年11月14日

まず:どの AI を使っていますか?

使っているアプリを選ぶと、下に手順が表示されます。

Claude につなげますが、先に準備が必要です

先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません

AI にインストールしてもらう

このメッセージを Claude のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。

このパソコンの Claude に MCP server Pycodemath を入れてください。順番に:1) uv --version で uv があるか確認。なければ https://docs.astral.sh/uv/getting-started/installation/ から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "mcpServers": { "pycodemath": { "command": "uvx", "args": [ "pycodemath", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、Pycodemath のツールが本当に表示されるか確認する。

このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。

  1. uv を入れる(まだなければ)

    もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter

    uv --version
    • バージョン番号(例 uv …)が出る = 入っています。この手順は飛ばせます
    • "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
    ターミナルの開き方

    Mac:⌘ + Space を押し、Terminal と入力して Enter

    Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」

    まだ入っていない場合: uv にはクリック式のインストーラーがありません。uv 公式ページからお使いの OS(macOS か Windows)用の 1 行コマンドをコピーしてターミナルに貼り付けます · Python を別に入れる必要はなく、必要なときに uv が自動で取得します

    uv のダウンロードページを開く ↗

    入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です: uv --version

    一度入れれば、uv を使うすべてのツールで使えます

  2. パソコン版 Claude アプリの設定ファイルを開く

    SettingsDeveloperEdit Config

  3. この設定を貼り付けて保存

    {
      "mcpServers": {
        "pycodemath": {
          "command": "uvx",
          "args": [
            "pycodemath",
            "mcp"
          ]
        }
      }
    }
  4. Claude を終了してもう一度開く

  5. 試してみる

    Pycodemath を使って、私に何ができるか教えて、1 つやってみせて

    ✓ Claude が Pycodemath を使っていると言うか、回答に Pycodemath のツール名が出れば接続成功です

メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります

ChatGPT はまだ Pycodemath につなげません

Pycodemath はパソコンに入れて使うものですが、ChatGPT は Web 上で動くサーバーにしかつなげません

代わりにできること

A · Pycodemath につなげるアプリを使う

  • 先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
  • 先にパソコンへ Python (uv) を入れてください(1 回だけ)
  • 先にパソコンへ Python (uv) を入れてください(1 回だけ)
  • 先にパソコンへ Python (uv) を入れてください(1 回だけ)

B · 開発者ツール の中で ChatGPT につなげる別のサーバー

同じカテゴリでよく使われているものから、キーなしでアドレスだけでつなげるものを選びました

Claude Code につなげますが、先に準備が必要です

先にパソコンへ Python (uv) を入れてください(1 回だけ)

AI にインストールしてもらう

このメッセージを Claude Code のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。

このパソコンの Claude Code に MCP server Pycodemath を入れてください。順番に:1) uv --version で uv があるか確認。なければ https://docs.astral.sh/uv/getting-started/installation/ から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):claude mcp add --scope user pycodemath -- uvx pycodemath mcp 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、Pycodemath のツールが本当に表示されるか確認する。

このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。

  1. uv を入れる(まだなければ)

    もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter

    uv --version
    • バージョン番号(例 uv …)が出る = 入っています。この手順は飛ばせます
    • "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
    ターミナルの開き方

    Mac:⌘ + Space を押し、Terminal と入力して Enter

    Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」

    まだ入っていない場合: uv にはクリック式のインストーラーがありません。uv 公式ページからお使いの OS(macOS か Windows)用の 1 行コマンドをコピーしてターミナルに貼り付けます · Python を別に入れる必要はなく、必要なときに uv が自動で取得します

    uv のダウンロードページを開く ↗

    入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です: uv --version

    一度入れれば、uv を使うすべてのツールで使えます

  2. ターミナルを開く

    Mac:Command+スペースで Terminal と入力 · Windows:PowerShell を開く

  3. このコマンドを貼り付けて Enter

    claude mcp add --scope user pycodemath -- uvx pycodemath mcp
  4. Claude Code で /mcp と入力

    Pycodemath が一覧にあり、接続済みと表示されれば OK です

  5. 試してみる

    Pycodemath を使って、私に何ができるか教えて、1 つやってみせて

    ✓ Claude Code が Pycodemath を使っていると言うか、回答に Pycodemath のツール名が出れば接続成功です

メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります

Cursor につなげますが、先に準備が必要です

先にパソコンへ Python (uv) を入れてください(1 回だけ)

AI にインストールしてもらう

このメッセージを Cursor のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。

このパソコンの Cursor に MCP server Pycodemath を入れてください。順番に:1) uv --version で uv があるか確認。なければ https://docs.astral.sh/uv/getting-started/installation/ から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "mcpServers": { "pycodemath": { "command": "uvx", "args": [ "pycodemath", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、Pycodemath のツールが本当に表示されるか確認する。

このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。

  1. uv を入れる(まだなければ)

    もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter

    uv --version
    • バージョン番号(例 uv …)が出る = 入っています。この手順は飛ばせます
    • "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
    ターミナルの開き方

    Mac:⌘ + Space を押し、Terminal と入力して Enter

    Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」

    まだ入っていない場合: uv にはクリック式のインストーラーがありません。uv 公式ページからお使いの OS(macOS か Windows)用の 1 行コマンドをコピーしてターミナルに貼り付けます · Python を別に入れる必要はなく、必要なときに uv が自動で取得します

    uv のダウンロードページを開く ↗

    入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です: uv --version

    一度入れれば、uv を使うすべてのツールで使えます

  2. このボタンで Cursor を開く

    Cursor で開く

    Cursor がインストールの確認をするので Install を押します

  3. Cursor の AI チャットを Agent モードで開く

  4. 試してみる

    Pycodemath を使って、私に何ができるか教えて、1 つやってみせて

    ✓ Cursor が Pycodemath を使っていると言うか、回答に Pycodemath のツール名が出れば接続成功です

メニュー名は 2026年11月11日 に Cursor のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります

VS Code につなげますが、先に準備が必要です

先にパソコンへ Python (uv) を入れてください(1 回だけ)

AI にインストールしてもらう

このメッセージを VS Code のチャットに貼り付けます。AI がパソコンを確認し、変更するファイルを伝え、毎回あなたの了承を待ちます。

このパソコンの VS Code に MCP server Pycodemath を入れてください。順番に:1) uv --version で uv があるか確認。なければ https://docs.astral.sh/uv/getting-started/installation/ から入れるよう私に伝え、自分では入れない。2) この設定だけを使う(PopNx MCP の確認済み):{ "servers": { "pycodemath": { "type": "stdio", "command": "uvx", "args": [ "pycodemath", "mcp" ] } } } 3) 変更するファイルのフルパスか実行するコマンドを伝えて、私の了承を待つ。4) キーは不要。5) 了承した内容を実行し、Pycodemath のツールが本当に表示されるか確認する。

このメッセージにあなたのキーは含まれません。キーが必要な場合は、AI がファイルやアプリの入力欄にご自身で貼るよう案内します。

  1. uv を入れる(まだなければ)

    もう入っていますか?先に確認 · ターミナルを開き、このコマンドを入力して Enter

    uv --version
    • バージョン番号(例 uv …)が出る = 入っています。この手順は飛ばせます
    • "command not found"(Windows では "is not recognized")が出る = まだ入っていないか、入れた直後でターミナルを開き直す必要があります
    ターミナルの開き方

    Mac:⌘ + Space を押し、Terminal と入力して Enter

    Windows:スタートメニューを開き、Windows PowerShell と入力して「開く」

    まだ入っていない場合: uv にはクリック式のインストーラーがありません。uv 公式ページからお使いの OS(macOS か Windows)用の 1 行コマンドをコピーしてターミナルに貼り付けます · Python を別に入れる必要はなく、必要なときに uv が自動で取得します

    uv のダウンロードページを開く ↗

    入れ終わったらターミナルを閉じて開き直し、同じコマンドをもう一度実行します。バージョン番号が出れば完了です: uv --version

    一度入れれば、uv を使うすべてのツールで使えます

  2. このボタンで VS Code を開く

    VS Code で開く

    VS Code がインストールの確認をするので Install を押します

  3. VS Code の AI チャットを Agent モードで開く

  4. 試してみる

    Pycodemath を使って、私に何ができるか教えて、1 つやってみせて

    ✓ VS Code が Pycodemath を使っていると言うか、回答に Pycodemath のツール名が出れば接続成功です

メニュー名は 2026年11月11日 に VS Code のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります

Windsurf、Zed、Gemini CLI など MCP を使える他のアプリは追加方法がそれぞれ違います。アプリ一覧で確認してください

MCP を使えるアプリをすべて見る →

JSON 設定は下の「開発者向け」にあります

つまずいたら?Pycodemath を使っている人に聞いてみましょう💬 ディスカッション →
開発者向け:ターミナルのコマンドと JSON 設定

パソコンにインストール

Claude Code

claude mcp add --scope user pycodemath -- uvx pycodemath mcp

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "pycodemath": {
      "command": "uvx",
      "args": [
        "pycodemath",
        "mcp"
      ]
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "pycodemath": {
      "command": "uvx",
      "args": [
        "pycodemath",
        "mcp"
      ]
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "pycodemath": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "pycodemath",
        "mcp"
      ]
    }
  }
}

この設定は、作者のレジストリ登録情報から作成しています。READMEと違う場合は、READMEに従ってください。

ひと目でわかる

週あたりのダウンロードi
42/週
接続方法
パソコンで動く
最新バージョンi
0.5.2
レジストリ公開日i
2026年11月14日
コードの最終更新i
2026年11月14日
作者
cybersora9
パッケージ
pypi: pycodemath
ウェブサイト
cybersora.pl
レジストリでの状態
有効

使えるアプリ

このサーバーのつなぎ方と、各アプリの公式ドキュメントに基づきます。2026年11月10日に確認。

パソコン上で動かせるアプリ

ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast

すべてのアプリと長所・短所 →

できること

パソコンで動くサーバーです。インストールすると、ツール一覧がAIアプリに表示されます。

基本チェックi

誰でも見られる情報をチェックしており、コードは読んでいません。当てはまらない項目は数に入れていません。 · 2026年11月19日にチェック

  • ✓ 合格

    作者とリポジトリが一致

    レジストリ名は、リポジトリを所有するGitHubアカウント cybersora9 で確認済みです

  • ✓ 合格

    今もメンテナンスされている

    コードの最終更新:5 日前

  • ✓ 合格

    ライセンスがある

    MITを使用

  • – 対象外

    エンドポイントが応答する

    これはパソコンで動くため、インターネット上のエンドポイントはありません

  • – 対象外

    OAuthでサインイン

    パソコンで動き、代わりにローカルの設定を使います

  • … 未チェック

    ツールの説明に隠れた指示がない

    パソコンで動くサーバーです。ツール一覧を読み取れるのは、インターネット上のエンドポイントがある場合だけです

公開済みの脆弱性(OSV.dev)

OSV.dev に pycodemath@0.5.2 の登録はありません

このバージョンのパッケージ本体のみ確認。すべての依存関係ではありません · 確認日 2026年11月15日

確認していること → · JSON

作者の方へ:再確認の依頼・情報の誤りの報告
作者向け:README にバッジを付ける

作者の方は、このコードを README に貼れます。バッジはこのページにリンクします。

[![Featured on PopNx MCP](https://mcp.popnx.com/badge/cybersora9-pycodemath.svg)](https://mcp.popnx.com/en/servers/cybersora9-pycodemath)

話し合い

質問、コツの共有、使えないことの報告ができます。「役に立った」の多い順です。

まだ投稿はありません。最初の質問や共有をどうぞ。

ここの投稿は利用者によるもので、PopNx チームのものではありません。

ログインして投稿

ユーザーレビュー

まだレビューはありません

ログインしてレビューを書く

開発者ツールのほかのサーバーとの比較i

  • このカテゴリのほかの6136件のうち88%よりスターが多い
  • このカテゴリのほかの6136件のうち89%より最近レジストリに公開
  • 基本チェックの結果が、このカテゴリのほかの6136件のうち99%と同じかそれ以上

レジストリでこのカテゴリにある有効なすべてのサーバーと比較しています。スターは、公開者がリポジトリの所有者である場合だけ数えます。

よくある質問

Pycodemathは安全ですか?

当てはまる基本チェック3項目のうち3項目に合格しました。コードは読んでいません。キーやトークンを追加する前に、サーバーがどんなアクセスを求めているかを確認し、必要な権限だけを持つキーを使ってください。

どんなキーやコードが必要ですか?

レジストリには必須のキーは載っていません。ただし、最初に使うときにサインインを求めるサーバーもあります。

パソコンで動きますか、それともクラウドですか?

あなたのパソコンで動きます。必要なときにAIアプリが起動し、データは作者のサーバーを通りません(サーバー自体がオンラインサービスを呼び出す場合を除きます)。

今もメンテナンスされていますか?

GitHubリポジトリの最終更新は5 日前、最新バージョン(0.5.2)がレジストリに届いたのは5 日前です。

どのアプリで使えますか?

Claude Desktop、Claude Code、Cursor、VS CodeなどのMCP対応アプリで使えます。パソコンにPython (uv)も必要です。

代わりに使えるものは?

同じカテゴリには:GitDiagram, Appllama, Cloudflare MCP, Omnara, Repowise

似た働きのほかの候補

同じカテゴリでほかの作者のもの。コマンドは確認済み。公式を先に、次にスター順。

カードの見方:↓ 週あたりのダウンロードi★ GitHubスターi3つの柱:レビュー · チェック · 利用状況i更新=最新バージョンをレジストリに公開した日i

GitDiagram

Architecture diagrams, explanations and Mermaid source for public GitHub repositories.

作者:ahmedkhaleel2004広く使われている★ 1.9万2 か月前更新

クラウドで動く✓ 提供元 · gitdiagram.comPopNx チームが実際に試用

Appllama

Study screens, flows and paywalls from top-earning iOS apps, then build from what wins.

作者:Appllama広く使われている★ 52303 か月前更新

クラウドで動く✓ 提供元 · appllama.io

Omnara

Deploy durable AI agents with Omnara, an open-source managed-agent platform.

作者:omnara-ai広く使われている★ 34172 か月前更新

クラウドで動く✓ 提供元 · omnara.com

Repowise

Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.

作者:repowise-dev広く使われている↓ 6506/週★ 8180 リポジトリ全体のスター6 日前更新

パソコンでもクラウドでも✓ 提供元 · repowise.dev
似たものと比べる
これ
Pycodemath
GitDiagramAppllamaCloudflare MCPOmnaraRepowise
動く場所パソコンにインストールが必要クラウドで動き、インストール不要クラウドで動き、インストール不要クラウドで動き、インストール不要クラウドで動き、インストール不要クラウドでもパソコンにインストールでも使える
キーが必要いいえいいえいいえいいえいいえいいえ
Claude で + から追加いいえいいえいいえはいいいえいいえ
基本チェック3/34/44/44/44/45/5
ライセンスMITMITMITApache-2.0Apache-2.0AGPL-3.0
料金登録情報に費用の記載なし登録情報に費用の記載なし登録情報に費用の記載なし登録情報に費用の記載なし登録情報に費用の記載なし登録情報に費用の記載なし

作者のREADME

READMEを開く

作者のリポジトリから書かれたとおりにコピーしたものです。PopNx MCPは内容を確認・推奨していません。HTML、画像、スクリプトは取り除いています。リンクはこのサイトの外へ移動します。

Your code looks right. Is the math?

Pycodemath checks the math in your Python code. Give it a function and the formula it should compute. You get a proof that they match, or the exact input that breaks the function. No guessing, no random samples.

pip install pycodemath
# example.py

from pycodemath import check_code

SRC = ''' def sum_to(n: int) -> int: # should return 0 + 1 + ... + n total = 0 for k in range(n): # off by one: stops at n-1 total += k return total '''

if name == "main": # needed on Windows: your function runs in a worker process r = check_code(SRC, "n*(n+1)/2") print(r.verdict) # refuted print(r.counterexample.call) # sum_to(n=1) print(r.reason) # sum_to(n=1) returns 0, the formula gives 1 ...

REFUTED always comes with a concrete input that was really executed (the *witness*). VERIFIED is a proof. Anything else is UNDECIDED, with a reason. Fix the loop to range(n + 1), tell it n is a non-negative integer (domain={"n": "integer, n>=0"}), and the same call comes back VERIFIED.

Pycodemath is also an exact math engine and an MCP server for AI agents (SymPy + NumPy): write math in a few characters, get an exact answer or standalone, optimized Python/NumPy code back, instead of asking a language model to "do arithmetic in its head".

*Polska wersja tego dokumentu: README.pl.md.*

Contents: Check the math in your code · Install · First run · Quick start · Verify · Results you can branch on · Code generation · Design contracts

Four checks in 0.5.1, in one minute

1. A solver that silently drops a root. exp(x) = 3x has two real solutions; SymPy's solve returns one. certify re-checks the answer and finds the missing root:

$ python -m pycodemath "certify solve exp(x) = 3*x for x"

-LambertW(-1/3) certificate: REFUTED (sign-scan) — a root is missing: the expression changes sign at x ≈ 1.51213455165784 (confirmed at 30 and 60 digits), where no listed root lies

2. A system of equations, with proof the list is complete:

$ python -m pycodemath "solve x^2 + y^2 = 25, x + y = 7 for x, y"

x = 3, y = 4; x = 4, y = 3 proof: every solution substituted gives 0; the number of distinct complex solutions equals the dimension of Q[vars]/radical(I) (Seidenberg), so the list is complete certificate: VERIFIED (groebner) — every solution substituted gives 0; the number of distinct complex solutions equals the dimension of Q[vars]/radical(I) (Seidenberg), so the list is complete

3. A formula that loses precision, rewritten and proved equal:

$ python -m pycodemath "improve sqrt(x+1)-sqrt(x) for x in [1e6, 1e12]"

1 / (sqrt(x + 1) + sqrt(x)): 28.5 -> 0.4 bits of error on average (39.9 -> 1.6 at worst), proved by check_equal proof: verified (check_equal) — left - right simplifies to 0; agree numerically at 32 of 32 sample points certificate: VERIFIED (symbolic) — left - right simplifies to 0; agree numerically at 32 of 32 sample points

4. Money split to the cent, with no lost grosz:

$ python -m pycodemath "money split 100 PLN into 3"

33.34 + 33.33 + 33.33 = 100.00 PLN (hamilton; sums exactly: True) certificate: VERIFIED (exact) — shares sum to the total exactly (rational sum); zero weights get zero; every share within one unit of its quota; equal split: spread <= one unit; shares re-added in exact fractions

88 commands in 11 sections: run pycodemath commands for the full list, or pycodemath tour.

What it does

Built as a thin, disciplined layer over SymPy + NumPy:

  1. Cut tokens — one short command in, one exact result out. Perfect as an agent tool (MCP server included).
  2. Better code than naive Python — the generator applies symbolic simplification + common-subexpression elimination (CSE) before emitting code (measured ~1.7x faster than naive expansion on repeated subexpressions).
  3. Answers you can branch on — a failure is a TYPE, not a message, and a numerical answer can hand back the evidence behind it. See Results you can branch on.
  4. Check instead of compute — an identity, a derivation step by step, or an engine answer, judged VERIFIED / REFUTED (with a counterexample) / UNDECIDED. See Verify.
  5. Check the math in your code — a function against its formula, float accuracy, overflow, money, units and geometry, each with a witness or a proof. See Check the math in your code.
text → [parser] → IR (expression tree) → [engine]     evaluate / simplify / solve

→ [generator] IR → CSE → Python/NumPy source

Check the math in your code

Code that computes a formula can be checked like an identity. Pycodemath reads a Python function, proves it equal to the formula it should compute, or hands back the exact call that breaks it — really executed, never "it disagreed on some random samples". The same contract runs through every check below: VERIFIED is a proof, REFUTED always carries a concrete witness checked exactly, and anything else is UNDECIDED with a reason. Every answer ends with a certificate: line — the check written down, re-runnable from the file alone (see Certificates).

Does this function compute that formula? The classic off-by-one:

>>> from pycodemath import check_code, emit_test

>> src = "def sum_to(n: int) -> int:\n total = 0\n for k in range(n):\n total += k\n return total\n"

>> r = check_code(src, "n*(n+1)/2")

>> r.verdict, r.counterexample.call

('refuted', 'sum_to(n=1)')

>> r.reason

'sum_to(n=1) returns 0, the formula gives 1 — confirmed by executing the function and evaluating the formula exactly'

>> check_code(src, "n*(n-1)/2", domain={"n": "integer, n>=0"}).verdict

'verified'

>> "assert sum_to(n=1) == 1" in emit_test(r, module="sums")

True

Correct code comes back VERIFIED with a proof (symbolic, branch by branch, or an exact certificate for integer code with // and %). Float rounding alone never counts as a bug here — that is what stability is for. emit_test writes the pytest that pins the counterexample. From the shell, on your own file (its function is executed in an isolated worker to confirm a refutation):

python -m pycodemath "verify code sums.py:sum_to == n*(n+1)/2 --emit-test"

python -m pycodemath "verify code sums.py:sum_to == n*(n-1)/2 where n: integer, n>=0"

Floating-point accuracy, with proof. How many bits does float64 lose, where, and why — and a rewrite that is proved equal and measured better:

$ python -m pycodemath "stability sqrt(x + 1) - sqrt(x) for x in [1e10, 1e15]"

sqrt(x + 1) - sqrt(x) [float64]: loses 41.0 bits on average (max 49.9); worst at {'x': '510800533960562.3'} worst: at x = 510800533960562.3 computes 1.862645149230957e-08, exact 2.2123015980434279398e-8 (49.9 bits) culprit: sqrt(x + 1) - sqrt(x) — cancellation: subtracting nearly equal values (41.0 bits on average); try p - sqrt(q) -> (p^2 - q) / (p + sqrt(q)) (conjugate) certificate: REFUTED (re-evaluation) — at x = 510800533960562.3: float64 computes 1.862645149230957e-08 (emitted NumPy code), exact 2.2123015980434279398E-8 (SymPy, 40 digits): 49.9 bits lost (more than 3)

>>> from pycodemath import diagnose, improve

>> rep = diagnose("sqrt(x + 1) - sqrt(x)", {"x": (1e10, 1e15)})

>> round(rep.mean_bits, 1), rep.culprits[0].cause

(41.0, 'cancellation: subtracting nearly equal values')

>> imp = improve("sqrt(x + 1) - sqrt(x)", {"x": (1e10, 1e15)})

>> imp.best.expression, imp.best.proof.status, round(imp.best.mean_bits, 1)

('1 / (sqrt(x + 1) + sqrt(x))', 'verified', 0.4)

improve ... emit python|numpy|c prints the code that computes exactly what was measured. No rewrite is ever returned without a proof. Compared with Herbie on the 11 Hamming benchmarks the optimizer was not tuned on: 7.25 bits of error left vs 8.08 for Herbie's outputs (better on 3, worse on 5, tied on 3) — against Herbie's published 2017 report (the 1.1 era), not today's Herbie 2.x, which could not be installed in the measuring environment.

Will it overflow? The 2006 binary-search bug, with the input that breaks it (executed in NumPy int32) and a fix that is proved equivalent:

$ python -m pycodemath "ranges (lo + hi) // 2 for lo in [0, 2^31-1], hi in [0, 2^31-1] as int32"

(lo + hi) // 2 [int32] -> problems confirmed overflow lo + hi at {'hi': '2147483647', 'lo': '2147483647'} -> -2 advice: lo + (hi - lo) // 2 [int32] removes overflow advice: (lo + hi) // 2 [int64] removes overflow advice proof: lo + (hi - lo) // 2 — verified (symbolic (integer parity cases)) advice proof: (lo + hi) // 2 — verified (same expression) certificate: REFUTED (execution) — overflow at lo + hi: lo + hi at hi=2147483647, lo=2147483647: got -2, exact 4294967294

$ python -m pycodemath "maxsafe exp(x) for x as float32" x <= 88.72283172607422 is safe in float32 (exact bound 11629079/131072; interval/exhaustive proof below, executed witness above) first failure: exp(x) at x=88.72283935546875: got inf, exact 3.4028244988034356558e+38 x <= 88.72283172607422 is proved safe; x = 88.72283935546875 fails (overflow at exp(x)) certificate: VERIFIED (proof) — no event in float32 over the given ranges

int8…uint64, float16, bfloat16, float32, float64: overflow, underflow, subnormals, NaN, division by zero, lost integer precision (for t_ms in [0, 2^31-1] int as float32 — millisecond timestamps in float32). "Safe" is a proof, not a guess. In Python: pycodemath.code.analyze(expr, ranges, dtype) and max_safe_input.

Calculator that proves its answers
$ python -m pycodemath "factor 2^64+1"

274177 * 67280421310721 certificate: VERIFIED (proof) — product of the factors equals 18446744073709551617 exactly; each factor is proven prime; re-multiplied: the factors give the number back

$ python -m pycodemath "special zeta 3 digits 50" 1.2020569031595942853997381615114499907649862923405 certificate: VERIFIED (cross-check) — precision ladder: values at 65 and 130 digits agree; Euler-Maclaurin summation agrees with the default (Borwein) algorithm

$ python -m pycodemath "var sample 1 2 3 4" 5/3 certificate: VERIFIED (proof) — exact rational sample variance over a common denominator

Primality is proved (deterministic Miller–Rabin below 3.3·10²⁴, Lucas–Lehmer or a re-checkable Pocklington certificate above it; anything only BPSW-probable is UNDECIDED and says so). Number theory, combinatorics, 13 special functions at any precision, exact descriptive statistics, 7 distributions and a

冒頭だけを表示しています。続きはリポジトリで読めます