Show HN: SymDerive – 一个函数式、无状态的符号数学库
9 分•作者: dinunnob•6 天前
嘿 HN,
我是一名从物理学家转行到量化领域的工程师。我和一些朋友“构建”了 SymDerive,因为我们想要一个从设计上就“原生支持 Agent”的符号数学库,同时仍然是一个对人类来说实用的工具。
它归结为两个主要目标:
1. Agent 可靠性:我发现,当 AI agents 坚持使用无状态的、函数式管道(Lisp 风格)时,它们编写的代码会更加可靠。这可以防止它们产生状态变化的幻觉,或者在冗长的程序脚本中迷失方向。我想要一个默认情况下强制执行“输入 -> 转换 -> 输出”流程的库。
2. 简化向 Python 的过渡:对于许多物理学家来说,Mathematica 是他们的母语。我希望有一种方法来简化这种过渡——提供一个桥梁,保持熟悉的语法(CamelCase、Sin、Integrate),同时严格使用 Python 科学栈。
我构建了什么:它是一个围绕标准栈(SymPy、PySR、CVXPY)的函数式封装,对于任何喜欢基于管道的工作流程的人——无论是人类还是 agent——来说,它都可以作为一个独立的引擎使用。
```python
# “管道”方法(对 agent 来说更简洁,对人类来说可读)
result = (
Pipe((x + 1)**3)
.then(Expand)
.then(Simplify)
.value
)
```
“Vibes”特性:
Wolfram 语法:Integrate、Det、Solve。如果你懂数学,你就懂 API。
模块化:繁重的功能(符号回归、凸优化)是可选安装的(\[regression],\[optimize])。除非你要求,否则它不会让你的 venv 膨胀。
物理学相关内容:我添加了我实际使用的工具——用于广义相对论的抽象指标记号、用于因果模型的 Kramers-Kronig 等。
它绝对是主观的,但如果你正在构建 agent 来进行严谨的数学运算,或者只是想为自己的研究提供一个熟悉的函数式接口,这可能会有所帮助。
我发现编排器(Claude Code 等)非常擅长学习这些工具并将任务发送给正确的角色,我们对它的效果感到惊讶。
Repo 地址:https://github.com/closedform/deriver
如果被吐槽得太狠,我会哭的。
查看原文
Hey HN,<p>I’m a physicist turned quant. Some friends and I 'built' SymDerive because we wanted a symbolic math library that was "Agent-Native" by design, but still a practical tool for humans.<p>It boils down to two main goals:<p>1. Agent Reliability: I’ve found that AI agents write much more reliable code when they stick to stateless, functional pipelines (Lisp-style). It keeps them from hallucinating state changes or getting lost in long procedural scripts. I wanted a library that enforces that "Input -> Transform -> Output" flow by default.<p>2. Easing the transition to Python: For many physicists, Mathematica is the native tongue. I wanted a way to ease that transition—providing a bridge that keeps the familiar syntax (CamelCase, Sin, Integrate) while strictly using the Python scientific stack under the hood.<p>What I built: It’s a functional wrapper around the standard stack (SymPy, PySR, CVXPY) that works as a standalone engine for anyone—human or agent—who prefers a pipe-based workflow.<p><pre><code> # The "Pipe" approach (Cleaner for agents, readable for humans)
result = (
Pipe((x + 1)**3)
.then(Expand)
.then(Simplify)
.value
)
</code></pre>
The "Vibes" features:<p>Wolfram Syntax: Integrate, Det, Solve. If you know the math, you know the API.<p>Modular: The heavy stuff (Symbolic Regression, Convex Optimization) are optional installs ([regression], [optimize]). It won’t bloat your venv unless you ask it to.<p>Physics stuff: I added tools I actually use—abstract index notation for GR, Kramers-Kronig for causal models, etc.<p>It’s definitely opinionated, but if you’re building agents to do rigorous math, or just want a familiar functional interface for your own research, this might help.<p>I have found that orchestrators (Claude Code, etc) are fairly good at learning the tools and sending tasks to the right persona, we have been surprised by how well it has worked.<p>Repo here: https://github.com/closedform/deriver<p>I will cry if roasted too hard